cudcv@warwick.ac.uk (Rob McMahon) (08/07/90)
I've just been looking at pac, the calculator. It seems a fairly nice piece of work (shame it doesn't work on Sun3s...anyone know a fix for this ?). There are however a few buglets/wierdos. It tries to write to constant strings in a few places---instant core dump with ANSI compilers. In the Newconv menu, if you just hit return it dumps core trying to write to a NULL pointer. Delete works really strangely, these patches make it work like the normal Unix delete, and every editor I've ever used (except XEDIT, but I'm not planning on making *anything* look like XEDIT :-). There was no way to suspend pac, which is really invaluable in a tool like this. I've put this on ^Z for systems that have SIGTSTP. The ASCII printout of control characters was really wierd, I've never seen ^| ^/ or ^` anywhere before, I've changed it to print out the normal ^[ ^\ ^] ^_ ^^ as Unix does. All I miss now is a way to abort things I entered by accident (Newconv, File, etc.), an `apropos' function, and a way to scroll the help and conversion windows ... another day maybe. Have fun, Rob =================================================================== RCS file: defs.h,v retrieving revision 1.1 diff -c -r1.1 defs.h *** /tmp/,RCSt1a02499 Mon Aug 6 18:12:43 1990 --- defs.h Mon Aug 6 12:21:59 1990 *************** *** 165,171 **** }; char *Titlq[TREQ]; char *Basq[BREQ]; ! char *Bb[] = { "TAB bye <CTRL> Exit Redraw File Postpend Klock Globals Loan Newconv Total ", "<CTRL> File Postpend Toggle_back copy: a...t up_down: A...S transfer: T ", "file write: hardcopy ", --- 165,171 ---- }; char *Titlq[TREQ]; char *Basq[BREQ]; ! char Bb[][TITSIZ + 1] = { "TAB bye <CTRL> Exit Redraw File Postpend Klock Globals Loan Newconv Total ", "<CTRL> File Postpend Toggle_back copy: a...t up_down: A...S transfer: T ", "file write: hardcopy ", *************** *** 176,187 **** "new value = ", "new formula: " }; ! char *Hardname = ! "hardcopy "; ! char *Totname = ! "hardtotal "; ! char *Amortname = ! "hardamort "; char Spreadbuf[PIPEMAX * 2]; /* expand user input for tokenizing */ char Tokbuf[PIPEMAX]; /* strcomp against key list */ --- 176,184 ---- "new value = ", "new formula: " }; ! char Hardname[64] = "hardcopy"; ! char Totname[64] = "hardtotal"; ! char Amortname[64] = "hardamort"; char Spreadbuf[PIPEMAX * 2]; /* expand user input for tokenizing */ char Tokbuf[PIPEMAX]; /* strcomp against key list */ *************** *** 306,312 **** extern char *Titlq[]; extern char *Basq[]; extern char *Cb[], *Sb[]; ! extern char *Bb[]; extern char Spreadbuf[]; extern char Tokbuf[]; extern char Controlbuf[]; --- 303,309 ---- extern char *Titlq[]; extern char *Basq[]; extern char *Cb[], *Sb[]; ! extern char Bb[][TITSIZ + 1]; extern char Spreadbuf[]; extern char Tokbuf[]; extern char Controlbuf[]; *************** *** 335,343 **** extern int Rcfd, Rcerr; extern char Onebuf[STACKMAX + 1]; extern int Hardcopy, Hc, Hf; ! extern char *Hardname; ! extern char *Amortname; ! extern char *Totname; extern int Totcopy, Tc, Tqlev; extern int Autoconv; extern int Convcount; --- 332,340 ---- extern int Rcfd, Rcerr; extern char Onebuf[STACKMAX + 1]; extern int Hardcopy, Hc, Hf; ! extern char Hardname[]; ! extern char Amortname[]; ! extern char Totname[]; extern int Totcopy, Tc, Tqlev; extern int Autoconv; extern int Convcount; =================================================================== RCS file: ledit.c,v retrieving revision 1.1 diff -c -r1.1 ledit.c *** /tmp/,RCSt1a02499 Mon Aug 6 18:12:44 1990 --- ledit.c Mon Aug 6 18:08:53 1990 *************** *** 163,178 **** /* curr line: delete char and move 1 pos to left */ case 11: for (ri = CX + 1; ri <= rbound; ri++) addch(stdscr->_y[CY][ri]); addch(' '); - if (--CX < lbound) - ++CX; move(CY,CX); break; /* across lines: delete char and move 1 pos to left */ case 16: for (ri = CX + 1; ri <= rbound; ri++) addch(stdscr->_y[CY][ri]); for (rj = CY + 1; rj <= bbound; rj++) { --- 163,187 ---- /* curr line: delete char and move 1 pos to left */ case 11: + if (--CX < lbound) + ++CX; + move(CY,CX); for (ri = CX + 1; ri <= rbound; ri++) addch(stdscr->_y[CY][ri]); addch(' '); move(CY,CX); break; /* across lines: delete char and move 1 pos to left */ case 16: + if (--CX < lbound) { + if (--CY < tbound) { + ++CX; ++CY; + } else { + CX = rbound; + } + } + move(CY,CX); for (ri = CX + 1; ri <= rbound; ri++) addch(stdscr->_y[CY][ri]); for (rj = CY + 1; rj <= bbound; rj++) { *************** *** 182,189 **** addch(stdscr->_y[rj][ri]); } addch(' '); - if (--CX < lbound) - ++CX; move(CY,CX); break; --- 191,196 ---- *************** *** 198,206 **** --- 205,226 ---- case 20 : insert = 0; break; + + case 26 : + #ifdef SIGTSTP + kill(0, SIGTSTP); + clearok(curscr, TRUE); + #endif + break; } standend(); pfresh(); + } + + if (retbuf == ZERO) { + pfresh(); + TR_ + return(retval); } rp = retbuf; =================================================================== RCS file: maps.h,v retrieving revision 1.1 diff -c -r1.1 maps.h *** /tmp/,RCSt1a02499 Mon Aug 6 18:12:44 1990 --- maps.h Mon Aug 6 17:25:14 1990 *************** *** 10,16 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 9, 10, 0, 1, 0, 0, 11, 7, 0, 0, 8, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 10,16 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 9, 10, 0, 1, 0, 0, 11, 7, 0, 0, 8, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ *************** *** 29,35 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 29,35 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ *************** *** 48,54 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 48,54 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ *************** *** 69,75 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 0, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 69,75 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 0, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ *************** *** 91,97 **** "DLE ^P", "DC1 ^Q", "DC2 ^R", "DC3 ^S", "DC4 ^T", "NAK ^U", "SYN ^V", "ETB ^W", "CAN ^X", "EM ^Y", "SUB ^Z", "ESC ^[", ! "FS ^|", "GS ^]", "RS ^`", "US ^/", "asc SP" }; --- 91,97 ---- "DLE ^P", "DC1 ^Q", "DC2 ^R", "DC3 ^S", "DC4 ^T", "NAK ^U", "SYN ^V", "ETB ^W", "CAN ^X", "EM ^Y", "SUB ^Z", "ESC ^[", ! "FS ^\\", "GS ^]", "RS ^^", "US ^_", "asc SP" }; *************** *** 102,108 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 2, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 102,108 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 20, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 2, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ *************** *** 121,127 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 2, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 121,127 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 20, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 2, 0, 0, 0, 0, 2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ *************** *** 140,146 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 0, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 140,146 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 0, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ *************** *** 161,167 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 161,167 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 10, 0, 1, 0, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 20, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 2, 2, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ *************** *** 183,191 **** 0, 17, 17, 10, 17, 1, 17, 17, 11, 7, 17, 17, 17, 17, 17, 17, #ifdef DESIGN /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 17, 0, 18, 0, 17, 17, 0, 0, 17, 17, 0, 20, 0, 0, 0, 0, #else ! 17, 0, 18, 17, 17, 0, 0, 0, 17, 0, 0, 20, 0, 0, 0, 0, #endif /* SP ! " # $ % & ' ( ) * + , - . / */ 2, 2, 0, 2, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, --- 183,191 ---- 0, 17, 17, 10, 17, 1, 17, 17, 11, 7, 17, 17, 17, 17, 17, 17, #ifdef DESIGN /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 17, 0, 18, 0, 17, 17, 0, 0, 17, 17, 26, 20, 0, 0, 0, 0, #else ! 17, 0, 18, 17, 17, 0, 0, 0, 17, 0, 26, 20, 0, 0, 0, 0, #endif /* SP ! " # $ % & ' ( ) * + , - . / */ 2, 2, 0, 2, 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, *************** *** 207,213 **** /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 12, 0, 1, 12, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 12, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 21, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 0, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ --- 207,213 ---- /* NL ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O */ 0, 0, 0, 12, 0, 1, 12, 0, 11, 7, 0, 0, 0, 0, 0, 0, /* ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^| ^] ^` ^/ */ ! 12, 0, 0, 0, 8, 0, 0, 0, 0, 0, 26, 20, 0, 0, 0, 0, /* SP ! " # $ % & ' ( ) * + , - . / */ 10, 0, 0, 21, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 0, /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England
guy@auspex.auspex.com (Guy Harris) (08/08/90)
>I've just been looking at pac, the calculator. It seems a fairly nice piece >of work (shame it doesn't work on Sun3s...anyone know a fix for this ?). The introductory section of the posting correctly notes that the problem has nothing whatsoever to do with Sun-3s; the problem is that it doesn't work under SunOS 3.x. The "Relnotes" file reflects the author's old incorrect belief that the problem was with Sun-3s, not with 3.x (the only Sun-3's on which he'd tried it were running 3.x; I got it to run on a Sun-3 running 4.0.3 with no problem), and should be updated to reflect the fact that the problem is with 3.x's "curses" library, not with the Sun-3. >There are however a few buglets/wierdos. > >It tries to write to constant strings in a few places---instant core dump with >ANSI compilers. Nope. Instant core dump with those compilers - ANSI or non-ANSI - that put constant strings into read-only portions of the address space. ANSI does *NOT* mandate that this happen, it only *permits* it. GCC, for instance, has, as I remember, a flag "-fwritable-strings" or somesuch that tells it not to put constant strings into read-only portions of the address space.
paul@uxc.cso.uiuc.edu (Paul Pomes - UofIllinois CSO) (08/08/90)
pac should not conflict with other utilities of the same name. It should be renamed to something like pdc. /pbp -- Paul Pomes UUCP: {att,iuvax,uunet}!uiucuxc!paul Internet, BITNET: paul@uxc.cso.uiuc.edu US Mail: UofIllinois, CSO, 1304 W Springfield Ave, Urbana, IL 61801-2987
cudcv@warwick.ac.uk (Rob McMahon) (08/08/90)
In article <3839@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: >>I've just been looking at pac, the calculator. It seems a fairly nice piece >>of work (shame it doesn't work on Sun3s...anyone know a fix for this ?). > >The introductory section of the posting correctly notes that the problem >has nothing whatsoever to do with Sun-3s; the problem is that it doesn't >work under SunOS 3.x. Ugh, "if in doubt, read the instructions ...". I'm confused then, because it certainly breaks on our Sun3/SunOS 4.0.3 systems, whereas it works on our Sun4/SunOS 4.0.3 and Sun4/SunOS 4.1 systems (with both gcc and cc). The symptoms are that if you type an expression (like `42 \r'), then turn on the clock with ^K, the cursor is left in the wrong place, and a ^R completely scrambles the screen (it looks like the program's idea of the screen origin gets out of sync with reality). Anyone got any ideas ? >>It tries to write to constant strings in a few places---instant core dump >>with ANSI compilers. > >Nope. Instant core dump with those compilers - ANSI or non-ANSI - that >put constant strings into read-only portions of the address space. Yes, okay, I admit it, I was exaggerating and knew it. I just think it's a bad idea to write into string constants when it's invariably as easy to use initialised arrays, and it does blow up with some compilers with some options. Cheers, Rob -- UUCP: ...!mcsun!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick INET: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England
guy@auspex.auspex.com (Guy Harris) (08/11/90)
>Ugh, "if in doubt, read the instructions ...". I'm confused then, because it >certainly breaks on our Sun3/SunOS 4.0.3 systems, whereas it works on our >Sun4/SunOS 4.0.3 and Sun4/SunOS 4.1 systems (with both gcc and cc). Well, "seems to work, or at least didn't obviously blow up", or maybe "lucked into working", is the more correct phrase, rather than "works". There's a buffer in "pac" that's one byte (at least) too small, so some poor innocent variable gets stomped. In the Sun-3 case, it happened, by a bad stroke of luck, to be "_pfast", which is a variable internal to "curses"; this caused it to get quite confused. It was something else in the Sun-4 binary; smashing that may have been harmless, or may not have. It might be something else yet again on another system.... The moral of the story: "array bounds checking can be your friend". We had Saber-C here at one point, but I don't know if we still have it; running this puppy under Saber might well have found this bug. (The other moral of the story: "Remember, an N-character string in C takes up N+1 bytes....") >>Nope. Instant core dump with those compilers - ANSI or non-ANSI - that >>put constant strings into read-only portions of the address space. > >Yes, okay, I admit it, I was exaggerating and knew it. I just think it's a >bad idea to write into string constants when it's invariably as easy to use >initialised arrays, and it does blow up with some compilers with some options. I think it's a bad idea too, but if somebody's in a hurry to get something working, some ANSI compilers that normally put strings in read-only memory can be coaxed into not doing so.... In any case, here's the fix: *** defs.h.dist Fri Aug 10 10:17:47 1990 --- defs.h Fri Aug 10 18:19:17 1990 *************** *** 193,199 **** char Rebuf[PIPEMAX]; /* work buffers */ char Tmpbuf[PIPEMAX]; char Mop[PIPEMAX]; ! char Uwin_copy[(UBOT - UTOP + 1) * (URIGHT - ULEFT + 1)]; int Context = INIT; /* initial status values */ int Justify = JUS_DFLT; --- 193,199 ---- char Rebuf[PIPEMAX]; /* work buffers */ char Tmpbuf[PIPEMAX]; char Mop[PIPEMAX]; ! char Uwin_copy[(UBOT - UTOP + 1) * (URIGHT - ULEFT + 1) + 1]; int Context = INIT; /* initial status values */ int Justify = JUS_DFLT;