=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/lex.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- src/usr.bin/awk/lex.c 2020/06/10 21:01:32 1.13 +++ src/usr.bin/awk/lex.c 2020/06/10 21:02:33 1.14 @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.13 2020/06/10 21:01:32 millert Exp $ */ +/* $OpenBSD: lex.c,v 1.14 2020/06/10 21:02:33 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -147,7 +147,7 @@ if (bp-buf >= sz) if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, "gettok")) FATAL( "out of space for number %.10s...", buf ); - if (isdigit(c) || c == 'e' || c == 'E' + if (isdigit(c) || c == 'e' || c == 'E' || c == '.' || c == '+' || c == '-') *bp++ = c; else { @@ -181,10 +181,10 @@ int yylex(void) { int c; - static char *buf = 0; + static char *buf = NULL; static int bufsize = 5; /* BUG: setting this small causes core dump! */ - if (buf == 0 && (buf = (char *) malloc(bufsize)) == NULL) + if (buf == NULL && (buf = (char *) malloc(bufsize)) == NULL) FATAL( "out of space in yylex" ); if (sc) { sc = 0; @@ -205,7 +205,7 @@ /* should this also have STR set? */ RET(NUMBER); } - + yylval.i = c; switch (c) { case '\n': /* {EOL} */ @@ -236,7 +236,7 @@ case '&': if (peek() == '&') { input(); RET(AND); - } else + } else RET('&'); case '|': if (peek() == '|') { @@ -334,7 +334,7 @@ unputstr(buf); RET(INDIRECT); } - + case '}': if (--bracecnt < 0) SYNTAX( "extra }" ); @@ -357,10 +357,10 @@ case '(': parencnt++; RET('('); - + case '"': return string(); /* BUG: should be like tran.c ? */ - + default: RET(c); } @@ -371,10 +371,10 @@ { int c, n; char *s, *bp; - static char *buf = 0; + static char *buf = NULL; static int bufsz = 500; - if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL) + if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL) FATAL("out of space for strings"); for (bp = buf; (c = input()) != '"'; ) { if (!adjbuf(&buf, &bufsz, bp-buf+2, 500, &bp, "string")) @@ -393,7 +393,7 @@ c = input(); switch (c) { case '"': *bp++ = '"'; break; - case 'n': *bp++ = '\n'; break; + case 'n': *bp++ = '\n'; break; case 't': *bp++ = '\t'; break; case 'f': *bp++ = '\f'; break; case 'r': *bp++ = '\r'; break; @@ -430,7 +430,7 @@ break; } - default: + default: *bp++ = c; break; } @@ -440,7 +440,7 @@ break; } } - *bp = 0; + *bp = 0; s = tostring(buf); *bp++ = ' '; *bp++ = 0; yylval.cp = setsymtab(buf, s, 0.0, CON|STR|DONTFREE, symtab); @@ -466,15 +466,14 @@ return -1; } -int word(char *w) +int word(char *w) { Keyword *kp; int c, n; n = binsearch(w, keywords, sizeof(keywords)/sizeof(keywords[0])); -/* BUG: this ought to be inside the if; in theory could fault (daniel barrett) */ - kp = keywords + n; if (n != -1) { /* found in table */ + kp = keywords + n; yylval.i = kp->sub; switch (kp->type) { /* special handling */ case BLTIN: @@ -518,11 +517,11 @@ int regexpr(void) { int c, openclass = 0; - static char *buf = 0; + static char *buf = NULL; static int bufsz = 500; char *bp; - if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL) + if (buf == NULL && (buf = (char *) malloc(bufsz)) == NULL) FATAL("out of space for rex expr"); bp = buf; for ( ; ((c = input()) != '/' || openclass == 1) && c != 0; ) { @@ -530,11 +529,11 @@ FATAL("out of space for reg expr %.10s...", buf); if (c == '\n') { *bp = '\0'; - SYNTAX( "newline in regular expression %.10s...", buf ); + SYNTAX( "newline in regular expression %.10s...", buf ); unput('\n'); break; } else if (c == '\\') { - *bp++ = '\\'; + *bp++ = '\\'; *bp++ = input(); } else { if (c == '[') @@ -558,7 +557,7 @@ char *ep = ebuf; char yysbuf[100]; /* pushback buffer */ char *yysptr = yysbuf; -FILE *yyin = 0; +FILE *yyin = NULL; int input(void) /* get next lexical input character */ {