Path: utzoo!attcan!uunet!wuarchive!emory!gatech!purdue!tippy!sawmill!buhrt From: buhrt@sawmill.uucp (Jeffery A Buhrt) Newsgroups: comp.sources.bugs Subject: Official Sc6.9 -> Sc6.10 patches (Please Apply) (2 of 2) Message-ID: <1990Oct26.222013.16940@sawmill.uucp> Date: 26 Oct 90 22:20:13 GMT Organization: Grauel Enterprises Lines: 3320 Apply these patches w/ 'patch' as well. -Jeff Buhrt *** 69/lex.c Thu Oct 4 09:17:47 1990 --- lex.c Fri Oct 26 16:57:55 1990 *************** *** 7,13 * * More mods Robert Bond, 12/86 * More mods by Alan Silverstein, 3/88, see list of changes. ! * $Revision: 6.9 $ * */ --- 7,13 ----- * * More mods Robert Bond, 12/86 * More mods by Alan Silverstein, 3/88, see list of changes. ! * $Revision: 6.10 $ * */ *************** *** 56,61 jmp_buf wakeup; jmp_buf fpe_buf; struct key { char *key; int val; --- 56,78 ----- jmp_buf wakeup; jmp_buf fpe_buf; + #ifdef SIGVOID + void + #endif + fpe_trap(signo) + int signo; + { + #ifdef i386 + asm(" fnclex"); + asm(" fwait"); + #else + #ifdef IEEE_MATH + (void)fpsetsticky((fp_except)0); /* Clear exception */ + #endif /* IEEE_MATH */ + #endif + longjmp(fpe_buf, 1); + } + struct key { char *key; int val; *************** *** 69,74 #include "statres.h" 0, 0}; yylex () { register char *p = line+linelim; --- 86,92 ----- #include "statres.h" 0, 0}; + int yylex () { register char *p = line+linelim; *************** *** 136,142 } } } else if ((*p == '.') || isdigit(*p)) { ! double v = 0; int temp; char *nstart = p; if (*p != '.') { --- 154,165 ----- } } } else if ((*p == '.') || isdigit(*p)) { ! #ifdef SIGVOID ! void (*sig_save)(); ! #else ! int (*sig_save)(); ! #endif ! double v = 0.0; int temp; char *nstart = p; *************** *** 139,144 double v = 0; int temp; char *nstart = p; if (*p != '.') { do v = v*10 + (double)(*p-'0'); while (isdigit(*++p)); --- 162,176 ----- double v = 0.0; int temp; char *nstart = p; + + sig_save = signal(SIGFPE, fpe_trap); + if (setjmp(fpe_buf)) { + (void) signal(SIGFPE, sig_save); + yylval.fval = v; + error("Floating point exception\n"); + return FNUMBER; + } + if (*p != '.') { do v = v*10.0 + (double) ((unsigned) *p - '0'); while (isdigit(*++p)); *************** *** 140,146 int temp; char *nstart = p; if (*p != '.') { ! do v = v*10 + (double)(*p-'0'); while (isdigit(*++p)); } if (*p=='.' || *p == 'e' || *p == 'E') { --- 172,178 ----- } if (*p != '.') { ! do v = v*10.0 + (double) ((unsigned) *p - '0'); while (isdigit(*++p)); } if (*p=='.' || *p == 'e' || *p == 'E') { *************** *** 163,168 } } } } else if (*p=='"') { char *ptr; ptr = p+1; --- 195,201 ----- } } } + (void) signal(SIGFPE, sig_save); } else if (*p=='"') { char *ptr; ptr = p+1; *************** *** 212,217 #ifdef SIMPLE initkbd() {} --- 245,251 ----- #ifdef SIMPLE + void initkbd() {} *************** *** 215,220 initkbd() {} kbd_again() {} --- 249,255 ----- initkbd() {} + void kbd_again() {} *************** *** 218,223 kbd_again() {} resetkbd() {} --- 253,259 ----- kbd_again() {} + void resetkbd() {} *************** *** 223,228 #ifndef VMS nmgetch() { return (toascii(getchar())); --- 259,265 ----- #ifndef VMS + int nmgetch() { return (toascii(getchar())); *************** *** 230,235 #else /* VMS */ nmgetch() /* This is not perfect, it doesn't move the cursor when goraw changes --- 267,273 ----- #else /* VMS */ + int nmgetch() /* This is not perfect, it doesn't move the cursor when goraw changes *************** *** 326,331 ctl('z'), 0 }; charout(c) int c; { --- 364,370 ----- ctl('z'), 0 }; + void charout(c) int c; { *************** *** 332,337 (void)putchar(c); } initkbd() { register struct key_map *kp; --- 371,377 ----- (void)putchar(c); } + void initkbd() { register struct key_map *kp; *************** *** 410,415 #endif } nmgetch() { register int c; --- 450,456 ----- #endif } + int nmgetch() { register int c; *************** *** 484,489 #if defined(SYSV2) || defined(SYSV3) initkbd() { keypad(stdscr, TRUE); --- 525,531 ----- #if defined(SYSV2) || defined(SYSV3) + void initkbd() { keypad(stdscr, TRUE); *************** *** 501,506 keypad(stdscr, FALSE); } nmgetch() { register int c; --- 543,549 ----- keypad(stdscr, FALSE); } + int nmgetch() { register int c; *************** *** 539,544 #ifdef SIGVOID void #endif time_out(signo) int signo; --- 582,589 ----- #ifdef SIGVOID void + #else + int #endif time_out(signo) int signo; *************** *** 543,552 time_out(signo) int signo; { ! #ifdef IEEE_MATH ! (void)fpsetsticky((fp_except)0); /* Clear exception */ ! #endif /* IEEE_MATH */ ! longjmp(wakeup, -1); } #ifdef SIGVOID --- 588,594 ----- time_out(signo) int signo; { ! longjmp(wakeup, 1); } /* *************** *** 549,563 longjmp(wakeup, -1); } - #ifdef SIGVOID - void - #endif - fpe_trap(signo) - int signo; - { - longjmp(fpe_buf, 1); - } - /* * This converts a floating point number of the form * [s]ddd[.d*][esd*] where s can be a + or - and e is E or e. --- 591,596 ----- longjmp(wakeup, 1); } /* * This converts a floating point number of the form * [s]ddd[.d*][esd*] where s can be a + or - and e is E or e. *************** *** 580,586 #else int (*sig_save)(); #endif - sig_save = signal(SIGFPE, fpe_trap); if (setjmp(fpe_buf)) { error("Floating point exception\n"); --- 613,618 ----- #else int (*sig_save)(); #endif sig_save = signal(SIGFPE, fpe_trap); if (setjmp(fpe_buf)) { error("Floating point exception\n"); *** 69/psc.c Thu Oct 4 09:12:50 1990 --- psc.c Fri Oct 26 17:01:02 1990 *************** *** 52,57 int *fwidth; int *precision; int maxcols; char token[1000]; --- 52,58 ----- int *fwidth; int *precision; int maxcols; + int *realfmt; char token[1000]; *** 69/range.c Thu Oct 4 09:13:22 1990 --- range.c Fri Oct 26 16:57:57 1990 *************** *** 4,10 * * Robert Bond, 4/87 * ! * $Revision: 6.8 $ */ #include --- 4,10 ----- * * Robert Bond, 4/87 * ! * $Revision: 6.10 $ */ #include *************** *** 22,27 static struct range *rng_base; add_range(name, left, right, is_range) char *name; struct ent_ptr left, right; --- 22,28 ----- static struct range *rng_base; + void add_range(name, left, right, is_range) char *name; struct ent_ptr left, right; *************** *** 86,91 rng_base = r; } del_range(left, right) struct ent *left, *right; { --- 87,93 ----- rng_base = r; } + void del_range(left, right) struct ent *left, *right; { *************** *** 113,118 xfree((char *)r); } clean_range() { register struct range *r; --- 115,121 ----- xfree((char *)r); } + void clean_range() { register struct range *r; *************** *** 160,165 return((struct range *)0); } sync_ranges() { register struct range *r; --- 163,169 ----- return((struct range *)0); } + void sync_ranges() { register struct range *r; *************** *** 172,177 } } write_range(f) FILE *f; { --- 176,182 ----- } } + void write_range(f) FILE *f; { *************** *** 257,262 } } are_ranges() { return (rng_base != 0); --- 262,268 ----- } } + int are_ranges() { return (rng_base != 0); *************** *** 259,263 are_ranges() { ! return (rng_base != 0); } --- 265,269 ----- int are_ranges() { ! return (rng_base != 0); } *** 69/sc.c Thu Oct 4 09:15:40 1990 --- sc.c Fri Oct 26 16:58:09 1990 *************** *** 7,14 * * More mods Robert Bond, 12/86 * More mods by Alan Silverstein, 3-4/88, see list of changes. ! * Currently supported by pur-phy!sawmill!buhrt (Jeff Buhrt) ! * $Revision: 6.9 $ * */ --- 7,14 ----- * * More mods Robert Bond, 12/86 * More mods by Alan Silverstein, 3-4/88, see list of changes. ! * Currently supported by sequent!sawmill!buhrt (Jeff Buhrt) ! * $Revision: 6.10 $ * */ *************** *** 34,39 void exit(); #endif #ifndef DFLT_PAGER #define DFLT_PAGER "more" /* more is probably more widespread than less */ #endif /* DFLT_PAGER */ --- 34,43 ----- void exit(); #endif + #ifndef SAVENAME + #define SAVENAME "SC.SAVE" /* file name to use for emergency saves */ + #endif /* SAVENAME */ + #ifndef DFLT_PAGER #define DFLT_PAGER "more" /* more is probably more widespread than less */ #endif /* DFLT_PAGER */ *************** *** 53,58 int maxrows, maxcols; int *fwidth; int *precision; char *col_hidden; char *row_hidden; char line[FBUFLEN]; --- 57,63 ----- int maxrows, maxcols; int *fwidth; int *precision; + int *realfmt; char *col_hidden; char *row_hidden; char line[FBUFLEN]; *************** *** 79,84 int calc_order = BYROWS; int tbl_style = 0; /* headers for T command output */ int rndinfinity = 0; int lastmx, lastmy; /* Screen address of the cursor */ int lastcol; /* Spreadsheet Column the cursor was in last */ --- 84,90 ----- int calc_order = BYROWS; int tbl_style = 0; /* headers for T command output */ int rndinfinity = 0; + int numeric_field = 0; /* Started the line editing with a number */ int lastmx, lastmy; /* Screen address of the cursor */ int lastcol; /* Spreadsheet Column the cursor was in last */ *************** *** 379,384 * Show expression; takes priority over other displays: */ if (showexpr && ((*pp) -> expr)) { linelim = 0; editexp(row, col); /* set line to expr */ --- 385,394 ----- * Show expression; takes priority over other displays: */ + if ((*pp)->cellerror) + printw("%*.*s", fwidth[col], fwidth[col], + (*pp)->cellerror == CELLERROR ? "ERROR" : "INVALID"); + else if (showexpr && ((*pp) -> expr)) { linelim = 0; editexp(row, col); /* set line to expr */ *************** *** 385,393 linelim = -1; showstring(line, /* leftflush = */ 1, /* hasvalue = */ 0, row, col, & nextcol, mxcol, & fieldlen, r, c); ! } ! else { ! /* * Show cell's numeric value: */ --- 395,401 ----- linelim = -1; showstring(line, /* leftflush = */ 1, /* hasvalue = */ 0, row, col, & nextcol, mxcol, & fieldlen, r, c); ! } else { /* * Show cell's numeric value: */ *************** *** 390,396 /* * Show cell's numeric value: ! */ if ((*pp) -> flags & is_valid) { char field[FBUFLEN]; --- 398,404 ----- } else { /* * Show cell's numeric value: ! */ if ((*pp) -> flags & is_valid) { char field[FBUFLEN]; *************** *** 394,399 if ((*pp) -> flags & is_valid) { char field[FBUFLEN]; if ((*pp) -> format) { (void)format((*pp) -> format, (*pp) -> v, field, sizeof(field)); --- 402,408 ----- if ((*pp) -> flags & is_valid) { char field[FBUFLEN]; + if ((*pp) -> format) { format((*pp) -> format, (*pp) -> v, field, sizeof(field)); *************** *** 395,402 if ((*pp) -> flags & is_valid) { char field[FBUFLEN]; if ((*pp) -> format) { ! (void)format((*pp) -> format, (*pp) -> v, field, ! sizeof(field)); } else { (void)sprintf(field,"%*.*f", fwidth[col], precision[col], (*pp)->v); --- 404,411 ----- char field[FBUFLEN]; if ((*pp) -> format) { ! format((*pp) -> format, (*pp) -> v, ! field, sizeof(field)); } else { engformat(realfmt[col], fwidth[col], precision[col], (*pp) -> v, *************** *** 398,405 (void)format((*pp) -> format, (*pp) -> v, field, sizeof(field)); } else { ! (void)sprintf(field,"%*.*f", fwidth[col], ! precision[col], (*pp)->v); } if(strlen(field) > fwidth[col]) { for(i = 0; i format, (*pp) -> v, field, sizeof(field)); } else { ! engformat(realfmt[col], fwidth[col], ! precision[col], (*pp) -> v, ! field, sizeof(field)); } if (strlen(field) > fwidth[col]) { for(i = 0; iv); } ! if(strlen(field) > fwidth[col]) { ! for(i = 0; i v, field, sizeof(field)); } ! if (strlen(field) > fwidth[col]) { ! for(i = 0; i len) line[linelim] = 0; } ! back_space() { if (linelim == 0) --- 476,483 ----- if (linelim > len) line[linelim] = 0; } ! ! static void back_space() { if (linelim == 0) *************** *** 440,445 } } get_motion() { int c; --- 493,499 ----- } } + int get_motion() { int c; *************** *** 456,461 } } delete_cmd() { int cpos; --- 510,516 ----- } } + static void delete_cmd() { int cpos; *************** *** 464,469 del_chars(cpos, linelim); } change_cmd() { delete_cmd(); --- 519,525 ----- del_chars(cpos, linelim); } + static void change_cmd() { delete_cmd(); *************** *** 470,475 insert_mode(); } del_chars(first, last) register int first, last; { --- 526,532 ----- insert_mode(); } + static void del_chars(first, last) register int first, last; { *************** *** 489,494 } } del_to_end() { if (linelim < 0) --- 546,552 ----- } } + static void del_to_end() { if (linelim < 0) *************** *** 497,502 linelim = back_line(); } cr_line() { showrange = 0; --- 555,561 ----- linelim = back_line(); } + static void cr_line() { showrange = 0; *************** *** 509,514 /* History functions */ save_hist() { register int i; --- 568,574 ----- /* History functions */ + static void save_hist() { if (lasthist < 0) *************** *** 511,522 save_hist() { ! register int i; ! ! /* free the oldest one */ ! if (history[HISTLEN-1]) { ! xfree(history[HISTLEN-1]); ! history[HISTLEN-1] = 0; } /* Move the others back */ --- 571,578 ----- static void save_hist() { ! if (lasthist < 0) ! { lasthist = 0; } else lasthist = (lasthist + 1) % HISTLEN; *************** *** 518,523 xfree(history[HISTLEN-1]); history[HISTLEN-1] = 0; } /* Move the others back */ for (i = HISTLEN-1; i > 0; --i) --- 574,581 ----- if (lasthist < 0) { lasthist = 0; } + else + lasthist = (lasthist + 1) % HISTLEN; if (lasthist > endhist) endhist = lasthist; *************** *** 519,527 history[HISTLEN-1] = 0; } ! /* Move the others back */ ! for (i = HISTLEN-1; i > 0; --i) ! history[i] = history[i-1]; history[0] = xmalloc((unsigned) strlen(line)+1); strcpy(history[0], line); --- 577,584 ----- else lasthist = (lasthist + 1) % HISTLEN; ! if (lasthist > endhist) ! endhist = lasthist; if (history[lasthist].len < strlen(line)+1) { if (history[lasthist].len) *************** *** 523,530 for (i = HISTLEN-1; i > 0; --i) history[i] = history[i-1]; ! history[0] = xmalloc((unsigned) strlen(line)+1); ! strcpy(history[0], line); } back_hist() --- 580,592 ----- if (lasthist > endhist) endhist = lasthist; ! if (history[lasthist].len < strlen(line)+1) ! { if (history[lasthist].len) ! (void)xfree(history[lasthist].histline); ! history[lasthist].len = strlen(line)+1; ! history[lasthist].histline = xmalloc(history[lasthist].len); ! } ! strcpy(history[lasthist].histline, line); } static void *************** *** 527,532 strcpy(history[0], line); } back_hist() { if (histp == -1 || histp < HISTLEN-1 && history[histp + 1]) --- 589,595 ----- strcpy(history[lasthist].histline, line); } + static void back_hist() { if (histp == -1) *************** *** 529,536 back_hist() { ! if (histp == -1 || histp < HISTLEN-1 && history[histp + 1]) ! histp++; if (history[histp]) { strcpy(line, history[histp]); --- 592,607 ----- static void back_hist() { ! if (histp == -1) ! histp = lasthist; ! else ! if (histp == 0) ! { if (endhist != lasthist) ! histp = endhist; ! } ! else ! if (histp != ((lasthist + 1) % (endhist + 1))) ! histp--; if (lasthist < 0) line[linelim = 0] = 0; *************** *** 532,541 if (histp == -1 || histp < HISTLEN-1 && history[histp + 1]) histp++; ! if (history[histp]) { ! strcpy(line, history[histp]); ! linelim = 0; ! } else line[linelim = 0] = 0; } --- 603,609 ----- if (histp != ((lasthist + 1) % (endhist + 1))) histp--; ! if (lasthist < 0) line[linelim = 0] = 0; else { strcpy(line, history[histp].histline); *************** *** 537,543 linelim = 0; } else line[linelim = 0] = 0; ! } search_hist() --- 605,614 ----- if (lasthist < 0) line[linelim = 0] = 0; ! else { ! strcpy(line, history[histp].histline); ! linelim = 0; ! } } static void *************** *** 540,545 } search_hist() { if (last_search) { --- 611,617 ----- } } + static void search_hist() { if (last_search) { *************** *** 553,559 return; } ! last_search = strcpy(xmalloc((unsigned)(strlen(line+1)+1)), line+1); search_again(); mode = EDIT_MODE; } --- 625,631 ----- return; } ! last_search = strcpy(xmalloc((unsigned)(strlen(line+1))), line+1); search_again(); mode = EDIT_MODE; } *************** *** 558,563 mode = EDIT_MODE; } search_again() { int found_it; --- 630,636 ----- mode = EDIT_MODE; } + static void search_again() { int found_it; *************** *** 589,594 } while (!found_it); } for_hist() { if (histp > 0) --- 662,668 ----- } while (!found_it); } + static void for_hist() { if (histp == -1) *************** *** 591,598 for_hist() { ! if (histp > 0) ! histp--; if (histp >= 0 && history[histp]) { strcpy(line, history[histp]); --- 665,675 ----- static void for_hist() { ! if (histp == -1) ! histp = lasthist; ! else ! if (histp != lasthist) ! histp = (histp + 1) % (endhist + 1); if (lasthist < 0) line[linelim = 0] = 0; *************** *** 594,603 if (histp > 0) histp--; ! if (histp >= 0 && history[histp]) { ! strcpy(line, history[histp]); ! linelim = 0; ! } else line[linelim = 0] = 0; } --- 671,677 ----- if (histp != lasthist) histp = (histp + 1) % (endhist + 1); ! if (lasthist < 0) line[linelim = 0] = 0; else { strcpy(line, history[histp].histline); *************** *** 599,604 linelim = 0; } else line[linelim = 0] = 0; } col_0() --- 673,682 ----- if (lasthist < 0) line[linelim = 0] = 0; + else { + strcpy(line, history[histp].histline); + linelim = 0; + } } static void *************** *** 601,606 line[linelim = 0] = 0; } col_0() { linelim = 0; --- 679,685 ----- } } + static void col_0() { linelim = 0; *************** *** 606,611 linelim = 0; } last_col() { linelim = strlen(line); --- 685,691 ----- linelim = 0; } + static void last_col() { linelim = strlen(line); *************** *** 613,618 --linelim; } find_char() { register int c; --- 693,699 ----- --linelim; } + static int find_char() { register int c; *************** *** 628,633 return(i); } to_char() { register int i; --- 709,715 ----- return(i); } + static int to_char() { register int i; *** 69/vmtbl.c Thu Oct 4 09:17:32 1990 --- vmtbl.c Fri Oct 26 16:58:30 1990 *************** *** 15,24 extern char *malloc(); extern char *realloc(); - #if defined(BSD42) || defined(BSD43) - #define memcpy(dest, source, len) bcopy(source, dest, (unsigned int)len); - #define memset(dest, zero, len) bzero((dest), (unsigned int)(len)); - #endif /* * check to see if *rowp && *colp are currently allocated, if not expand the --- 15,20 ----- extern char *malloc(); extern char *realloc(); /* * check to see if *rowp && *colp are currently allocated, if not expand the *************** *** 84,89 struct ent ***tbl2; int *fwidth2; int *precision2; char *col_hidden2; char *row_hidden2; int newrows, newcols; --- 80,86 ----- struct ent ***tbl2; int *fwidth2; int *precision2; + int *realfmt2; char *col_hidden2; char *row_hidden2; int newrows, newcols; *************** *** 151,156 { GROWALLOC(fwidth2, fwidth, newcols, int, nowider); GROWALLOC(precision2, precision, newcols, int, nowider); #ifdef PSC memset(fwidth+maxcols, 0, (newcols-maxcols)*sizeof(int)); memset(precision+maxcols, 0, (newcols-maxcols)*sizeof(int)); --- 148,154 ----- { GROWALLOC(fwidth2, fwidth, newcols, int, nowider); GROWALLOC(precision2, precision, newcols, int, nowider); + GROWALLOC(realfmt2, realfmt, newcols, int, nowider); #ifdef PSC memset(fwidth+maxcols, 0, (newcols-maxcols)*sizeof(int)); memset(precision+maxcols, 0, (newcols-maxcols)*sizeof(int)); *************** *** 154,159 #ifdef PSC memset(fwidth+maxcols, 0, (newcols-maxcols)*sizeof(int)); memset(precision+maxcols, 0, (newcols-maxcols)*sizeof(int)); } #else GROWALLOC(col_hidden2, col_hidden, newcols, char, nowider); --- 152,158 ----- #ifdef PSC memset(fwidth+maxcols, 0, (newcols-maxcols)*sizeof(int)); memset(precision+maxcols, 0, (newcols-maxcols)*sizeof(int)); + memset(realfmt+maxcols, 0, (newcols-maxcols)*sizeof(int)); } #else GROWALLOC(col_hidden2, col_hidden, newcols, char, nowider); *************** *** 161,166 for (i = maxcols; i < newcols; i++) { fwidth[i] = DEFWIDTH; precision[i] = DEFPREC; } /* [re]alloc the space for each row */ --- 160,166 ----- for (i = maxcols; i < newcols; i++) { fwidth[i] = DEFWIDTH; precision[i] = DEFPREC; + realfmt[i]= DEFREFMT; } /* [re]alloc the space for each row */ *** 69/xmalloc.c Thu Oct 4 09:17:35 1990 --- xmalloc.c Fri Oct 26 16:58:32 1990 *************** *** 1,6 /* * A safer saner malloc, for careless programmers ! * $Revision: 6.8 $ */ #include --- 1,6 ----- /* * A safer saner malloc, for careless programmers ! * $Revision: 6.10 $ */ #include *************** *** 26,31 return(ptr + sizeof(double)); } xfree(p) char *p; { --- 26,32 ----- return(ptr + sizeof(double)); } + void xfree(p) char *p; { *************** *** 37,42 free(p); } fatal(str) char *str; { --- 38,44 ----- free(p); } + void fatal(str) char *str; { *************** *** 42,46 { deraw(); (void) fprintf(stderr,"%s\n", str); exit(1); } --- 44,49 ----- { deraw(); (void) fprintf(stderr,"%s\n", str); + diesave(); exit(1); }