This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 3.0 patch #4 Patch #2 continued
[perl5.git] / toke.c
diff --git a/toke.c b/toke.c
index 6b58074..1d9474e 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1,4 +1,4 @@
-/* $Header: toke.c,v 3.0 89/10/18 15:32:33 lwall Locked $
+/* $Header: toke.c,v 3.0.1.2 89/11/11 05:04:42 lwall Locked $
  *
  *    Copyright (c) 1989, Larry Wall
  *
@@ -6,6 +6,12 @@
  *    as specified in the README file that comes with the perl 3.0 kit.
  *
  * $Log:       toke.c,v $
+ * Revision 3.0.1.2  89/11/11  05:04:42  lwall
+ * patch2: fixed a CLINE macro conflict
+ * 
+ * Revision 3.0.1.1  89/10/26  23:26:21  lwall
+ * patch1: disambiguated word after "sort" better
+ * 
  * Revision 3.0  89/10/18  15:32:33  lwall
  * 3.0 baseline
  * 
@@ -17,6 +23,9 @@
 
 char *reparse;         /* if non-null, scanreg found ${foo[$bar]} */
 
+#ifdef CLINE
+#undef CLINE
+#endif
 #define CLINE (cmdline = (line < cmdline ? line : cmdline))
 
 #define META(c) ((c) | 128)
@@ -83,7 +92,7 @@ yylex()
 
   retry:
 #ifdef YYDEBUG
-    if (yydebug)
+    if (debug & 1)
        if (index(s,'\n'))
            fprintf(stderr,"Tokener at %s",s);
        else
@@ -156,7 +165,13 @@ yylex()
        }
 #endif
        bufend = linestr->str_ptr + linestr->str_cur;
-       firstline = FALSE;
+       if (firstline) {
+           while (s < bufend && isspace(*s))
+               s++;
+           if (*s == ':')      /* for csh's that have to exec sh scripts */
+               s++;
+           firstline = FALSE;
+       }
        goto retry;
     case ' ': case '\t': case '\f':
        s++;
@@ -865,7 +880,15 @@ yylex()
                    fatal("sort is now a reserved word");
                if (isascii(*s) && (isalpha(*s) || *s == '_')) {
                    for (d = s; isalpha(*d) || isdigit(*d) || *d == '_'; d++) ;
-                   if (d >= bufend || isspace(*d))
+                   strncpy(tokenbuf,s,d-s);
+                   if (strNE(tokenbuf,"keys") &&
+                       strNE(tokenbuf,"values") &&
+                       strNE(tokenbuf,"split") &&
+                       strNE(tokenbuf,"grep") &&
+                       strNE(tokenbuf,"readdir") &&
+                       strNE(tokenbuf,"unpack") &&
+                       strNE(tokenbuf,"do") &&
+                       (d >= bufend || isspace(*d)) )
                        *(--s) = '\\';  /* force next ident to WORD */
                }
                LOP(O_SORT);
@@ -2083,10 +2106,8 @@ load_format()
 
 set_csh()
 {
-    if (!csh) {
-       if (stat("/bin/csh",&statbuf) < 0)
-           csh = -1;
-       else
-           csh = 1;
-    }
+#ifdef CSH
+    if (!cshlen)
+       cshlen = strlen(cshname);
+#endif
 }