[BACK]Return to parse.y CVS log [TXT][DIR] Up to [local] / src / usr.bin / doas

Diff for /src/usr.bin/doas/parse.y between version 1.29 and 1.30

version 1.29, 2021/01/27 17:02:50 version 1.30, 2021/11/30 20:08:15
Line 18 
Line 18 
 %{  %{
 #include <sys/types.h>  #include <sys/types.h>
 #include <ctype.h>  #include <ctype.h>
   #include <limits.h>
 #include <unistd.h>  #include <unistd.h>
 #include <stdint.h>  #include <stdint.h>
 #include <stdarg.h>  #include <stdarg.h>
Line 39 
Line 40 
                 const char **strlist;                  const char **strlist;
                 const char *str;                  const char *str;
         };          };
         int lineno;          unsigned long lineno;
         int colno;          unsigned long colno;
 } yystype;  } yystype;
 #define YYSTYPE yystype  #define YYSTYPE yystype
   
Line 50 
Line 51 
 size_t nrules;  size_t nrules;
 static size_t maxrules;  static size_t maxrules;
   
 int parse_errors = 0;  int parse_error = 0;
   
 static void yyerror(const char *, ...);  static void yyerror(const char *, ...);
 static int yylex(void);  static int yylex(void);
Line 198 
Line 199 
         va_start(va, fmt);          va_start(va, fmt);
         vfprintf(stderr, fmt, va);          vfprintf(stderr, fmt, va);
         va_end(va);          va_end(va);
         fprintf(stderr, " at line %d\n", yylval.lineno + 1);          fprintf(stderr, " at line %lu\n", yylval.lineno + 1);
         parse_errors++;          parse_error = 1;
 }  }
   
 static struct keyword {  static struct keyword {
Line 222 
Line 223 
 yylex(void)  yylex(void)
 {  {
         char buf[1024], *ebuf, *p, *str;          char buf[1024], *ebuf, *p, *str;
         int c, quotes = 0, escape = 0, qpos = -1, nonkw = 0;          int c, quoted = 0, quotes = 0, qerr = 0, escape = 0, nonkw = 0;
           unsigned long qpos = 0;
         size_t i;          size_t i;
   
         p = buf;          p = buf;
Line 258 
Line 260 
         for (;; c = getc(yyfp), yylval.colno++) {          for (;; c = getc(yyfp), yylval.colno++) {
                 switch (c) {                  switch (c) {
                 case '\0':                  case '\0':
                         yyerror("unallowed character NUL in column %d",                          yyerror("unallowed character NUL in column %lu",
                             yylval.colno + 1);                              yylval.colno + 1);
                         escape = 0;                          escape = 0;
                         continue;                          continue;
Line 268 
Line 270 
                                 continue;                                  continue;
                         break;                          break;
                 case '\n':                  case '\n':
                         if (quotes)                          if (quotes && !qerr) {
                                 yyerror("unterminated quotes in column %d",                                  yyerror("unterminated quotes in column %lu",
                                     qpos + 1);                                      qpos + 1);
                                   qerr = 1;
                           }
                         if (escape) {                          if (escape) {
                                 nonkw = 1;                                  nonkw = 1;
                                 escape = 0;                                  escape = 0;
                                 yylval.colno = 0;                                  yylval.colno = ULONG_MAX;
                                 yylval.lineno++;                                  yylval.lineno++;
                                 continue;                                  continue;
                         }                          }
                         goto eow;                          goto eow;
                 case EOF:                  case EOF:
                         if (escape)                          if (escape)
                                 yyerror("unterminated escape in column %d",                                  yyerror("unterminated escape in column %lu",
                                     yylval.colno);                                      yylval.colno);
                         if (quotes)                          if (quotes && !qerr)
                                 yyerror("unterminated quotes in column %d",                                  yyerror("unterminated quotes in column %lu",
                                     qpos + 1);                                      qpos + 1);
                         goto eow;                          goto eow;
                         /* FALLTHROUGH */  
                 case '{':                  case '{':
                 case '}':                  case '}':
                 case '#':                  case '#':
Line 298 
Line 301 
                         break;                          break;
                 case '"':                  case '"':
                         if (!escape) {                          if (!escape) {
                                   quoted = 1;
                                 quotes = !quotes;                                  quotes = !quotes;
                                 if (quotes) {                                  if (quotes) {
                                         nonkw = 1;                                          nonkw = 1;
                                           qerr = 0;
                                         qpos = yylval.colno;                                          qpos = yylval.colno;
                                 }                                  }
                                 continue;                                  continue;
Line 326 
Line 331 
                  */                   */
                 if (c == EOF)                  if (c == EOF)
                         goto eof;                          goto eof;
                 else if (qpos == -1)    /* accept, e.g., empty args: cmd foo args "" */                  else if (!quoted)    /* accept, e.g., empty args: cmd foo args "" */
                         goto repeat;                          goto repeat;
         }          }
         if (!nonkw) {          if (!nonkw) {

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30