X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/blobdiff_plain/7c6322c43138af50384f4055afc79736b0ec25bf..917beb172f5c4ee492fa7b47ce8c161066b977e8:/usr.bin/colldef/scan.l diff --git a/usr.bin/colldef/scan.l b/usr.bin/colldef/scan.l index 51926afb9d..7dc7d66d65 100644 --- a/usr.bin/colldef/scan.l +++ b/usr.bin/colldef/scan.l @@ -26,36 +26,34 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/usr.bin/colldef/scan.l,v 1.11.2.2 2002/10/11 10:43:45 ache Exp $ + * $FreeBSD: head/usr.bin/colldef/scan.l 175038 2008-01-01 10:04:10Z imp $ */ + #include #include #include +#include #include #include -#include #include "common.h" #include "y.tab.h" -#pragma GCC diagnostic ignored "-Wsign-compare" - int line_no = 1, save_no, fromsubs; -static u_char buffer[BUFSIZE], *buf_ptr; +u_char buff[BUFSIZE], *zptr; FILE *map_fp; YY_BUFFER_STATE main_buf, map_buf; #ifdef FLEX_DEBUG YYSTYPE yylval; #endif /* FLEX_DEBUG */ - %} %option noinput %option nounput %% [ \t]+ ; -\" { buf_ptr = buffer; BEGIN(string); } -\< { buf_ptr = buffer; fromsubs = 1; BEGIN(name); } -\< { buf_ptr = buffer; fromsubs = 0; BEGIN(name); } +\" { zptr = buff; BEGIN(string); } +\< { zptr = buff; fromsubs = 1; BEGIN(name); } +\< { zptr = buff; fromsubs = 0; BEGIN(name); } ^#.*\n line_no++; ^\n line_no++; \\\n line_no++; @@ -74,7 +72,7 @@ YYSTYPE yylval; \n { line_no++; if (map_fp != NULL) { - buf_ptr = buffer; + zptr = buff; BEGIN(defn); } return '\n'; @@ -103,45 +101,45 @@ YYSTYPE yylval; . { yylval.ch = *yytext; return CHAR; } ^#.*\n line_no++; [ \t]+ { - if (buf_ptr == buffer) + if (zptr == buff) errx(EX_UNAVAILABLE, "map expected near line %u of %s", line_no, map_name); - *buf_ptr = '\0'; - strcpy(yylval.str, buffer); + *zptr = '\0'; + strcpy(yylval.str, buff); BEGIN(nchar); return DEFN; } \/\/ { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "name buffer overflow near line %u, character '/'", line_no); - *buf_ptr++ = '/'; + *zptr++ = '/'; } \/\> { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "name buffer overflow near line %u, character '>'", line_no); - *buf_ptr++ = '>'; + *zptr++ = '>'; } \\\" { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\"'", line_no); - *buf_ptr++ = '"'; + *zptr++ = '"'; } \> { u_int i; - if (buf_ptr == buffer) + if (zptr == buff) errx(EX_UNAVAILABLE, "non-empty name expected near line %u", line_no); - *buf_ptr = '\0'; + *zptr = '\0'; for (i = 0; i <= UCHAR_MAX; i++) { - if (strcmp(charmap_table[i], buffer) == 0) + if (strcmp(charmap_table[i], buff) == 0) goto findit; } errx(EX_UNAVAILABLE, "name <%s> not 'charmap'-defined near line %u", - buffer, line_no); + buff, line_no); findit: yylval.ch = i; if (fromsubs) @@ -151,8 +149,8 @@ YYSTYPE yylval; return CHAR; } \" { - *buf_ptr = '\0'; - strcpy(yylval.str, buffer); + *zptr = '\0'; + strcpy(yylval.str, buff); BEGIN(subs2); return STRING; } @@ -162,52 +160,52 @@ YYSTYPE yylval; if (!isascii(*yytext) || !isprint(*yytext)) errx(EX_UNAVAILABLE, "non-ASCII or non-printable character 0x%02x not allowed in the map/name near line %u of %s", *yytext, line_no, s); - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "map/name buffer overflow near line %u of %s, character '%c'", line_no, s, *yytext); - *buf_ptr++ = *yytext; + *zptr++ = *yytext; } \\t { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\t'", line_no); - *buf_ptr++ = '\t'; + *zptr++ = '\t'; } \\b { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\b'", line_no); - *buf_ptr++ = '\b'; + *zptr++ = '\b'; } \\f { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\f'", line_no); - *buf_ptr++ = '\f'; + *zptr++ = '\f'; } \\v { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\v'", line_no); - *buf_ptr++ = '\v'; + *zptr++ = '\v'; } \\n { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\n'", line_no); - *buf_ptr++ = '\n'; + *zptr++ = '\n'; } \\r { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\r'", line_no); - *buf_ptr++ = '\r'; + *zptr++ = '\r'; } \\a { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\a'", line_no); - *buf_ptr++ = '\a'; + *zptr++ = '\a'; } \n { const char *s = (map_fp != NULL) ? map_name : "input"; @@ -223,25 +221,25 @@ YYSTYPE yylval; u_int v; sscanf(&yytext[2], "%x", &v); - *buf_ptr++ = (u_char)v; + *zptr++ = (u_char)v; } \\[0-7]{3} { u_int v; sscanf(&yytext[1], "%o", &v); - *buf_ptr++ = (u_char)v; + *zptr++ = (u_char)v; } \\. { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '%c'", line_no, yytext[1]); - *buf_ptr++ = yytext[1]; + *zptr++ = yytext[1]; } . { - if(buf_ptr >= buffer + sizeof(buffer) - 1) + if(zptr >= buff + sizeof(buff) - 1) errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '%c'", line_no, *yytext); - *buf_ptr++ = *yytext; + *zptr++ = *yytext; } [^ \t\n]+ { strcat(map_name, "/"); @@ -254,7 +252,7 @@ YYSTYPE yylval; map_buf = yy_new_buffer(map_fp, YY_BUF_SIZE); main_buf = YY_CURRENT_BUFFER; yy_switch_to_buffer(map_buf); - buf_ptr = buffer; + zptr = buff; BEGIN(defn); } \n { @@ -267,7 +265,7 @@ YYSTYPE yylval; } <> { if(map_fp != NULL) { - if (buf_ptr != buffer) + if (zptr != buff) errx(EX_UNAVAILABLE, "premature EOF in the map near line %u of %s", line_no, map_name); yy_switch_to_buffer(main_buf); yy_delete_buffer(map_buf); @@ -280,7 +278,7 @@ YYSTYPE yylval; } %% #ifdef FLEX_DEBUG -main(void) +main() { while(yylex()) ;