Stephen Boyd schrieb: > On Wed, Jun 3, 2009 at 3:18 AM, René Scharfe<rene.scharfe@xxxxxxxxxxxxxx> wrote: >> By the way, can the switch be replaced by a simple check for >> PARSE_OPT_NOARG now? >> > > This looks possible. I think just set PARSE_OPT_NOARG as the flag of > the appropriate OPT_* macros. I'll have to grep the tree for custom > uses of OPTION_* though. Yes, it's only worthwhile if there aren't too many special cases that require explicit setting of PARSE_OPT_NOARG. > > Should that be all squashed together? Or maybe that could be a follow up patch? Your existing patch looks fine as is, I'd keep additional changes separate. Hmm, and how about the following in between them? parse-options.c | 16 +++------------- 1 files changed, 3 insertions(+), 13 deletions(-) diff --git a/parse-options.c b/parse-options.c index b85cab2..dda36b1 100644 --- a/parse-options.c +++ b/parse-options.c @@ -440,7 +440,7 @@ int parse_options(int argc, const char **argv, const char *prefix, static int usage_argh(const struct option *opts) { const char *s; - int literal = opts->flags & PARSE_OPT_LITERAL_ARGHELP; + int literal = (opts->flags & PARSE_OPT_LITERAL_ARGHELP) || !opt->argh; if (opts->flags & PARSE_OPT_OPTARG) if (opts->long_name) s = literal ? "[=%s]" : "[=<%s>]"; @@ -448,7 +448,7 @@ static int usage_argh(const struct option *opts) s = literal ? "[%s]" : "[<%s>]"; else s = literal ? " %s" : " <%s>"; - return fprintf(stderr, s, opts->argh); + return fprintf(stderr, s, opt->argh ? opt->argh : "..."); } #define USAGE_OPTS_WIDTH 24 @@ -519,17 +519,7 @@ int usage_with_options_internal(const char * const *usagestr, case OPTION_FILENAME: /* FALLTHROUGH */ case OPTION_STRING: - if (opts->argh) - pos += usage_argh(opts); - else { - if (opts->flags & PARSE_OPT_OPTARG) - if (opts->long_name) - pos += fprintf(stderr, "[=...]"); - else - pos += fprintf(stderr, "[...]"); - else - pos += fprintf(stderr, " ..."); - } + pos += usage_argh(opts); break; default: /* OPTION_{BIT,BOOLEAN,NUMBER,SET_INT,SET_PTR} */ break; -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html