From: bernhardheld Date: Tue, 20 May 2003 06:44:44 +0000 (+0000) Subject: Applied patch from bug 737905 (renamed yylineo to mylineno) X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=28a737dd5ef9959b63ee66d2f069891649a97c76;p=fw%2Fsdcc Applied patch from bug 737905 (renamed yylineo to mylineno) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2633 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index ef2a8fa3..ae51cf56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-05-19 Bernhard Held + + Applied patch from bug 737905 (renamed yylineo to mylineno): + * src/altlex.c + * src/SDCCast.c + * src/SDCglobl.h + * src/SDCC.lex + * src/SDCCsymt.c + * src/SDCCval.c + 2003-05-19 Scott Dattalo * src/pic16/pcode.c: Cleaned warnings diff --git a/src/SDCC.lex b/src/SDCC.lex index 87d26948..d88529d2 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -22,6 +22,8 @@ what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ +%option noyywrap + D [0-9] L [a-zA-Z_] H [a-fA-F0-9] @@ -42,15 +44,33 @@ char *currFname; extern int lineno, column; extern char *filename ; -int yylineno = 1 ; +int mylineno = 1 ; void count() ; int process_pragma(char *); #undef yywrap +#ifndef YYPROTO + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +#endif + int yywrap YY_PROTO((void)) { return(1); } + +static void yyunput (int, char *); + +static void my_unput(char c) +{ + yyunput(c, (yytext_ptr)); +} + #define TKEYWORD(token) return (isTargetKeyword(yytext) ? token :\ check_type(yytext)) char *asmbuff=NULL; @@ -64,6 +84,7 @@ extern int printListing (int ); struct optimize save_optimize ; struct options save_options ; %} + %x asm %% "_asm" { @@ -224,7 +245,7 @@ struct options save_options ; if (ch!='\n') { // that could have been removed by the preprocessor anyway werror (W_STRAY_BACKSLASH, column); - unput(ch); + my_unput(ch); } } . { count() ; } @@ -257,7 +278,7 @@ int checkCurrFile ( char *s) /* set the current line number to */ /* line number if printFlag is on */ if (!*s) { - lineno = yylineno = lNum ; + lineno = mylineno = lNum ; return 0; } @@ -269,7 +290,7 @@ int checkCurrFile ( char *s) /* in c1mode fullSrcFileName is NULL */ if ( fullSrcFileName && strncmp(s,fullSrcFileName,strlen(fullSrcFileName)) == 0) { - lineno = yylineno = lNum; + lineno = mylineno = lNum; currFname = fullSrcFileName ; } else { char *sb = s; @@ -277,7 +298,7 @@ int checkCurrFile ( char *s) while (*s != '"') s++; *s = '\0'; currFname = strdup (sb); - lineno = yylineno = lNum; + lineno = mylineno = lNum; } filename = currFname ; return 0; @@ -292,7 +313,7 @@ void count() for (i = 0; yytext[i] != '\0'; i++) { if (yytext[i] == '\n') { column = 0; - lineno = ++yylineno ; + lineno = ++mylineno ; } else if (yytext[i] == '\t') @@ -344,7 +365,7 @@ char *stringLiteral() ch = input(); if (ch == '\n') { /* \ is a continuator */ - lineno = ++yylineno; + lineno = ++mylineno; column = 0; } else { @@ -358,7 +379,7 @@ char *stringLiteral() /* if new line we have a new line break, which is illegal */ werror(W_NEWLINE_IN_STRING); dbuf_append(&dbuf, "\n", 1); - lineno = ++yylineno; + lineno = ++mylineno; column = 0; break; @@ -372,16 +393,16 @@ char *stringLiteral() case '\\': if ((ch = input()) != '\n') { werror(W_STRAY_BACKSLASH, column); - unput(ch); + my_unput(ch); } else { - lineno = ++yylineno; + lineno = ++mylineno; column = 0; } break; case '\n': - yylineno++; + mylineno++; break; } } @@ -390,7 +411,7 @@ char *stringLiteral() goto out; if (ch != '\"') { - unput(ch) ; + my_unput(ch) ; goto out; } break; @@ -607,9 +628,9 @@ int yyerror(char *s) { fflush(stdout); - if (yylineno && filename) { + if (mylineno && filename) { fprintf(stdout,"\n%s:%d: %s: token -> '%s' ; column %d\n", - filename,yylineno, + filename,mylineno, s,yytext,column); fatalError++; } else { diff --git a/src/SDCCast.c b/src/SDCCast.c index 5fd56732..1399fbd8 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -78,7 +78,7 @@ newAst_ (unsigned type) ex = Safe_alloc ( sizeof (ast)); ex->type = type; - ex->lineno = (noLineno ? oldLineno : yylineno); + ex->lineno = (noLineno ? oldLineno : mylineno); ex->filename = currFname; ex->level = NestLevel; ex->block = currBlockno; @@ -4314,7 +4314,7 @@ createFunction (symbol * name, ast * body) addSymChain (name); allocVariables (name); } - name->lastLine = yylineno; + name->lastLine = mylineno; currFunc = name; /* set the stack pointer */ diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 44a8d3ef..3fff1577 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -253,7 +253,7 @@ extern char *dstPath; /* path for the output files; */ extern char *moduleName; /* module name is source file without path and extension */ /* can be NULL while linking without compiling */ extern int currLineno; /* current line number */ -extern int yylineno; /* line number of the current file SDCC.lex */ +extern int mylineno; /* line number of the current file SDCC.lex */ extern FILE *yyin; /* */ extern FILE *asmFile; /* assembly output file */ extern FILE *cdbFile; /* debugger symbol file */ diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index be673e50..1e21ade1 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -290,7 +290,7 @@ newSymbol (char *name, int scope) strncpyz (sym->name, name, sizeof(sym->name)); /* copy the name */ sym->level = scope; /* set the level */ sym->block = currBlockno; - sym->lineDef = yylineno; /* set the line number */ + sym->lineDef = mylineno; /* set the line number */ return sym; } diff --git a/src/SDCCval.c b/src/SDCCval.c index d944b5c8..edd9c25b 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -56,7 +56,7 @@ newiList (int type, void *ilist) nilist = Safe_alloc (sizeof (initList)); nilist->type = type; - nilist->lineno = yylineno; + nilist->lineno = mylineno; switch (type) { diff --git a/src/altlex.c b/src/altlex.c index 5de19546..a7115d6f 100644 --- a/src/altlex.c +++ b/src/altlex.c @@ -47,7 +47,7 @@ extern char *filename; FILE *yyin; -int yylineno; +int mylineno; char *currFname; char *yytext; @@ -292,8 +292,8 @@ handle_line (void) if (line[0] == '\0') error ("Error in number in #line"); /* This is weird but cpp seems to add an extra three to the line no */ - yylineno = atoi (line) - 3; - lineno = yylineno; + mylineno = atoi (line) - 3; + lineno = mylineno; /* Fetch the filename if there is one */ while (c == '\t' || c == ' ') c = GETC (); @@ -325,8 +325,8 @@ static INLINE int check_newline (void) { int c; - yylineno++; - lineno = yylineno; + mylineno++; + lineno = mylineno; /* Skip any leading white space */ c = GETC ();