From: Matthieu Moy Date: Wed, 28 Jul 2010 07:38:45 GMT Subject: Re: [PATCH 1/4] Allow detached form (e.g. "-S foo" instead of "-Sfoo") for diff options Message-ID: In-Reply-To: <20100727213750.GB11768@burratino> Jonathan Nieder writes: > Matthieu Moy wrote: > >> +++ b/diff.c >> @@ -2990,9 +2990,23 @@ static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *va > [...] >> +#define IF_SHORT_OPT(optname) \ >> + ((!strcmp(arg, "-" #optname) \ >> + && (argv[1] || (die("Option `" #optname "' requires a value"), 1), \ >> + optarg = argv[1], \ >> + argcount = 2, \ >> + 1)) || \ >> + (!prefixcmp(arg, "-" #optname) \ >> + && (optarg = arg + strlen("-" #optname), \ >> + argcount = 1, \ >> + 1))) >> + > > Why not something like this? > > static inline int short_opt(char opt, const char *arg, > const char *argv, const char **optarg) Sounds nice too. I'll do that in the next round. -- Matthieu Moy http://www-verimag.imag.fr/~moy/