-C Add\sspell-checking\sfor\sall\scomments\sin\smain\ssources.\s(./src/\s.c\s.h\s.in)\smake\starget\s"misspell"\stells\sof\smisspelled\swords\sfor\swhich\sno\sexceptions\shave\sbeen\sput\sinto\stool/custom.txt\s.
-D 2023-06-07T23:10:40.610
+C Enhance\sLemon\sso\sthat\sit\sremembers\swhich\s-D\scommand-line\soptions\sare\sactually\nused\sin\sthe\sgrammar\sand\sincludes\sa\slist\sof\sall\ssuch\soptions\sin\sthe\sheader\nof\sthe\sgenerated\soutput\sfile.
+D 2023-06-08T12:52:28.968
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5
F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f
-F tool/lemon.c ea5c8589c7749e9bd32ba10432aeeed3c16e215de72a12ada2bc707884837149
+F tool/lemon.c 19e368bc8e97ff4071115119a7911ca3b0c56eba7926d8ada8b4a86fcc69a176
F tool/lempar.c 57478ea48420da05faa873c6d1616321caa5464644588c97fbe8e0ea04450748
F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 9a12bac5d24c7a8364d2127fd12c3409a53ef83e408d10f344ddd311cdba98af 8c291d99946eb32b20b743921202f9c7cfb716268ff526817b27adbb7942e40b
-R afa3749bf57be03443dd9fb9514c3cf7
-U larrybr
-Z 0c523abe03ffdbb3d9d4cf04093ae69e
+P 5332abf0ad8ef42c44e9dd7045d017bb8fc9a0262a89ababa3e2c41788a6cdb8
+R 8901e2725cbc66d820e7686f035bb3c9
+U drh
+Z e939ccde6d44f5ae271532ac04101d42
# Remove this line to create a well-formed Fossil manifest.
int printPreprocessed; /* Show preprocessor output on stdout */
int has_fallback; /* True if any %fallback is seen in the grammar */
int nolinenosflag; /* True if #line statements should not be printed */
- char *argv0; /* Name of the program */
+ int argc; /* Number of command-line arguments */
+ char **argv; /* Command-line arguments */
};
#define MemoryCheck(X) if((X)==0){ \
exit(1);
}
-static int nDefine = 0; /* Number of -D options on the command line */
-static char **azDefine = 0; /* Name of the -D macros */
+static int nDefine = 0; /* Number of -D options on the command line */
+static int nDefineUsed = 0; /* Number of -D options actually used */
+static char **azDefine = 0; /* Name of the -D macros */
+static char *bDefineUsed = 0; /* True for every -D macro actually used */
/* This routine is called with the argument to each -D command-line option.
** Add the macro defined to the azDefine array.
fprintf(stderr,"out of memory\n");
exit(1);
}
+ bDefineUsed = (char*)realloc(bDefineUsed, nDefine);
+ if( bDefineUsed==0 ){
+ fprintf(stderr,"out of memory\n");
+ exit(1);
+ }
+ bDefineUsed[nDefine-1] = 0;
paz = &azDefine[nDefine-1];
*paz = (char *) malloc( lemonStrlen(z)+1 );
if( *paz==0 ){
struct lemon lem;
struct rule *rp;
- (void)argc;
OptInit(argv,options,stderr);
if( version ){
printf("Lemon version 1.0\n");
Strsafe_init();
Symbol_init();
State_init();
- lem.argv0 = argv[0];
+ lem.argv = argv;
+ lem.argc = argc;
lem.filename = OptArg(0);
lem.basisflag = basisflag;
lem.nolinenosflag = nolinenosflag;
res = 0;
for(j=0; j<nDefine; j++){
if( strncmp(azDefine[j],&z[i],n)==0 && azDefine[j][n]==0 ){
+ if( !bDefineUsed[j] ){
+ bDefineUsed[j] = 1;
+ nDefineUsed++;
+ }
res = 1;
break;
}
}else if( access(templatename,004)==0 ){
tpltname = templatename;
}else{
- toFree = tpltname = pathsearch(lemp->argv0,templatename,0);
+ toFree = tpltname = pathsearch(lemp->argv[0],templatename,0);
}
if( tpltname==0 ){
fprintf(stderr,"Can't find the parser driver template file \"%s\".\n",
fprintf(out,
"/* This file is automatically generated by Lemon from input grammar\n"
- "** source file \"%s\". */\n", lemp->filename); lineno += 2;
+ "** source file \"%s\"", lemp->filename); lineno++;
+ if( nDefineUsed==0 ){
+ fprintf(out, ".\n*/\n"); lineno += 2;
+ }else{
+ fprintf(out, " with these options:\n**\n"); lineno += 2;
+ for(i=0; i<nDefine; i++){
+ if( !bDefineUsed[i] ) continue;
+ fprintf(out, "** -D%s\n", azDefine[i]); lineno++;
+ }
+ fprintf(out, "*/\n"); lineno++;
+ }
/* The first %include directive begins with a C-language comment,
** then skip over the header comment of the template file