/* This function is reentrant */ static int handle_signal (Signal_Type *s) { int status = 0; int was_blocked; (void) block_signal (s->sig, &was_blocked); /* At this point, sig is blocked and the handler is about to be called. * The pending flag can be safely set to 0 here. */ s->pending = 0; if (s->handler != NULL) { int depth = SLstack_depth (); if ((-1 == SLang_start_arg_list ()) || (-1 == SLang_push_integer (s->sig)) || (-1 == SLang_end_arg_list ()) || (-1 == SLexecute_function (s->handler))) status = -1; if ((status == 0) && (depth != SLstack_depth ())) { SLang_verror (SL_Application_Error, "The signal handler %s corrupted the stack", s->handler->name); status = -1; } } if (was_blocked == 0) (void) unblock_signal (s->sig); return status; }
static int read_plot_cursor (Cursor_Config_Type *cc, float *x, float *y, char *ch) /*{{{*/ { if (pli_undefined()) return -1; if (PLI->read_cursor == NULL) { isis_vmesg (FAIL, I_FAILED, __FILE__, __LINE__, "plot: read_cursor operation is not supported"); return -1; } if (-1 == SLang_push_cstruct ((VOID_STAR)cc, Cursor_Config_Table)) return -1; if (-1 == SLexecute_function (PLI->read_cursor)) { isis_vmesg (FAIL, I_FAILED, __FILE__, __LINE__, "plot: read_cursor failed"); return -1; } if (SLstack_depth() < 3) { isis_vmesg (FAIL, I_ERROR, __FILE__, __LINE__, "plot: read_cursor failed"); return -1; } SLang_pop_char (ch); SLang_pop_float (y); SLang_pop_float (x); return 0; }
static int stack_depth_intrin (void) { return SLstack_depth (); }
static void finish_status(int col_flag) { char *v, ch; Line *l; int top, rows, narrows; char buf[256]; char *str; v = CBuf->status_line; if (*v == 0) v = Default_Status_Line; while (1) { char *v0 = v; while (1) { ch = *v; if (ch == 0) { SLsmg_write_nchars (v0, (unsigned int) (v-v0)); return; } if (ch == '%') { SLsmg_write_nchars (v0, (unsigned int) (v-v0)); break; } v++; } /* At this point *v == '%' */ v++; ch = *v++; switch (ch) { case 'F': SLsmg_write_string (CBuf->dir); str = CBuf->file; break; case 'S': /* stack depth */ sprintf(buf, "%03d", SLstack_depth()); str = buf; break; case 'a': if (CBuf->flags & ABBREV_MODE) str = " abbrev"; else str = NULL; break; case 'f': str = CBuf->file; break; case 'n': narrows = jed_count_narrows (); if (narrows) { sprintf (buf, " Narrow[%d]", narrows); str = buf; } else str = NULL; break; case 'o': if (CBuf->flags & OVERWRITE_MODE) str = " Ovwrt"; else str = NULL; break; case 'O': if (CBuf->flags & OVERWRITE_MODE) str = " ovr"; else str = " ins"; break; case 'b': str = CBuf->name; break; case 'p': str = buf; if (0 == User_Prefers_Line_Numbers) { top = JWindow->sy; rows = JWindow->rows - 1; l = JScreen[top + rows].line; if (l == CBuf->end) l = NULL; if (JScreen[top].line == CBuf->beg) { if (l == NULL) str = "All"; else str = "Top"; } else if (l == NULL) str = "Bot"; else { sprintf(buf, "%d%%", (int) ((LineNum * 100L) / (long) Max_LineNum)); } } else { if (User_Prefers_Line_Numbers == 1) sprintf(buf, "%u/%u", LineNum, Max_LineNum); else { if (col_flag) (void) calculate_column (); sprintf(buf, "%u/%u,%d", LineNum, Max_LineNum, Absolute_Column); } } break; case 'l': sprintf(buf, "%u", LineNum); str=buf; break; case 'L': sprintf(buf, "%u", Max_LineNum); str=buf; break; case 'v': SLsmg_write_string (Jed_Version_String); if (Jed_UTF8_Mode) str = "U"; else str = NULL; break; case 'm': str = CBuf->mode_string; break; case 't': str = status_get_time(); break; case 'c': if (col_flag) (void) calculate_column (); sprintf(buf, "%d", Absolute_Column); str = buf; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { char fmt[16]; int num = ch - '0'; while (isdigit(*v)) { num = num * 10 + (*v - '0'); v++; } if ((num < 0) || (-1 == SLsnprintf (fmt, sizeof(fmt), "%s%du", ((ch == '0') ? "%0" : "%"), num))) strcpy (fmt, "%u"); str = "*"; switch (*v++) { default: v--; break; case 'c': if (col_flag) (void) calculate_column (); if (-1 != SLsnprintf (buf, sizeof (buf), fmt, (unsigned int)Absolute_Column)) str = buf; break; case 'l': if (-1 != SLsnprintf (buf, sizeof (buf), fmt, LineNum)) str = buf; break; case 'L': if (-1 != SLsnprintf (buf, sizeof (buf), fmt, Max_LineNum)) str = buf; break; } } break; case '%': str = "%"; break; case 0: return; default: str = NULL; } if (str != NULL) SLsmg_write_string (str); } }