diff options
author | Rob Landley <rob@landley.net> | 2014-05-10 13:06:31 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-05-10 13:06:31 -0500 |
commit | 3a41541347e2b404964964072fa70dfe85639b81 (patch) | |
tree | cb45b36f075d047253b92798caab5c0014e63d05 | |
parent | 48c172ba589cfd848624b51f6f748b56bc217775 (diff) | |
download | toybox-3a41541347e2b404964964072fa70dfe85639b81.tar.gz |
Catch duplicate command name (which breaks the build already, but doesn't identify the culprit).
-rw-r--r-- | scripts/mkflags.c | 17 |
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); |