X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fopt%2Fopt.c;fp=ccan%2Fopt%2Fopt.c;h=e7ebc3dd0550e2181b13c41438ddeb9e8f244dff;hp=a5180706c45e28e52394411ad5ff271f10cdeb2c;hb=f4b1f445a7b21b1599530afb897ef54efe15479d;hpb=f20e4f235ac89f3901f248f91c3ac5a33088349d diff --git a/ccan/opt/opt.c b/ccan/opt/opt.c index a5180706..e7ebc3dd 100644 --- a/ccan/opt/opt.c +++ b/ccan/opt/opt.c @@ -17,14 +17,14 @@ const char *opt_argv0; /* Returns string after first '-'. */ static const char *first_name(const char *names, unsigned *len) { - *len = strcspn(names + 1, "/"); + *len = strcspn(names + 1, "/= "); return names + 1; } static const char *next_name(const char *names, unsigned *len) { names += *len; - if (!names[0]) + if (names[0] == ' ' || names[0] == '=' || names[0] == '\0') return NULL; return first_name(names + 1, len); } @@ -124,6 +124,9 @@ static void check_opt(const struct opt_table *entry) assert(*p != '?'); } } + /* Don't document args unless there are some. */ + if (entry->flags == OPT_NOARG) + assert(p[len] != ' ' && p[len] != '='); } }