From: Arnaud L. <leg...@us...> - 2006-03-21 08:24:20
|
Update of /cvsroot/flexml/flexml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12924 Modified Files: flexml.pl skel Log Message: Add a -P option to enable multiple versions of flexml to live in the same C code. Note that this is a minor modification that doesn't break backward compatibility and that it unfortunately doesn't enable to have two dtd with common tags. Index: skel =================================================================== RCS file: /cvsroot/flexml/flexml/skel,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- skel 23 Feb 2005 22:22:20 -0000 1.26 +++ skel 21 Mar 2006 08:24:12 -0000 1.27 @@ -67,12 +67,14 @@ /* Text buffer stack handling. */ char bufferstack[FLEXML_BUFFERSTACKSIZE]; -char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE; +static char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE; typedef struct BufferLast_s { struct BufferLast_s *old; char* saved; char new1[1]; } BufferLast; -BufferLast* last = (BufferLast*)0; -char* next = bufferstack; +#ifdef FLEXML_HasMixed +static BufferLast* last = (BufferLast*)0; +#endif +static char* next = bufferstack; #define BUFFERSET(P) (P = next) #define BUFFERPUTC(C) (assert(next<limit), *(next++) = (C)) Index: flexml.pl =================================================================== RCS file: /cvsroot/flexml/flexml/flexml.pl,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- flexml.pl 3 Mar 2006 19:25:46 -0000 1.45 +++ flexml.pl 21 Mar 2006 08:24:12 -0000 1.46 @@ -54,6 +54,7 @@ my $uri; # -u option uri my $pubid; # -p option string my $stacksize; # -b option flag +my $tagprefix; # -P option flag my $dtd; # DTD file name (or URI) my $dtdrevision; # DTD version pruned from file @@ -486,9 +487,9 @@ # Parse options. $Use = "Usage: flexml [-ASHDvdqnLXV] [-s skel] [-p pubid] [-u uri]\n" - . " [-b stack_size] [-r roottags] [-a actions] name[.dtd]"; + . " [-b stack_size] [-r roottags] [-a actions] [-P prefix] name[.dtd]"; -getopts('ASHDvdnLXVqp:b:s:u:r:a:', \%opt); +getopts('ASHDvdnLXVqp:b:P:s:u:r:a:', \%opt); # Version! print "FleXML version $Id.\n" if $opt{V} or $opt{v}; @@ -515,6 +516,9 @@ # Specific stack size? $stacksize = ($opt{'b'} ? $opt{'b'} : 100000); +# Specific tagprefix? +$tagprefix = ($opt{'P'} ? $opt{'P'}."_" : ""); + # Set skeleton scanner file name and check it is readable (if needed). $SKELETON = ($opt{'s'} ? $opt{'s'} : './skel'); die "$0: No skeleton file $SKELETON.\n" if not -r $SKELETON and $opt{S}; @@ -1070,14 +1074,14 @@ print "\n"; print "/* XML application utilities. */\n"; - print "extern int element_context(int);\n"; + print "extern int ${tagprefix}element_context(int);\n"; print "\n"; print "/* XML processor entry point. */\n"; print "extern int yylex(void);\n"; print "\n"; print "/* Flexml error handling function (useful only when -q flag passed to flexml) */\n"; - print "const char * parse_err_msg(void);\n"; + print "const char * ${tagprefix}parse_err_msg(void);\n"; print "#endif\n"; @@ -1118,7 +1122,7 @@ if ( /^FLEXML_VERSION$/ ) { - print "const char rcs_flexml[] =\n" + print "const char rcs_${tagprefix}flexml[] =\n" . " \"\$\" \"$Id \$\";\n"; print "const char rcs_${cdtd}_dtd[] =\n" @@ -1171,7 +1175,7 @@ print "%{\n"; print "/* State names. */\n"; - print "const char* *statenames=NULL;\n"; + print "const char* *${tagprefix}statenames=NULL;\n"; print "%}\n"; } @@ -1181,16 +1185,16 @@ print " /* FleXML_init */\n"; print " next = bufferstack;\n"; - print " if(!statenames) {statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));\n"; + print " if(!${tagprefix}statenames) {${tagprefix}statenames= (const char **)calloc(IMPOSSIBLE,sizeof(char*));\n"; for ('PROLOG','DOCTYPE','EPILOG','INCOMMENT','INPI','VALUE1','VALUE2','CDATA') { - print " statenames[$_] = NULL;\n"; + print " ${tagprefix}statenames[$_] = NULL;\n"; } for my $tag (@tags) { my $c = $ctag{$tag}; - print " statenames[ROOT_$c] = NULL;\n" if $roottags{$tag}; - print " statenames[AL_$c] = NULL;\n"; + print " ${tagprefix}statenames[ROOT_$c] = NULL;\n" if $roottags{$tag}; + print " ${tagprefix}statenames[AL_$c] = NULL;\n"; for (split ',',$states{$tag}) { - print " statenames[$_] = \"$tag\";\n"; + print " ${tagprefix}statenames[$_] = \"$tag\";\n"; } } print " }\n"; @@ -1478,6 +1482,10 @@ } else { s/"\$Id/"\$" "Id/; + s/statenames/${tagprefix}statenames/g; + s/element_context/${tagprefix}element_context/g; + s/parse_err_msg/${tagprefix}parse_err_msg/g; + s/rcs_flexml_skeleton/rcs_${tagprefix}flexml_skeleton/g; print; } @@ -1750,6 +1758,11 @@ this option when you get an error like "Assertion `next<limit' failed". +=item B<-p> I<STRING> + +Use STRING to differentiate multiple versions of flexml in the same C +code. + =item B<-u> I<uri> Sets the URI of the DTD, used in the C<DOCTYPE> header, to the |