]> granicus.if.org Git - sudo/commitdiff
kill_aliases -> reset_aliases
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 27 Mar 1995 19:53:37 +0000 (19:53 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 27 Mar 1995 19:53:37 +0000 (19:53 +0000)
yywrap() now cleans up by calling reset_aliases() and clearing top
took reset stuff out of yyerror() since it doesn't beling there
(and doesn't work anyway).
errorlineno is now initially set to -1 so we can set it to the
first error that occurrs (it was getting set to the last)

parse.yacc

index 2bbeced4698830d9d983528bb6b5f70f66037943..1e349b42e82297fa5a2e82cd7cc34c545938d3e1 100644 (file)
@@ -59,7 +59,7 @@ static char rcsid[] = "$Id$";
 #include "options.h"
 
 extern int sudolineno, parse_error;
-int errorlineno = 0;
+int errorlineno = -1;
 
 /*
  * Alias types
@@ -94,25 +94,28 @@ extern int ntwk_matches             __P((char *));
 static int find_alias          __P((char *, int));
 static int add_alias           __P((char *, int));
 static int more_aliases                __P((int));
-static void kill_aliases       __P((void));
+static void reset_aliases      __P((void));
 
 yyerror(s)
 char *s;
 {
-    errorlineno = sudolineno;
+    /* save the line the first error occured on */
+    if (errorlineno == -1)
+       errorlineno = sudolineno;
 #ifndef TRACELEXER
-    fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s, errorlineno);
+    fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s, sudolineno);
 #else
     fprintf(stderr, "<*> ");
 #endif
     parse_error = TRUE;
-    /* reset data structures so we can reparse cleanly */
-    kill_aliases();
-    top = 0;
 }
 
 yywrap()
 {
+    /* reset values so we can reparse cleanly */
+    reset_aliases();
+    top = 0;
+
     return(1);
 }
 %}
@@ -358,8 +361,8 @@ dumpaliases()
 
 }
 
-void
-kill_aliases()
+static void
+reset_aliases()
 {
     (void) free(aliases);
     naliases = nslots = 0;