Re: [Flex-devel] yytext and similar in -P scanners
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Will E. <wl...@us...> - 2007-05-11 16:16:29
|
Thanks for the patch and the report. There was no particular reason for the change to not parsing multiple concurrent options. On Friday, 11 May 2007, 12:05 pm EDT, Petr Machata <pma...@re...> wrote: > Hi, > > a bug has been opened against flex in Red Hat bugzilla: > http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=239695 > > Quote: > > Previous flex releases parsed args such that "flex -is" was > > acceptable. This release requires the form "flex -i -s" to > > do the same thing. > > Perhaps there were reasons behind this change, but grouping of options > seems to me a reasonable thing to support. I'm sending the patch that > implements it this way: if short option doesn't allow an argument, but > there is an argument string, error is not reported, but the string is > parsed next time around as another short option. > > Comments welcome. > > Thanks, > PM > > diff -urp flex-2.5.33/scanopt.c flex-2.5.33-pm/scanopt.c > --- flex-2.5.33/scanopt.c 2002-08-29 22:30:25.000000000 +0200 > +++ flex-2.5.33-pm/scanopt.c 2007-05-11 17:48:29.000000000 +0200 > @@ -789,12 +789,12 @@ int scanopt (svoid, arg, optindex) > } > > optarg = pstart + 1; > - arglen = 0; > - while (optarg[arglen]) > - arglen++; > - > - if (arglen == 0) > + if (!*optarg) { > optarg = NULL; > + arglen = 0; > + } > + else > + arglen = strlen (optarg); > } > > /* At this point, we have a long or short option matched at opt_offset into > @@ -812,13 +812,16 @@ int scanopt (svoid, arg, optindex) > > /* case: no args allowed */ > if (auxp->flags & ARG_NONE) { > - if (optarg) { > + if (optarg && !is_short) { > scanopt_err (s, opt_offset, is_short, errcode = > SCANOPT_ERR_ARG_NOT_ALLOWED); > INC_INDEX (s, 1); > return errcode; > } > - INC_INDEX (s, 1); > + else if (!optarg) > + INC_INDEX (s, 1); > + else > + s->subscript++; > return optp->r_val; > } > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Flex-devel mailing list > Fle...@li... > https://lists.sourceforge.net/lists/listinfo/flex-devel -- Will Estes Flex Project Maintainer http://flex.sourceforge.net/ |