From 3a41541347e2b404964964072fa70dfe85639b81 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 10 May 2014 13:06:31 -0500 Subject: Catch duplicate command name (which breaks the build already, but doesn't identify the culprit). --- scripts/mkflags.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'scripts/mkflags.c') 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); -- cgit v1.2.3