OSDN Git Service

Fix option parsing infrastructure bug.
authorRob Landley <rob@landley.net>
Fri, 1 Jul 2016 01:41:07 +0000 (20:41 -0500)
committerRob Landley <rob@landley.net>
Fri, 1 Jul 2016 01:41:07 +0000 (20:41 -0500)
In main.c: used adjusted string with placeholers for removed options (so flag
values don't move based on config, allowing FORCE_FLAGS to work).

In scripts/mkflags.c: test was wrong, a bare longopt never matches a single
letter command, but it was treated as always matching when comparing
allyesconfig vs current config to determine which options were disabled, so
there was a corner case that got the flag values wrong.

main.c
scripts/mkflags.c

diff --git a/main.c b/main.c
index bedb333..31e51b1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -13,7 +13,7 @@
 
 #undef NEWTOY
 #undef OLDTOY
-#define NEWTOY(name, opts, flags) {#name, name##_main, opts, flags},
+#define NEWTOY(name, opts, flags) {#name, name##_main, OPTSTR_##name, flags},
 #define OLDTOY(name, oldname, flags) \
   {#name, oldname##_main, OPTSTR_##oldname, flags},
 
index da3b2f9..8b3d0aa 100644 (file)
@@ -194,7 +194,7 @@ int main(int argc, char *argv[])
         }
       // Output normal flag macro
       } else if (aflist->command) {
-        if (flist && (!flist->command || *aflist->command == *flist->command)) {
+        if (flist && flist->command && *aflist->command == *flist->command) {
           if (aflist->command)
             sprintf(out, "#define FLAG_%c (1%s<<%d)\n", *aflist->command,
               llstr, bit);