1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Lemon escapes backslashes in filenames in #line directives it generates.

Ticket #892. (CVS 1943)

FossilOrigin-Name: d53047cbbc4e618c7bb5161b6f82876bb113db25
This commit is contained in:
drh
2004-09-07 11:28:25 +00:00
parent 12057d54ef
commit af805ca035
3 changed files with 41 additions and 19 deletions

View File

@ -1,5 +1,5 @@
C Fix\smore\sname\scollisions.\s\sAllow\ssqlite.h\sand\ssqlite3.h\sto\sboth\sbe\sincluded\nin\sthe\ssame\sC/C++\ssource\sfile.\s(CVS\s1942) C Lemon\sescapes\sbackslashes\sin\sfilenames\sin\s#line\sdirectives\sit\sgenerates.\nTicket\s#892.\s(CVS\s1943)
D 2004-09-06T17:34:13 D 2004-09-07T11:28:25
F Makefile.in 65a7c43fcaf9a710d62f120b11b6e435eeb4a450 F Makefile.in 65a7c43fcaf9a710d62f120b11b6e435eeb4a450
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@ -193,7 +193,7 @@ F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
F test/view.test ca5c296989d3045f121be9a67588ff88c64874a8 F test/view.test ca5c296989d3045f121be9a67588ff88c64874a8
F test/where.test 40dcffcb77ad0a00960cef2b5b1212c77fd02199 F test/where.test 40dcffcb77ad0a00960cef2b5b1212c77fd02199
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
F tool/lemon.c ece41a3cd100e68fef5f136267cf02c44366c263 F tool/lemon.c b64210ca04268681a74b32a830c64be523ccc859
F tool/lempar.c 0b5e7a58634e0d448929b8e85f7981c2aa708d57 F tool/lempar.c 0b5e7a58634e0d448929b8e85f7981c2aa708d57
F tool/memleak.awk b744b6109566206c746d826f6ecdba34662216bc F tool/memleak.awk b744b6109566206c746d826f6ecdba34662216bc
F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8 F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
@ -248,7 +248,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P 3ddf5a9d1c480a2e3aa32685879063b11afddbe1 P 23e5bed1c5062f0f639751f89873bf1a277547bd
R 4e21ecb2dca1b0e6b2292d8785d52007 R e40cf5a15ff3721d6f9f87371f66f8fc
U drh U drh
Z 6b0395c7e689562e57eb91318a8ed3d1 Z 9268fa6b52f2c5d13e0dc61c8a84d6ef

View File

@ -1 +1 @@
23e5bed1c5062f0f639751f89873bf1a277547bd d53047cbbc4e618c7bb5161b6f82876bb113db25

View File

