Re: [PATCHv2 1/2] parse-options: add PARSE_OPT_LITERAL_ARGHELP for complicated argh's

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCHv2 1/2] parse-options: add PARSE_OPT_LITERAL_ARGHELP for complicated argh's

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:48

Stephen Boyd [off-list ref] writes:
I've decided to appease the pirate haters :-)
Hmmm, why does this break t0040 (I am queuing this on top of 5acb3e5)?

Re: [PATCHv2 1/2] parse-options: add PARSE_OPT_LITERAL_ARGHELP for complicated argh's

From: René Scharfe <hidden>
Date: 2016-06-15 22:46:48

Junio C Hamano schrieb:
Stephen Boyd [off-list ref] writes:
quoted
I've decided to appease the pirate haters :-)
Hmmm, why does this break t0040 (I am queuing this on top of 5acb3e5)?
Probably because it changes this:

	pos += fprintf(...);

into this (simplified, usage_argh() expanded):

	pos += pos + fprintf(...);

usage_argh() doesn't need the parameter pos.

René

Re: [PATCHv2 1/2] parse-options: add PARSE_OPT_LITERAL_ARGHELP for complicated argh's

From: Stephen Boyd <hidden>
Date: 2016-06-15 22:46:48

On Thu, May 21, 2009 at 9:51 AM, René Scharfe
[off-list ref] wrote:
Junio C Hamano schrieb:
quoted
Hmmm, why does this break t0040 (I am queuing this on top of 5acb3e5)?
Probably because it changes this:

       pos += fprintf(...);

into this (simplified, usage_argh() expanded):

       pos += pos + fprintf(...);

usage_argh() doesn't need the parameter pos.

René
Woops. I thought I ran the tests but I guess I didn't. This is the
correct fix, thanks.

Re: [PATCHv2 1/2] parse-options: add PARSE_OPT_LITERAL_ARGHELP for complicated argh's

From: Stephen Boyd <hidden>
Date: 2016-06-15 22:46:48

Stephen Boyd wrote:
On Thu, May 21, 2009 at 9:51 AM, René Scharfe
[off-list ref] wrote:
quoted
Junio C Hamano schrieb:
quoted
Hmmm, why does this break t0040 (I am queuing this on top of 5acb3e5)?
Probably because it changes this:

       pos += fprintf(...);

into this (simplified, usage_argh() expanded):

       pos += pos + fprintf(...);

usage_argh() doesn't need the parameter pos.

René
Woops. I thought I ran the tests but I guess I didn't. This is the
correct fix, thanks.
And here's the patch you can squash in.
diff --git a/parse-options.c b/parse-options.c
index 2b880b1..e8955be 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -361,7 +361,7 @@ int parse_options(int argc, const char **argv, const struct option *options,
        return parse_options_end(&ctx);
 }

-static int usage_argh(const struct option *opts, int pos)
+static int usage_argh(const struct option *opts)
 {
        const char *s;
        int literal = opts->flags & PARSE_OPT_LITERAL_ARGHELP;
@@ -372,7 +372,7 @@ static int usage_argh(const struct option *opts, int pos)
                        s = literal ? "[%s]" : "[<%s>]";
        else
                s = literal ? " %s" : " <%s>";
-       return pos + fprintf(stderr, s, opts->argh);
+       return fprintf(stderr, s, opts->argh);
 }

 #define USAGE_OPTS_WIDTH 24
@@ -436,7 +436,7 @@ int usage_with_options_internal(const char * const *usagestr,
                        /* FALLTHROUGH */
                case OPTION_STRING:
                        if (opts->argh)
-                               pos += usage_argh(opts, pos);
+                               pos += usage_argh(opts);
                        else {
                                if (opts->flags & PARSE_OPT_OPTARG)
                                        if (opts->long_name)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help