Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/usr.bin/config/scan.l,v rcsdiff: /ftp/cvs/cvsroot/src/usr.bin/config/scan.l,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.17 retrieving revision 1.17.10.1 diff -u -p -r1.17 -r1.17.10.1 --- src/usr.bin/config/scan.l 2012/03/20 20:34:57 1.17 +++ src/usr.bin/config/scan.l 2015/03/06 21:00:23 1.17.10.1 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: scan.l,v 1.17 2012/03/20 20:34:57 matt Exp $ */ +/* $NetBSD: scan.l,v 1.17.10.1 2015/03/06 21:00:23 snj Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,6 +41,9 @@ * from: @(#)scan.l 8.1 (Berkeley) 6/6/93 */ +#include +__RCSID("$NetBSD: scan.l,v 1.17.10.1 2015/03/06 21:00:23 snj Exp $"); + #include #include #include @@ -108,12 +111,12 @@ static int getcurifdef(void); %} -%option noyywrap +%option noyywrap nounput noinput PATH [A-Za-z_0-9]*[./][-A-Za-z_0-9./]* -QCHARS ([^"\n]|\\\")+ +QCHARS \"(\\.|[^\\"])*\" WORD [A-Za-z_][-A-Za-z_0-9]* -FILENAME ({PATH}|\"{QCHARS}\") +FILENAME ({PATH}|{QCHARS}) RESTOFLINE [ \t]*(#[^\n]*)?\n %x IGNORED @@ -164,6 +167,7 @@ prefix return PREFIX; pseudo-device return PSEUDO_DEVICE; pseudo-root return PSEUDO_ROOT; root return ROOT; +select return SELECT; single return SINGLE; source return SOURCE; type return TYPE; @@ -319,12 +323,11 @@ package[ \t]+{FILENAME}{RESTOFLINE} { return EMPTYSTRING; } -\"{QCHARS} { - tok = input(); /* eat closing quote */ - if (tok != '"') { - cfgerror("closing quote missing\n"); - unput(tok); - } +{QCHARS} { + size_t l = strlen(yytext); + if (l > 1 && yytext[l - 1] == '"') + yytext[l - 1] = '\0'; + yylval.str = intern(yytext + 1); return QSTRING; } @@ -335,7 +338,7 @@ package[ \t]+{FILENAME}{RESTOFLINE} { } 0[xX][0-9a-fA-F]+ { yylval.num.fmt = 16; - yylval.num.val = strtoull(yytext + 2, NULL, 16); + yylval.num.val = (long long)strtoull(yytext + 2, NULL, 16); return NUMBER; } [1-9][0-9]* { @@ -397,8 +400,7 @@ curdir_push(const char *fname) free(f); return (-1); } - p = emalloc(strlen(cwd) + strlen(d) + 2); - sprintf(p, "%s/%s", cwd, d); + easprintf(&p, "%s/%s", cwd, d); } free(f); pf = ecalloc(1, sizeof(*pf)); @@ -498,8 +500,7 @@ include(const char *fname, int ateof, in s = estrdup(fname); else if (fname[0] == '.' && fname[1] == '/') { struct prefix *pf = SLIST_FIRST(&curdirs); - s = emalloc(strlen(pf->pf_prefix) + strlen(fname)); - sprintf(s, "%s/%s", pf->pf_prefix, fname + 2); + easprintf(&s, "%s/%s", pf->pf_prefix, fname + 2); } else s = sourcepath(fname); if ((fp = fopen(s, "r")) == NULL) { @@ -530,6 +531,7 @@ include(const char *fname, int ateof, in if (interesting) logconfig_include(fp, fname); incl = in; + CFGDBG(1, "include `%s' from `%s' line %d", fname, yyfile, yyline); yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); yyfile = intern(s); yyline = 1; @@ -604,12 +606,12 @@ endinclude(void) * us to consume a newline, we have to subtract one. yychar is yacc's * token lookahead, so we can tell. */ -int +u_short currentline(void) { extern int yychar; - return (yyline - (yychar == '\n')); + return (u_short)(yyline - (yychar == '\n')); } static int