use the library globbing routines instead of rolling our own
[unix-history] / usr / src / bin / csh / lex.c
index 79faa5a..6973bc3 100644 (file)
@@ -1,15 +1,14 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
+ * All rights reserved.  The Berkeley Software License Agreement
  * specifies the terms and conditions for redistribution.
  */
 
 #ifndef lint
  * specifies the terms and conditions for redistribution.
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)lex.c      5.2 (Berkeley) %G%";
-#endif not lint
+static char *sccsid = "@(#)lex.c       5.7 (Berkeley) %G%";
+#endif
 
 #include "sh.h"
 
 #include "sh.h"
-#include "sh.char.h"
 #include <sgtty.h>
 
 /*
 #include <sgtty.h>
 
 /*
@@ -112,7 +111,7 @@ prlex(sp0)
                if (sp == sp0)
                        break;
                if (sp->word[0] != '\n')
                if (sp == sp0)
                        break;
                if (sp->word[0] != '\n')
-                       putchar(' ');
+                       cshputchar(' ');
        }
 }
 
        }
 }
 
@@ -427,8 +426,8 @@ addla(cp)
 {
        char buf[BUFSIZ];
 
 {
        char buf[BUFSIZ];
 
-       if (lap != 0 && strlen(cp) + strlen(lap) >= sizeof (labuf) - 4) {
-               seterr("Expansion buf ovflo");
+       if (strlen(cp) + (lap ? strlen(lap) : 0) >= sizeof (labuf) - 4) {
+               seterr("Expansion buffer overflow");
                return;
        }
        if (lap)
                return;
        }
        if (lap)
@@ -1010,6 +1009,15 @@ findev(cp, anyarg)
                register struct wordent *lp = hp->Hlex.next;
                int argno = 0;
 
                register struct wordent *lp = hp->Hlex.next;
                int argno = 0;
 
+               /*
+                * The entries added by alias substitution don't
+                * have a newline but do have a negative event number.
+                * Savehist() trims off these entries, but it happens
+                * before alias expansion, too early to delete those
+                * from the previous command.
+                */
+               if (hp->Hnum < 0)
+                       continue;
                if (lp->word[0] == '\n')
                        continue;
                if (!anyarg) {
                if (lp->word[0] == '\n')
                        continue;
                if (!anyarg) {
@@ -1302,12 +1310,14 @@ bseek(l)
 }
 
 /* any similarity to bell telephone is purely accidental */
 }
 
 /* any similarity to bell telephone is purely accidental */
+#ifndef btell
 off_t
 btell()
 {
 
        return (fseekp);
 }
 off_t
 btell()
 {
 
        return (fseekp);
 }
+#endif
 
 btoeof()
 {
 
 btoeof()
 {