@ -2923,6 +2923,21 @@ struct lemon *lemp;
return in; return in;
} }
/* Print a #line directive line to the output file. */
PRIVATE void tplt_linedir(out,lineno,filename)
FILE *out;
int lineno;
char *filename;
{
fprintf(out,"#line %d \"",lineno);
while( *filename ){
if( *filename == '\\' ) putc('\\',out);
putc(*filename,out);
filename++;
}
fprintf(out,"\"\n");
}
/* Print a string to the file and keep the linenumber up to date */ /* Print a string to the file and keep the linenumber up to date */
PRIVATE void tplt_print(out,lemp,str,strln,lineno) PRIVATE void tplt_print(out,lemp,str,strln,lineno)
FILE *out; FILE *out;
@ -2932,13 +2947,15 @@ int strln;
int *lineno; int *lineno;
{ {
if( str==0 ) return; if( str==0 ) return;
fprintf(out,"#line %d \"%s\"\n",strln,lemp->filename); (*lineno)++; tplt_linedir(out,strln,lemp->filename);
(*lineno)++;
while( *str ){ while( *str ){
if( *str=='\n' ) (*lineno)++; if( *str=='\n' ) (*lineno)++;
putc(*str,out); putc(*str,out);
str++; str++;
} }
fprintf(out,"\n#line %d \"%s\"\n",*lineno+2,lemp->outname); (*lineno)+=2; tplt_linedir(out,*lineno+2,lemp->outname);
(*lineno)+=2;
return; return;
} }
@ -2958,14 +2975,17 @@ int *lineno;
if( sp->type==TERMINAL ){ if( sp->type==TERMINAL ){
cp = lemp->tokendest; cp = lemp->tokendest;
if( cp==0 ) return; if( cp==0 ) return;
fprintf(out,"#line %d \"%s\"\n{",lemp->tokendestln,lemp->filename); tplt_linedir(out,lemp->tokendestln,lemp->filename);
fprintf(out,"{");
}else if( sp->destructor ){ }else if( sp->destructor ){
cp = sp->destructor; cp = sp->destructor;
fprintf(out,"#line %d \"%s\"\n{",sp->destructorln,lemp->filename); tplt_linedir(out,sp->destructorln,lemp->filename);
fprintf(out,"{");
}else if( lemp->vardest ){ }else if( lemp->vardest ){
cp = lemp->vardest; cp = lemp->vardest;
if( cp==0 ) return; if( cp==0 ) return;
fprintf(out,"#line %d \"%s\"\n{",lemp->vardestln,lemp->filename); tplt_linedir(out,lemp->vardestln,lemp->filename);
fprintf(out,"{");
}else{ }else{
assert( 0 ); /* Cannot happen */ assert( 0 ); /* Cannot happen */
} }
@ -2979,7 +2999,8 @@ int *lineno;
fputc(*cp,out); fputc(*cp,out);
} }
(*lineno) += 3 + linecnt; (*lineno) += 3 + linecnt;
fprintf(out,"}\n#line %d \"%s\"\n",*lineno,lemp->outname); fprintf(out,"}\n");
tplt_linedir(out,*lineno,lemp->outname);
return; return;
} }
@ -3015,7 +3036,7 @@ PRIVATE char *append_str(char *zText, int n, int p1, int p2){
static char *z = 0; static char *z = 0;
static int alloced = 0; static int alloced = 0;
static int used = 0; static int used = 0;
int i, c; int c;
char zInt[40]; char zInt[40];
if( zText==0 ){ if( zText==0 ){
@ -3054,9 +3075,9 @@ PRIVATE char *append_str(char *zText, int n, int p1, int p2){
/* /*
** zCode is a string that is the action associated with a rule. Expand ** zCode is a string that is the action associated with a rule. Expand
** the symbols in this string so that the refer to elements of the parser ** the symbols in this string so that the refer to elements of the parser
** stack. Return a new string stored in space obtained from malloc. ** stack.
*/ */
PRIVATE char *translate_code(struct lemon *lemp, struct rule *rp){ PRIVATE void translate_code(struct lemon *lemp, struct rule *rp){
char *cp, *xp; char *cp, *xp;
int i; int i;
char lhsused = 0; /* True if the LHS element has been used */ char lhsused = 0; /* True if the LHS element has been used */
@ -3142,13 +3163,14 @@ int *lineno;
/* Generate code to do the reduce action */ /* Generate code to do the reduce action */
if( rp->code ){ if( rp->code ){
fprintf(out,"#line %d \"%s\"\n{",rp->line,lemp->filename); tplt_linedir(out,rp->line,lemp->filename);
fprintf(out,"%s",rp->code); fprintf(out,"{%s",rp->code);
for(cp=rp->code; *cp; cp++){ for(cp=rp->code; *cp; cp++){
if( *cp=='\n' ) linecnt++; if( *cp=='\n' ) linecnt++;
} /* End loop */ } /* End loop */
(*lineno) += 3 + linecnt; (*lineno) += 3 + linecnt;
fprintf(out,"}\n#line %d \"%s\"\n",*lineno,lemp->outname); fprintf(out,"}\n");
tplt_linedir(out,*lineno,lemp->outname);
} /* End if( rp->code ) */ } /* End if( rp->code ) */
return; return;