Mercurial > hg > toybox
changeset 1277:23817e1675f2 draft
Catch duplicate command name (which breaks the build already, but doesn't identify the culprit).
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 10 May 2014 13:06:31 -0500 |
parents | d48bdc1cb017 |
children | 324306321d82 |
files | scripts/mkflags.c |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/mkflags.c Tue May 06 06:31:28 2014 -0500 +++ b/scripts/mkflags.c Sat May 10 13:06:31 2014 -0500 @@ -44,7 +44,8 @@ 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 @@ for (;;) { struct flag *flist, *aflist, *offlist; - unsigned bit = 0; + unsigned bit; + + *command = 0; + bit = fscanf(stdin, "%255s \"%1023[^\"]\" \"%1023[^\"]\"\n", + command, flags, allflags); - if (3 != fscanf(stdin, "%255s \"%1023[^\"]\" \"%1023[^\"]\"\n", - command, flags, allflags)) break; + 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);