With all the good changes to lemon recently, I thought I'd post changes that I have made to my personal copy. One of my customers requires that I demonstrate the version of all build tools I use at build time, so I added a few command line parameters to help with that.
It would be nice if the version identifier for lemon would increment as it matures, but I understand why it doesn't currently increment. It doesn't make sense to tie the version of lemon.exe to sqlite3.exe. I've toyed with using the build script to query fossil finfo lemon.c --limit 1 and use the artifact id or version id to uniquely identify a particular lemon build. RW Ron Wilson, Engineering Project Lead (o) 434.455.6453, (m) 434.851.1612, www.harris.com project-name: SQLite repository: C:/rev/fossil/sqlite3.f local-root: C:/rev/src/sqlite3/ user-home: C:/Documents and Settings/ma088024/Application Data project-code: 2ab58778c2967968b94284e989e43dc11791f548 server-code: dcd2b579c69c56d9973f76b372db9806df4a3252 checkout: 1e8b842039cc06b57a321226633c55b94eb8dcd7 2010-02-22 19:37:44 UTC parent: a8076aede33c07e9a2aaa05be8a888f37b45e41c 2010-02-22 19:32:32 UTC parent: 721f33e7221c5fc907e9e293ac3242843f4fcfb7 2010-02-17 20:31:32 UTC tags: trunk --- lemon.c +++ lemon.c @@ -4,10 +4,13 @@ ** single file to make it easy to include LEMON in the source tree ** and Makefile of another program. ** ** The author of this program disclaims copyright. */ + +#define SZVERSION "1.0" + #include <stdio.h> #include <stdarg.h> #include <string.h> #include <ctype.h> #include <stdlib.h> @@ -99,10 +102,11 @@ enum option_type type; const char *label; char *arg; const char *message; }; +void OptVersion(void); int OptInit(char**,struct s_options*,FILE*); int OptNArgs(void); char *OptArg(int); void OptErr(int); void OptPrint(void); @@ -1395,10 +1399,12 @@ } /* The main program. Parse the command line and do it... */ int main(int argc, char **argv) { + static int help = 0; + static int versiononly = 0; static int version = 0; static int rpflag = 0; static int basisflag = 0; static int compress = 0; static int quiet = 0; @@ -1409,31 +1415,46 @@ {OPT_FLAG, "b", (char*)&basisflag, "Print only the basis in report."}, {OPT_FLAG, "c", (char*)&compress, "Don't compress the action table."}, {OPT_FSTR, "D", (char*)handle_D_option, "Define an %ifdef macro."}, {OPT_FSTR, "T", (char*)handle_T_option, "Specify a template file."}, {OPT_FLAG, "g", (char*)&rpflag, "Print grammar without actions."}, + {OPT_FLAG, "h", (char*)&help, "Print this help message."}, {OPT_FLAG, "m", (char*)&mhflag, "Output a makeheaders compatible file."}, {OPT_FLAG, "l", (char*)&nolinenosflag, "Do not print #line statements."}, {OPT_FLAG, "q", (char*)&quiet, "(Quiet) Don't print the report file."}, {OPT_FLAG, "s", (char*)&statistics, "Print parser stats to standard output."}, - {OPT_FLAG, "x", (char*)&version, "Print the version number."}, + {OPT_FLAG, "v", (char*)&version, "Print the version number and continue."}, + {OPT_FLAG, "x", (char*)&versiononly, "Print the version number and exit."}, {OPT_FLAG,0,0,0} }; int i; int exitcode; struct lemon lem; atexit(LemonAtExit); OptInit(argv,options,stderr); + + if ( help ) { + OptVersion(); + printf("Valid command line options are:\n"); + OptPrint(); + exit(0); + } + if( versiononly ){ + OptVersion(); + exit(0); + } if( version ){ - printf("Lemon version 1.0\n"); - exit(0); + OptVersion(); } if( OptNArgs()!=1 ){ fprintf(stderr,"Exactly one filename argument is required.\n"); + OptVersion(); + printf("Valid command line options are:\n"); + OptPrint(); exit(1); } memset(&lem, 0, sizeof(lem)); lem.errorcnt = 0; @@ -1821,10 +1842,15 @@ (*(void(*)(char *))(op[j].arg))(sv); break; } } return errcnt; +} + +void OptVersion() +{ + printf("Lemon version %s\n", SZVERSION); } int OptInit(char **a, struct s_options *o, FILE *err) { int errcnt = 0; _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users