Explicit casts of the return from strlen() to int in lemon. This has
no effect on SQLite. It has no effect on any lemon-generated parser with a grammar that is less than 2GB in size. Ticket #3293. (CVS 5564) FossilOrigin-Name: a519cdb2f46fffe16e666f161479a22463616cb3
This commit is contained in:
parent
639efd0451
commit
87cf137735
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\stoken\sdestructors\sin\slemon\sgenerated\sparsers.\s\sDoes\snot\seffect\sSQLite.\nTicket\s#3299.\s(CVS\s5563)
|
||||
D 2008-08-13T20:04:30
|
||||
C Explicit\scasts\sof\sthe\sreturn\sfrom\sstrlen()\sto\sint\sin\slemon.\s\sThis\shas\nno\seffect\son\sSQLite.\s\sIt\shas\sno\seffect\son\sany\slemon-generated\sparser\nwith\sa\sgrammar\sthat\sis\sless\sthan\s2GB\sin\ssize.\s\sTicket\s#3293.\s(CVS\s5564)
|
||||
D 2008-08-13T20:09:07
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in 2713ea64947be3b35f35d9a3158bb8299c90b019
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -596,7 +596,7 @@ F test/where6.test 42c4373595f4409d9c6a9987b4a60000ad664faf
|
||||
F test/zeroblob.test 792124852ec61458a2eb527b5091791215e0be95
|
||||
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
|
||||
F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
|
||||
F tool/lemon.c b1079f06558d1a94912271aa5c60600cc6022c1d
|
||||
F tool/lemon.c 6cb39632ef3bfec2cea8f81b4d7f63c09fe12802
|
||||
F tool/lempar.c 4d115ee7c0c8a749d5b22abed731abb4e6546a5f
|
||||
F tool/memleak.awk 4e7690a51bf3ed757e611273d43fe3f65b510133
|
||||
F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
|
||||
@ -618,7 +618,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
P 0b92cbf5255020d4fde382f81590ff0488936667
|
||||
R 9d574c529378b3d73d80ccf88b33d8ef
|
||||
P 4887e8fc4af9e2963b3eff3187dee5b0d6297eb5
|
||||
R 6ddaa6c8e2519b5e2a6ee90e75b9e9c6
|
||||
U drh
|
||||
Z fdcb2741ad3dd67c96bbb89ab36fad62
|
||||
Z 904bb51f739e17f7654b323ec4f1ab68
|
||||
|
@ -1 +1 @@
|
||||
4887e8fc4af9e2963b3eff3187dee5b0d6297eb5
|
||||
a519cdb2f46fffe16e666f161479a22463616cb3
|
61
tool/lemon.c
61
tool/lemon.c
@ -36,6 +36,13 @@ extern int access();
|
||||
|
||||
static char *msort(char*,char**,int(*)(const char*,const char*));
|
||||
|
||||
/*
|
||||
** Compilers are getting increasingly pedantic about type conversions
|
||||
** as C evolves ever closer to Ada.... To work around the latest problems
|
||||
** we have to define the following variant of strlen().
|
||||
*/
|
||||
#define lemonStrlen(X) ((int)strlen(X))
|
||||
|
||||
static struct action *Action_new(void);
|
||||
static struct action *Action_sort(struct action *);
|
||||
|
||||
@ -1321,13 +1328,13 @@ void ErrorMsg(const char *filename, int lineno, const char *format, ...){
|
||||
}else{
|
||||
sprintf(prefix,"%.*s: ",PREFIXLIMIT-10,filename);
|
||||
}
|
||||
prefixsize = strlen(prefix);
|
||||
prefixsize = lemonStrlen(prefix);
|
||||
availablewidth = LINEWIDTH - prefixsize;
|
||||
|
||||
/* Generate the error message */
|
||||
vsprintf(errmsg,format,ap);
|
||||
va_end(ap);
|
||||
errmsgsize = strlen(errmsg);
|
||||
errmsgsize = lemonStrlen(errmsg);
|
||||
/* Remove trailing '\n's from the error message. */
|
||||
while( errmsgsize>0 && errmsg[errmsgsize-1]=='\n' ){
|
||||
errmsg[--errmsgsize] = 0;
|
||||
@ -1371,7 +1378,7 @@ static void handle_D_option(char *z){
|
||||
exit(1);
|
||||
}
|
||||
paz = &azDefine[nDefine-1];
|
||||
*paz = malloc( strlen(z)+1 );
|
||||
*paz = malloc( lemonStrlen(z)+1 );
|
||||
if( *paz==0 ){
|
||||
fprintf(stderr,"out of memory\n");
|
||||
exit(1);
|
||||
@ -1649,10 +1656,10 @@ FILE *err;
|
||||
{
|
||||
int spcnt, i;
|
||||
if( argv[0] ) fprintf(err,"%s",argv[0]);
|
||||
spcnt = strlen(argv[0]) + 1;
|
||||
spcnt = lemonStrlen(argv[0]) + 1;
|
||||
for(i=1; i<n && argv[i]; i++){
|
||||
fprintf(err," %s",argv[i]);
|
||||
spcnt += strlen(argv[i])+1;
|
||||
spcnt += lemonStrlen(argv[i])+1;
|
||||
}
|
||||
spcnt += k;
|
||||
for(; argv[i]; i++) fprintf(err," %s",argv[i]);
|
||||
@ -1697,7 +1704,7 @@ FILE *err;
|
||||
int errcnt = 0;
|
||||
int j;
|
||||
for(j=0; op[j].label; j++){
|
||||
if( strncmp(&argv[i][1],op[j].label,strlen(op[j].label))==0 ) break;
|
||||
if( strncmp(&argv[i][1],op[j].label,lemonStrlen(op[j].label))==0 ) break;
|
||||
}
|
||||
v = argv[i][0]=='-' ? 1 : 0;
|
||||
if( op[j].label==0 ){
|
||||
@ -1874,7 +1881,7 @@ void OptPrint(){
|
||||
int max, len;
|
||||
max = 0;
|
||||
for(i=0; op[i].label; i++){
|
||||
len = strlen(op[i].label) + 1;
|
||||
len = lemonStrlen(op[i].label) + 1;
|
||||
switch( op[i].type ){
|
||||
case OPT_FLAG:
|
||||
case OPT_FFLAG:
|
||||
@ -1903,17 +1910,17 @@ void OptPrint(){
|
||||
case OPT_INT:
|
||||
case OPT_FINT:
|
||||
fprintf(errstream," %s=<integer>%*s %s\n",op[i].label,
|
||||
(int)(max-strlen(op[i].label)-9),"",op[i].message);
|
||||
(int)(max-lemonStrlen(op[i].label)-9),"",op[i].message);
|
||||
break;
|
||||
case OPT_DBL:
|
||||
case OPT_FDBL:
|
||||
fprintf(errstream," %s=<real>%*s %s\n",op[i].label,
|
||||
(int)(max-strlen(op[i].label)-6),"",op[i].message);
|
||||
(int)(max-lemonStrlen(op[i].label)-6),"",op[i].message);
|
||||
break;
|
||||
case OPT_STR:
|
||||
case OPT_FSTR:
|
||||
fprintf(errstream," %s=<string>%*s %s\n",op[i].label,
|
||||
(int)(max-strlen(op[i].label)-8),"",op[i].message);
|
||||
(int)(max-lemonStrlen(op[i].label)-8),"",op[i].message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2325,13 +2332,13 @@ to follow the previous rule.");
|
||||
char zLine[50];
|
||||
zNew = x;
|
||||
if( zNew[0]=='"' || zNew[0]=='{' ) zNew++;
|
||||
nNew = strlen(zNew);
|
||||
nNew = lemonStrlen(zNew);
|
||||
if( *psp->declargslot ){
|
||||
zOld = *psp->declargslot;
|
||||
}else{
|
||||
zOld = "";
|
||||
}
|
||||
nOld = strlen(zOld);
|
||||
nOld = lemonStrlen(zOld);
|
||||
n = nOld + nNew + 20;
|
||||
addLineMacro = psp->insertLineMacro &&
|
||||
(psp->decllinenoslot==0 || psp->decllinenoslot[0]!=0);
|
||||
@ -2340,8 +2347,8 @@ to follow the previous rule.");
|
||||
if( *z=='\\' ) nBack++;
|
||||
}
|
||||
sprintf(zLine, "#line %d ", psp->tokenlineno);
|
||||
nLine = strlen(zLine);
|
||||
n += nLine + strlen(psp->filename) + nBack;
|
||||
nLine = lemonStrlen(zLine);
|
||||
n += nLine + lemonStrlen(psp->filename) + nBack;
|
||||
}
|
||||
*psp->declargslot = zBuf = realloc(*psp->declargslot, n);
|
||||
zBuf += nOld;
|
||||
@ -2455,7 +2462,7 @@ static void preprocess_input(char *z){
|
||||
for(n=0; z[j+n] && !isspace(z[j+n]); n++){}
|
||||
exclude = 1;
|
||||
for(k=0; k<nDefine; k++){
|
||||
if( strncmp(azDefine[k],&z[j],n)==0 && strlen(azDefine[k])==n ){
|
||||
if( strncmp(azDefine[k],&z[j],n)==0 && lemonStrlen(azDefine[k])==n ){
|
||||
exclude = 0;
|
||||
break;
|
||||
}
|
||||
@ -2709,7 +2716,7 @@ char *suffix;
|
||||
char *name;
|
||||
char *cp;
|
||||
|
||||
name = malloc( strlen(lemp->filename) + strlen(suffix) + 5 );
|
||||
name = malloc( lemonStrlen(lemp->filename) + lemonStrlen(suffix) + 5 );
|
||||
if( name==0 ){
|
||||
fprintf(stderr,"Can't allocate space for a filename.\n");
|
||||
exit(1);
|
||||
@ -2754,7 +2761,7 @@ struct lemon *lemp;
|
||||
maxlen = 10;
|
||||
for(i=0; i<lemp->nsymbol; i++){
|
||||
sp = lemp->symbols[i];
|
||||
len = strlen(sp->name);
|
||||
len = lemonStrlen(sp->name);
|
||||
if( len>maxlen ) maxlen = len;
|
||||
}
|
||||
ncolumns = 76/(maxlen+5);
|
||||
@ -2969,18 +2976,18 @@ int modemask;
|
||||
if( cp ){
|
||||
c = *cp;
|
||||
*cp = 0;
|
||||
path = (char *)malloc( strlen(argv0) + strlen(name) + 2 );
|
||||
path = (char *)malloc( lemonStrlen(argv0) + lemonStrlen(name) + 2 );
|
||||
if( path ) sprintf(path,"%s/%s",argv0,name);
|
||||
*cp = c;
|
||||
}else{
|
||||
extern char *getenv();
|
||||
pathlist = getenv("PATH");
|
||||
if( pathlist==0 ) pathlist = ".:/bin:/usr/bin";
|
||||
path = (char *)malloc( strlen(pathlist)+strlen(name)+2 );
|
||||
path = (char *)malloc( lemonStrlen(pathlist)+lemonStrlen(name)+2 );
|
||||
if( path!=0 ){
|
||||
while( *pathlist ){
|
||||
cp = strchr(pathlist,':');
|
||||
if( cp==0 ) cp = &pathlist[strlen(pathlist)];
|
||||
if( cp==0 ) cp = &pathlist[lemonStrlen(pathlist)];
|
||||
c = *cp;
|
||||
*cp = 0;
|
||||
sprintf(path,"%s/%s",pathlist,name);
|
||||
@ -3215,7 +3222,7 @@ PRIVATE char *append_str(char *zText, int n, int p1, int p2){
|
||||
used += n;
|
||||
assert( used>=0 );
|
||||
}
|
||||
n = strlen(zText);
|
||||
n = lemonStrlen(zText);
|
||||
}
|
||||
if( n+sizeof(zInt)*2+used >= alloced ){
|
||||
alloced = n + sizeof(zInt)*2 + used + 200;
|
||||
@ -3228,7 +3235,7 @@ PRIVATE char *append_str(char *zText, int n, int p1, int p2){
|
||||
sprintf(zInt, "%d", p1);
|
||||
p1 = p2;
|
||||
strcpy(&z[used], zInt);
|
||||
used += strlen(&z[used]);
|
||||
used += lemonStrlen(&z[used]);
|
||||
zText++;
|
||||
n--;
|
||||
}else{
|
||||
@ -3384,13 +3391,13 @@ int mhflag; /* True if generating makeheaders output */
|
||||
for(i=0; i<arraysize; i++) types[i] = 0;
|
||||
maxdtlength = 0;
|
||||
if( lemp->vartype ){
|
||||
maxdtlength = strlen(lemp->vartype);
|
||||
maxdtlength = lemonStrlen(lemp->vartype);
|
||||
}
|
||||
for(i=0; i<lemp->nsymbol; i++){
|
||||
int len;
|
||||
struct symbol *sp = lemp->symbols[i];
|
||||
if( sp->datatype==0 ) continue;
|
||||
len = strlen(sp->datatype);
|
||||
len = lemonStrlen(sp->datatype);
|
||||
if( len>maxdtlength ) maxdtlength = len;
|
||||
}
|
||||
stddt = (char*)malloc( maxdtlength*2 + 1 );
|
||||
@ -3442,7 +3449,7 @@ int mhflag; /* True if generating makeheaders output */
|
||||
}
|
||||
if( types[hash]==0 ){
|
||||
sp->dtnum = hash + 1;
|
||||
types[hash] = (char*)malloc( strlen(stddt)+1 );
|
||||
types[hash] = (char*)malloc( lemonStrlen(stddt)+1 );
|
||||
if( types[hash]==0 ){
|
||||
fprintf(stderr,"Out of memory.\n");
|
||||
exit(1);
|
||||
@ -3611,7 +3618,7 @@ int mhflag; /* Output in makeheaders format if true */
|
||||
name = lemp->name ? lemp->name : "Parse";
|
||||
if( lemp->arg && lemp->arg[0] ){
|
||||
int i;
|
||||
i = strlen(lemp->arg);
|
||||
i = lemonStrlen(lemp->arg);
|
||||
while( i>=1 && isspace(lemp->arg[i-1]) ) i--;
|
||||
while( i>=1 && (isalnum(lemp->arg[i-1]) || lemp->arg[i-1]=='_') ) i--;
|
||||
fprintf(out,"#define %sARG_SDECL %s;\n",name,lemp->arg); lineno++;
|
||||
@ -4209,7 +4216,7 @@ char *y;
|
||||
|
||||
if( y==0 ) return 0;
|
||||
z = Strsafe_find(y);
|
||||
if( z==0 && (z=malloc( strlen(y)+1 ))!=0 ){
|
||||
if( z==0 && (z=malloc( lemonStrlen(y)+1 ))!=0 ){
|
||||
strcpy(z,y);
|
||||
Strsafe_insert(z);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user