martillo@mit-athena.ARPA (Joaquim Martillo) (11/27/84)
A while ago we received some changes to speed up emacs and then some changes to take care of problems .cshrc produced output. From: decvax!cca!z (Steve Zimmerman) Message-Id: <8410141354.AA04653@cca-unix.ARPA> To: emacs-maintainers Subject: EMACS Bug Fix #86: File I/O Cc: barnes Symptom: If a user's .cshrc file normally produces output to the terminal when it is sourced, then EMACS will not properly recognize file names that it is given by the user. Versions: 162.45z and versions containing the startup speed enhancement. Fix: *** e_io.h~1 Thu Sep 6 15:30:05 1984 --- e_io.h Fri Oct 12 11:54:37 1984 *************** *** 68,74 char *inahead, *outahead; /* Typeahead pointers */ char aheadbuf[AHEADSIZ]; /* Typeahead buffer */ ! char cbreak, piperr, shblock, shellput, shellstop; char METAKEY; /* Set if terminal has meta key */ short mschar; int alarmc, forceup; --- 68,74 ----- char *inahead, *outahead; /* Typeahead pointers */ char aheadbuf[AHEADSIZ]; /* Typeahead buffer */ ! char cbreak, piperr, shblock, shellput, shellstop, srclook; char METAKEY; /* Set if terminal has meta key */ short mschar; int alarmc, forceup; *** e_io.c~1 Thu Sep 6 15:30:31 1984 --- e_io.c Fri Oct 12 12:12:07 1984 *************** *** 808,822 register c; register char *cs; ! cs = s; ! while (--n>0 && (c = getc(iop))>=0) { ! *cs++ = c; ! if (c=='\n') ! break; ! } ! if (c<0 && cs==s) ! return(NULL); ! *cs++ = '\0'; return(s); } --- 808,827 ----- register c; register char *cs; ! *s = '\0'; ! do { ! if (sindex(s, ".cshrc sourced")) ! srclook = 0; ! cs = s; ! while (--n>0 && (c = getc(iop))>=0) { ! *cs++ = c; ! if (c=='\n') ! break; ! } ! if (c<0 && cs==s) ! return(NULL); ! *cs++ = '\0'; ! } while (srclook); return(s); } *** e_main.c~1 Wed Sep 12 19:19:30 1984 --- e_main.c Fri Oct 12 11:55:15 1984 *************** *** 456,462 register char *pc, *pc2; char buf[SBUFSIZ]; char *kfname, *sort; ! char *sourcestr = "if (-r ~/.cshrc) source ~/.cshrc; unset prompt; unalias *\n"; #if vms #endif --- 456,462 ----- register char *pc, *pc2; char buf[SBUFSIZ]; char *kfname, *sort; ! char *sourcestr = "if (-r ~/.cshrc) source ~/.cshrc; unset prompt; unalias *;echo .cshrc sourced\n"; #if vms #endif *************** *** 467,472 numarg = 0; ! if (streqc(myname, DIRED) || streqc(myname, INFO)) fputs(sourcestr, cshin); if (streqc(myname, DIRED)) { xcnum = binsrch("DIRED", (char *)comtab, NCOMS, sizeof(struct key)); #if vms --- 467,474 ----- numarg = 0; ! if (streqc(myname, DIRED) || streqc(myname, INFO)) { fputs(sourcestr, cshin); + srclook = 1; + } if (streqc(myname, DIRED)) { xcnum = binsrch("DIRED", (char *)comtab, NCOMS, sizeof(struct key)); #if vms *************** *** 489,494 else inifiles(argc, argv); fputs(sourcestr, cshin); while (1) { edit(1); gquit(); /* quit if done */ --- 491,497 ----- else inifiles(argc, argv); fputs(sourcestr, cshin); + srclook = 1; while (1) { edit(1); gquit(); /* quit if done */ **************************************************************** Once these changes are incorporated ? does not print the full help message until after ?I has been typed. Likewise ?A leads to an inglorious death for emacs unless ?I is first entered. The reason is that the above changes made efgets look for ".cshrc sourced" when a file is being read in. There is an assumption that the file being read has been `globbed' for * or ? or escape completion which would have meant sourcing .cshrc. Unfortunately, help() in e_help.c invokes putfile(helpdoc, 0) where helpdoc is a pointer to the help documentation file in /usr/lib/emacs without globbing the file name. putfile invokes fgets (macro for efgets) which gets confused and never prints out the full help message (only "You are at top level" appears). The situation is still ^G recoverable, however if A is typed, there is an attempt to do more processing (via fgets) once again on top of an already confused situation and emacs gets hung. The fix is trivial just invoke putfile(helpdoc, 0) in help() as putfile(glob(helpdoc), 0). helpdoc will be globbed and efgets will be happy and apropos and help work properly once more. This bug may occur in other places (which I have not discovered). Just glob the filename and the problem will go away. Unfortunately type-ahead (hitting A before "You are at top level appears" still leads to a hung emacs. Possibly helpdoc should be globbed immediately upon entering help(). I will try this and post the results in the future.
z@masscomp.UUCP (Steve Zimmerman) (11/29/84)
> A while ago we received some changes to speed up emacs and then some > changes to take care of problems .cshrc produced output. > > Once these changes are incorporated ? does not print the full help > message until after ?I has been typed. Likewise ?A leads to an > inglorious death for emacs unless ?I is first entered. > > The reason is that the above changes made efgets look for > ".cshrc sourced" when a file is being read in. There is an assumption > that the file being read has been `globbed' for * or ? or escape > completion which would have meant sourcing .cshrc. The real problem is that efgets() is looking for ".cshrc sourced" from all streams, not just the C shell pipe. This problem was noted early on and a fix was sent out; you apparently didn't get it. The fix is to replace the "do" loop in efgets() with the following: do { if (iop == cshout && sindex(s, ".cshrc sourced")) srclook = 0; cs = s; while (--n>0 && (c = getc(iop))>=0) { *cs++ = c; if (c=='\n') break; } if (c<0 && cs==s) return(NULL); *cs++ = '\0'; } while (srclook && iop == cshout); Steve Zimmerman