/* 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);
}
static const char *next_opt(const char *p, unsigned *i, unsigned *len)
{
- if (!p)
- (*i)++;
for (; *i < opt_count; (*i)++) {
if (opt_table[*i].flags == OPT_SUBTABLE)
continue;
assert(*p != '?');
}
}
+ /* Don't document args unless there are some. */
+ if (entry->flags == OPT_NOARG)
+ assert(p[len] != ' ' && p[len] != '=');
}
}
strcspn(longopt, "/"), longopt, problem);
}
-void dump_optstate(void);
-void dump_optstate(void)
-{
- printf("opterr = %i, optind = %i, optopt = %i, optarg = %s\n",
- opterr, optind, optopt, optarg);
-}
-
/* Parse your arguments. */
bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...))
{