aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-05-10 13:06:31 -0500
committerRob Landley <rob@landley.net>2014-05-10 13:06:31 -0500
commit3a41541347e2b404964964072fa70dfe85639b81 (patch)
treecb45b36f075d047253b92798caab5c0014e63d05 /scripts
parent48c172ba589cfd848624b51f6f748b56bc217775 (diff)
downloadtoybox-3a41541347e2b404964964072fa70dfe85639b81.tar.gz
Catch duplicate command name (which breaks the build already, but doesn't identify the culprit).
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mkflags.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/scripts/mkflags.c b/scripts/mkflags.c
index 001007ef..23cb83e8 100644
--- a/scripts/mkflags.c
+++ b/scripts/mkflags.c
@@ -44,7 +44,8 @@ struct flag *digest(char *string)
blank->lopt = new;
list = blank;
}
- while (*++string != ')') if (*string == '-') *string = '_'; // An empty longopt () would break this.
+ // An empty longopt () would break this.
+ while (*++string != ')') if (*string == '-') *string = '_';
*(string++) = 0;
continue;
}
@@ -80,11 +81,19 @@ int main(int argc, char *argv[])
for (;;) {
struct flag *flist, *aflist, *offlist;
- unsigned bit = 0;
+ unsigned bit;
- if (3 != fscanf(stdin, "%255s \"%1023[^\"]\" \"%1023[^\"]\"\n",
- command, flags, allflags)) break;
+ *command = 0;
+ bit = fscanf(stdin, "%255s \"%1023[^\"]\" \"%1023[^\"]\"\n",
+ command, flags, allflags);
+ if (!*command) break;
+ if (bit != 3) {
+ fprintf(stderr, "\nError in %s (duplicate command?)\n", command);
+ exit(1);
+ }
+
+ bit = 0;
printf("// %s %s %s\n", command, flags, allflags);
flist = digest(flags);