aboutsummaryrefslogtreecommitdiff
path: root/scripts/mkflags.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-05-03 12:41:05 -0500
committerRob Landley <rob@landley.net>2015-05-03 12:43:58 -0500
commit5640acb50da707b404e00e9a20ba3fb3ec334a91 (patch)
treec7383f1a8ee39c0f2b0d33ca03bc69e2b22040b0 /scripts/mkflags.c
parent38a5493031bca46263038964a8f5b188d7e9304e (diff)
downloadtoybox-5640acb50da707b404e00e9a20ba3fb3ec334a91.tar.gz
If a shortopt is configured out right before a bare longopt, the option parsing infrastructure segfaults because there's no next shortopt but the list isn't empty. (There was a test for this, but we're simultaneously traversing two lists and it was testing the wrong one.)
Diffstat (limited to 'scripts/mkflags.c')
-rw-r--r--scripts/mkflags.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/scripts/mkflags.c b/scripts/mkflags.c
index 228cd2f8..d87087bc 100644
--- a/scripts/mkflags.c
+++ b/scripts/mkflags.c
@@ -122,10 +122,14 @@ int main(int argc, char *argv[])
char *gaps, *mgaps, c;
unsigned bit;
- *command = 0;
+ *command = *flags = *allflags = 0;
bit = fscanf(stdin, "%255s \"%1023[^\"]\" \"%1023[^\"]\"\n",
command, flags, allflags);
+ if (getenv("DEBUG"))
+ fprintf(stderr, "command=%s, flags=%s, allflags=%s\n",
+ command, flags, allflags);
+
if (!*command) break;
if (bit != 3) {
fprintf(stderr, "\nError in %s (duplicate command?)\n", command);
@@ -182,8 +186,7 @@ int main(int argc, char *argv[])
if (flist) flist = flist->next;
}
} else if (aflist->command) {
- if (flist && (!aflist->command || *aflist->command == *flist->command))
- {
+ if (flist && (!flist->command || *aflist->command == *flist->command)) {
if (aflist->command)
sprintf(out, "#define FLAG_%c (1<<%d)\n", *aflist->command, bit);
flist = flist->next;