]> granicus.if.org Git - sudo/commitdiff
made more efficient by pulling out the terminators when in
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 19 Aug 1995 21:53:38 +0000 (21:53 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 19 Aug 1995 21:53:38 +0000 (21:53 +0000)
GOTCMND state and making them their own rule

parse.lex

index 711b02555d6789da529fb958e5057d82636ab650..8220b57b40e4340d7643165425896e9da3abb134 100644 (file)
--- a/parse.lex
+++ b/parse.lex
@@ -49,7 +49,6 @@ int sudolineno = 1;
 
 static void fill               __P((void));
 static void append             __P((void));
-static char chop               __P((void));
 extern void reset_aliases      __P((void));
 
 #ifdef TRACELEXER
@@ -75,6 +74,12 @@ N                    [0-9][0-9]?[0-9]?
                          LEXTRACE("\n\t");
                        }                       /* throw away EOL after \ */
 
+<GOTCMND>[:,=\n]       {
+                         BEGIN 0;
+                         unput(yytext[0]);
+                         return(PATH);
+                       }                       /* end of command line args */
+
 \n                     { 
                          ++sudolineno; 
                          LEXTRACE("\n");
@@ -87,18 +92,10 @@ N                   [0-9][0-9]?[0-9]?
                          return COMMENT;
                        }                       /* return comments */
 
-<GOTCMND>[^\,:=\\ \t\n#]+[:,=\n]       {
-                                 BEGIN 0;
-                                 LEXTRACE("ARG");
-                                 append();
-                                 unput(chop());
-                                 return(PATH);
-                               } /* the last command line arg */
-
-<GOTCMND>[^\,:=\\ \t\n#]+      {
-                         LEXTRACE("ARG ");
-                         append();
-                       } /* a command line arg */
+<GOTCMND>[^\,:=\\ \t\n#]+ {
+                           LEXTRACE("ARG ");
+                           append();
+                         }                     /* a command line arg */
 
 \,                     {
                          LEXTRACE(", ");
@@ -129,13 +126,6 @@ N                  [0-9][0-9]?[0-9]?
                          return NTWKADDR;
                        }
 
-\/[^\,:=\\ \t\n#]+[:,=\n]      {
-                         LEXTRACE("PATH ");
-                         fill();
-                         unput(chop());
-                         return(PATH);
-                       }                       /* a pathname with no args */
-
 \/[^\,:=\\ \t\n#]+     {
                          BEGIN GOTCMND;
                          LEXTRACE("PATH ");
@@ -191,17 +181,6 @@ static void append() {
     (void) strcat(yylval.string, yytext);
 }
 
-static char chop() {
-    int len;
-    char c;
-
-    len = strlen(yylval.string);
-    c = yylval.string[--len];
-    yylval.string[len] = '\0';
-    
-    return(c);
-}
-
 int yywrap()
 {
 #ifdef YY_NEW_FILE