Subject: Re: [PATCH 1/4] Allow detached form (e.g. "-S foo" instead of "-Sfoo") for diff options

From: Matthieu Moy <[email-masked]>
Date: Wed, 28 Jul 2010 09:38:45 +0200

Jonathan Nieder <[email-masked]> 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/