X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/a8beef7e6a9f6b75fa249d59b4c79585190540b6..e0c653e7e660c353c59b054de571474450aa4c92:/src/getargs.c diff --git a/src/getargs.c b/src/getargs.c index bc1cc64b..cff6ff3f 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -87,10 +87,12 @@ char *program_name; * \param keys array of valid subarguments. * \param values array of corresponding (int) values. * \param flags the flags to update - * \param args colon separated list of effective subarguments to decode. + * \param args comma separated list of effective subarguments to decode. * If 0, then activate all the flags. * - * The special value 0 resets the flags to 0. + * If VALUE != 0 then KEY sets flags and no-KEY clears them. + * If VALUE == 0 then KEY clears all flags and no-KEY sets all flags. + * Thus no-none = all and no-all = none. */ static void flags_argmatch (const char *option, @@ -102,11 +104,18 @@ flags_argmatch (const char *option, args = strtok (args, ","); while (args) { - int value = XARGMATCH (option, args, keys, values); + int no = strncmp (args, "no-", 3) == 0 ? 3 : 0; + int value = XARGMATCH (option, args + no, keys, values); if (value == 0) - *flags = 0; + if (no) + *flags = ~0; + else + *flags = 0; else - *flags |= value; + if (no) + *flags &= ~value; + else + *flags |= value; args = strtok (NULL, ","); } } @@ -248,6 +257,11 @@ usage (int status) program_name); else { + /* For ../build-aux/cross-options.pl to work, use the format: + ^ -S, --long[=ARGS] (whitespace) + A --long option is required. + Otherwise, add exceptions to ../build-aux/cross-options.pl. */ + printf (_("Usage: %s [OPTION]... FILE\n"), program_name); fputs (_("\ Generate LALR(1) and GLR parsers.\n\ @@ -529,14 +543,10 @@ getargs (int argc, char *argv[]) { char* name = optarg; char* value = strchr (optarg, '='); - char const * muscle_value = ""; if (value) - { - *value++ = 0; - muscle_value = value; - } + *value++ = 0; muscle_percent_define_insert (name, command_line_location (), - muscle_value); + value ? value : ""); } break;