Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site topaz.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!columbia!topaz!gallaher From: gallaher@topaz.ARPA (Mike Gallaher) Newsgroups: net.emacs Subject: Unipress Emacs Bug Fixes (3 of 3) Message-ID: <2143@topaz.ARPA> Date: Thu, 30-May-85 08:22:22 EDT Article-I.D.: topaz.2143 Posted: Thu May 30 08:22:22 1985 Date-Received: Fri, 31-May-85 06:14:05 EDT Organization: Rutgers Univ., New Brunswick, N.J. Lines: 673 # This is a shar archive. Extract with sh. echo Extracting process-2 cat > process-2 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00 ident: process-2 date: 1-Apr-85 posted-to: fixed-by: Jamie Watson source-files: subproc.[ch] Synopsis: subproc.c won't compile on 8-character-unique preprocessors Description: There are some preprocessors that want the defines to be unique in eight (8) characters. The define WAITCHILD had a conflict with WAITCHILDNH. Fix: The fix is to change WAITCHILD to WAITCHLD in the files subproc.c and subproc.h. __Egregious Trees!!!__ echo Extracting quit-1 cat > quit-1 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00 ident: quit-1 date: posted-to: fixed-by: jamie watson source-files: emacs.c Synopsis: Description: A newline was generated even when Emacs did not print an exiting message. This is sometimes annoying, this fix is to not print the newline unless a message is really being printed. Repeat-by: Fix: Change the code segment in the function quit from: if (message) printf(message); to: if (! STRNULL(message)) printf("%s\n", message); __Egregious Trees!!!__ echo Extracting quit-2 cat > quit-2 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00 ident: quit-2 date: 1-Apr-85 posted-to: fixed-by: unipress!dm (David Medinets @ Unipress Software) source-files: emacs.c Synopsis: bad command line switch causes core dump Description: Since all exits from Emacs are done by calling quit, the display may not have been initialized when quit is called. This happens, for instance, when a bad switch is given on the command line; the bad switch is detected and quit is called before InitWin is called. Repeat-by: Invoke Emacs with a bad command line switch, for example emacs -@ Emacs will core dump. Fix: The fix is to check to see if the display subsystem has been initialized before trying to call DoDsp. In quit, the call to DoDsp is done only if DisplayInitialized is TRUE. The test is done in quit rather than in DoDsp to save time in DoDsp. In the function quit, in the file emacs.c, change the following line: DoDsp(); to look like this: if (DisplayInitialized) DoDsp(); __Egregious Trees!!!__ echo Extracting subproc-1 cat > subproc-1 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: 2.00, 2.01 ident: subproc-1 date: 20-May-85 posted-to: fixed-by: unipress!mg (Mike Gallaher @ Unipress Software) source-files: compat.c subproc.c Synopsis: FilterThrough, ExecBf use variable number of arguments Description: The functions FilterThrough and ExecBf in subproc.c accept a variable number of arguments, which does not work on all machines. In particular, this does not work on the HP9000 series 500 because the stack grows in the direction opposite to that of other machines, so that argument lists built on the stack cannot be passed to functions like execvp that want an array of char pointers. Fix: The solution is to make all functions that call FilterThrough and ExecBf set up the arguments in an array of char pointers, and to call ExecBfp and FilterThroughp with a pointer to that array. The functions FilterThrough and ExecBf can be eliminated. Change the code according to the following patches, as if FIXED was defined non-zero. ----------- Begin patches to subproc.c ----------------------------------- In the function FilterRegion: if (s = getstr(FALSE,": filter-region (through command) ")) { #if FIXED char saveit[MAXSHCOMLEN+1]; char *commands[MAXCOMWORDS]; char **cp = commands; (void) strncpy(saveit, s, MAXSHCOMLEN); *cp++ = shell(); *cp++ = "-c"; *cp++ = saveit; *cp = NULL; FilterThroughp(ToMark(bf_cur->b_mark) - dot, commands); } #else FilterThrough(ToMark(bf_cur->b_mark) - dot, shell(), "-c", saveit, 0); #endif ------------------- In the function ExecuteMonitorCommand: if ((com = getstr(FALSE,"Unix command: ")) != NULL) #if FIXED { char *command[4]; char **cp = command; *cp++ = shell(); *cp++ = "-c"; *cp++ = com; *cp = NULL; ExecBfp("Command execution", 1, "/dev/null", 1, command); } #else ExecBf("Command execution", 1, "/dev/null", 1, shell(), "-c", com, 0); #endif -------------------- Remove the definitions of the functions ExecBf and FilterThrough. -------------- End patches to subproc.c ------------------------------ ************* -------------- Begin patches to compat.c ----------------------------- In the function IndentCProcedure: if (nest == 0) { #if FIXED char *command[6]; char **cp = command; SetDot(ScanBf('\n', spos, -1)); *cp++ = "indent"; *cp++ = "-st"; *cp = NULL; FilterThroughp(pos - dot, command); #else SetDot(ScanBf('\n', spos, -1)); FilterThrough(pos - dot, "indent", "-st", 0); #endif } ------------ In the function CompileIt: static char CompileCommand[MAXSHCOMLEN+1]; #if FIXED char *command[4]; char **cp = command; if (ModWrite()) { /* * this test really shouldn't be done this way, all the prefix * numeric argument stuff needs to be rationalized */ if (ArgState == HaveArg || !interactive) { if ((com = getstr(FALSE,"Compilation command: ")) == NULL) return(NULL); if (*com) (void) strcpy(CompileCommand, com); *cp++ = shell(); *cp++ = "-c"; *cp++ = CompileCommand; } else { *cp++ = "make"; *cp++ = "-k"; } *cp = NULL; ExecBfp("Error log", 1, "/dev/null", 1, command); #else if (ModWrite()) { /* * this test really shouldn't be done this way, all the prefix * numeric argument stuff needs to be rationalized */ if (ArgState==HaveArg || !interactive) { if ((com = getstr(FALSE,"Compilation command: ")) == NULL) return(NULL); if (*com) (void) strcpy(CompileCommand, com); ExecBf("Error log", 1, "/dev/null", 1,shell(),"-c", CompileCommand, 0); } else ExecBf("Error log",1,"/dev/null", 1, "make", "-k", 0); #endif -------------- End patches to compat.c ----------------------------- __Egregious Trees!!!__ echo Extracting syntax-1 cat > syntax-1 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00, V2.01 ident: syntax-1 date: 15-May-85 posted-to: fixed-by: source-files: syntax.c Synopsis: dot-in-comment returns inverse of what it should Description: The dot-in-comment function is undocumented, but here is a fix for it anyway. It returned the inverse of the value it should. It is also possible to greatly simplify its logic. Repeat-by: Use dot-in-comment in some buffer that has had its comment characters set in its syntax table. A quick way to do this is to run elec-c-mode. Fix: In the file syntax.c, in the function DotInComment, change the code as follows, as if FIXED were defined as 1: #if FIXED MLvalue->exp_int = (p > q); #else if (q == FAIL && p == FAIL) MLvalue->exp_int = FALSE; else if (p < q) MLvalue->exp_int = TRUE; else MLvalue->exp_int = FALSE; #endif Also, there is a redundant line MLvalue->exp_type = IsInteger; There is one before a comment block, one after. Remove the one before the comment block. __Egregious Trees!!!__ echo Extracting ttylock-1 cat > ttylock-1 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00 ident: ttylock-1 date: 1-Apr-85 posted-to: fixed-by: unipress!dm (David Medinets @ Unipress Software) source-files: ttylock.c Synopsis: ttylock.c won't compile properly if ONEEMACSPERTTY TRUE Description: When ONEEMACSPERTTY was set to TRUE, ttylock.c would not compile. Some compilers also complain because fgets is cast to (char *). Repeat-by: Connect to the Emacs source directory and type make ttylock.o Fix: To make ttylock.c compile with ONEEMACSPERTTY set to TRUE: 1) Add the line: extern char MyTtyName[]; to the beginning of the C function LockTty. 2) Change the declaration of LockTty from hidden to visible. 3) Include the file at the begining of the file. To remove the cast of fgets: 1) change the line of code that reads c = (char *) fgets(buf, sizeof(buf), stdin); to c = fgets(buf, sizeof(buf), stdin); 2) change the variable declaration at the beginning of that same block to: char buf[10], *c, *fgets(); 3) as long as you are in this file, you may as well change the if statment to read as follows: if (STRNULL(c) || (*c != 'y' && *c != 'Y')) quit(FAIL, NULL); --------------- End of patches to ttylock.c ------------------------------ __Egregious Trees!!!__ echo Extracting unlink-1 cat > unlink-1 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: 2.00 ident: unlink-1 date: 14-Mar-85 Posted-to: unix-emacs net.emacs fixed-by: unipress!mg (Mike Gallaher @ Unipress Software) source-files: filecmd.c Description: unlink-file did not always work properly because it incorrectly used the value returned by GetTtyFile, which is actually a pointer to a static string. The string was getting overwritten by the call to yes. Fix: Replace the existing UnlinkFile with the one given below. ------ Begin patch to filecmd.c ---------------------------------------- /* UnlinkFile() * * Deletes a file using help facility and file completion. * There are five cases: * 1> no file-name given -> raises error. * 2> file not found interactively -> raises error. * 3> file deleted interactively -> prints message. * 4> file not found called by MLisp proc -> returns FAIL. * 5> file deleted called by MLisp proc -> returns SUCCEED. */ hidden int UnlinkFile() { char *fn; char scratch[MAXDSPLINELEN + 1]; char filename[PATHLEN + 1]; int flag = TRUE; if ((fn = GetFileName(": unlink-file ")) != NULL && ! Emacs_Err) { (void) strcpy(filename, fn); if (interactive) { (void) sprintf(scratch, "Delete \"%s\"? ", filename); flag = yes(TRUE, scratch); } if (! Emacs_Err && flag) { /* If we should go ahead and rm it */ if (unlink(filename) == FAIL) if (interactive) { /* it didn't work */ (void) sprintf(Err_buf, Err[Err_nofile], filename); error(Err_see_errbuf); } else { /* it did work */ MLvalue->exp_type = IsInteger; MLvalue->exp_int = FAIL; } else if (interactive) message(FALSE, Msg_filedeleted); else MLvalue->exp_type = IsInteger; MLvalue->exp_int = SUCCEED; } } else error(Err_emptyfilename); return(NULL); } ------ End patch to filecmd.c ---------------------------------------- __Egregious Trees!!!__ echo Extracting varfix-1 cat > varfix-1 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00, V2.01 ident: varfix-1 posted-to: net.emacs date: 15-Mar-85 fixed-by: unipress!mg (Mike Gallaher @ Unipress Software) source-files: mlarith.c mlargs.c mlvars.h Synopsis: ++, --, +=, -=, etc. don't work with system variables Description: The ++, --, and assignment/operation operator MLisp functions (+=, -=, etc.) do not work properly when given system variables as arguments. Fix: There are three files that need to be patched: mlvars.h, mlarith.c, and mlargs.c. mlvars.h -------- 1) Change extern Expression *GetArg1(); to extern BINDING *GetArg1(); 2) Add the following code to mlvars.h, just after the definition of struct Binding. This defines macros for referencing, reading, and setting MLisp variables, taking into account whether they are system or MLisp-defined. -------------------- start of patch to mlvars.h -------------------- /* Macros for referencing variable values. */ #define IntVarVal(b) (b)->b_exp->exp_int #define StrVarPtr(b) (b)->b_exp->exp_v.v_string #define StrVarLen(b) (b)->b_exp->exp_int #define SysIntVarVal(b) *(int *)((b)->b_exp->exp_v.v_string) #define SysStrVarPtr(b) (b)->b_exp->exp_v.v_string #define SysStrVarLen(b) strlen(SysStrVarPtr(b)) /* Macros for reading and setting variable values */ #define GetIntVarVal(b) ((b)->IsSystem ? SysIntVarVal(b) \ : IntVarVal(b)) #define SetIntVarVal(b,n) if ((b)->IsSystem) \ SysIntVarVal(b) = (n);\ else \ IntVarVal(b) = (n) -------------------- end of patch to mlvars.h -------------------- mlargs.c -------- Change GetArg1 to return the binding of the first argument rather than the expression within that binding by doing the following: 1) Change the declared type of the function GetArg from Expression * to BINDING *. 2) Change the return(e) in GetArg1 [there is only one such return in this function] to return(b). mlarith.c --------- Change plusplus, minusminus, and AsgOp to use the new variable value macros, and to reflect the change of the type of GetArg1 from Expression to BINDING. The simplest way to do this is to replace their definitions entirely with the code below. Following this code in the source file should be the calls to AsgOp. -------- begin patch to mlarith.c ------------------------------ /* * This implements the `++' prefix operator in C. It requires its * arg to be a varname. It returns the incremented value. (friedl at kentvax) */ hidden int plusplus() { register BINDING *b; register int n; if ((b = GetArg1()) != NULL) { n = GetIntVarVal(b); MLvalue->exp_int = ++n; SetIntVarVal(b, n); } return(NULL); } /* * minusminus() * * This implements the -- prefix operator in C. It requires its * arg to be a varname. It returns the decremented value. (friedl at kentvax) */ hidden int minusminus() { register BINDING *b; register int n; if ((b = GetArg1()) != NULL) { n = GetIntVarVal(b); MLvalue->exp_int = --n; SetIntVarVal(b, n); } return(NULL); } /* * AsgOp(OPNAME, OP) * * This macro implements the assignment operator - just * like those in C. They are of the form * * (OP var e1 e2 ...) * * where all the expressions are optional. All of them * return integer values (friedl at Kentvax). */ #define AsgOp(OPNAME, OP) \ hidden int \ OPNAME()\ {\ register BINDING *b;\ if ((b = GetArg1()) != NULL)\ {\ register int n = GetIntVarVal(b);\ while (!Emacs_Err && EI.ArgN < EI.ArgMax)\ n OP NumericArg(EI.Nis);\ MLvalue->exp_int = n;\ SetIntVarVal(b, n);\ }\ return(NULL);\ } -------- end patch to mlarith.c ------------------------------ __Egregious Trees!!!__ echo Extracting variables-3 cat > variables-3 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00 ident: variables-3 date: 1-Apr-85 posted-to: fixed-by: david medinets (unipress!dm) source-files: mlvars.c Synopsis: setting GlobalModeString causes core dump Repeat-by: ESC-X set global-mode-string skreltch Fix: (The constant MAXDSPLINELEN shown below may have been changed to MAXGMODESTRLEN in your version of Emacs. If so, leave it alone and substitute it in the text below.) display.c or window.c (depending on version number): the declaration of GlobalModeString should look like this: char GlobalModeString[MAXDSPLINELEN + 1]; mlvars.c: The declaration for GlobalModeString must be a char array with an explicit length, because at least one compiler (Sun Unix 1.2) generates incorrect code for any other form of declaration. The declaration should look like this: extern char GlobalModeString[MAXDSPLINELEN + 1]; Change the line that initializes it to GlobalModeString[0] = '\0'; __Egregious Trees!!!__ echo Extracting xonflow-1 cat > xonflow-1 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00, V2.01 Ident: xonflow-1 Date: 7-May-85 fixed-by: unipress!mg (Mike Gallaher @ Unipress Software) posted-to: source-files: emacs.c Synopsis: not easy to start Emacs in xon/xoff flow control mode Description: There is no easy way to force Emacs to come up with the terminal in xon/xoff flow control mode. Fix: Add a -x command line option that turns on xon/xoff flow control. In the file emacs.c, look for the string "case 'h':". This should be in the command line switch processing code. Just after the code for the -h switch (i.e., after the break statement), add the following lines: case 'x': { extern int XonFlow, HalfBaked; char *s = getmainarg(targc, targv); HalfBaked = XonFlow = (*s == '0' ? FALSE : TRUE); } break; ---- Then add the following lines to the comment above that lists the command line switches. * -x[<1|0>] Turns XonFlow and Halbaked on or off. * Omitting the number turns them on. ------ End of patches to emacs.c ----------------------------------------- __Egregious Trees!!!__ echo Extracting xonflow-2 cat > xonflow-2 << "__Egregious Trees!!!__" Unipress Emacs Bug Fix Emacs version: V2.00, V2.01 ident: xonflow-2 date: 29-May-85 posted-to: fixed-by: tjalk!sjoerd source-files: mlcompile.c Synopsis: setting xon/xoff-flow-control in startup files has no effect Description: In ExecuteMLispFile the routine DoDsp is called for the L state indicator. The problem is that when the Globalpro-file is executed the display is initialized before any initialization file gets the chance of setting the xon/xoff-flow-control variable. I have changed this, so that when the display in not yet initialized the routine DoDsp won't be called. Repeat-by: Try to set xon/xoff-flow-control to 1 in a startup file. It will always be set to 0, no matter what you try to set it to. Fix: In the funciton mlcompile.c$ExecuteMLispFile, look for the following code: ExecutedDefun = NULL; if (! STRNULL(fn) && ! Emacs_Err) { #if 1 GlobalState = STATE_LOADING; /* {8} */ Cant1LineOpt = TRUE; DoDsp(FALSE); #endif 1 code = NULL; Change the code within the #if 1 to the following extern int DisplayInitialized; GlobalState = STATE_LOADING; /* {8} */ if (DisplayInitialized) { Cant1LineOpt = TRUE; DoDsp(FALSE); } --------------- End of patch to mlcompile.c ------------------------------ __Egregious Trees!!!__