/* 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;
}
const char *first_sopt(unsigned *i)
{
const char *p;
- unsigned int len;
+ unsigned int len = 0 /* GCC bogus warning */;
for (p = first_opt(i, &len); p; p = next_opt(p, i, &len)) {
if (p[0] != '-')
static struct option *make_options(void)
{
struct option *options = malloc(sizeof(*options) * (opt_num_long + 1));
- unsigned int i, num = 0, len;
+ unsigned int i, num = 0, len = 0 /* GCC bogus warning */;
const char *p;
for (p = first_lopt(&i, &len); p; p = next_lopt(p, &i, &len)) {
errlog("%s: -%c: %s", opt_argv0, shortopt, problem);
else
errlog("%s: --%.*s: %s", opt_argv0,
- strcspn(longopt, "/"), longopt, problem);
+ strcspn(longopt, "|"), longopt, problem);
}
/* Parse your arguments. */
while ((ret = getopt_long(*argc, argv, optstring, options, &longidx))
!= -1) {
char *problem;
- const char *name;
+ const char *name = NULL; /* GCC bogus warning */
/* optopt is 0 if it's an unknown long option, *or* if
* -? is a valid short option. */
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
va_end(ap);
}
+void opt_log_stderr_exit(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+ exit(1);
+}
+
char *opt_invalid_argument(const char *arg)
{
char *str = malloc(sizeof("Invalid argument '%s'") + strlen(arg));