Bruno Haible <[EMAIL PROTECTED]> wrote:

> Paul Eggert wrote:
>> First, human_options should probably not output to stderr or exit, but
>> should instead let the caller do it.
>
> Indeed; this allows to not increase the number of arguments to
> human_options from 3 to 4.
>
>> +static char opt_str_storage[3] = {'-', 0, 0};
>> +#define OPT_STR(opt_idx, c, long_options)   \
>> +  ((opt_idx) < 0                            \
>> +   ? (opt_str_storage[1] = c, opt_str_storage)      \
>> +   : LONG_OPT_STR (opt_idx, long_options))
>
> I would not put a statically allocated array into every compilation unit
> that includes "system.h". In fact, the middle part of OPT_STR does not need
> to be a macro or inline function; it can as well be a plain function:
>
> #define OPT_STR(opt_idx, c, long_options)     \
>   ((opt_idx) < 0                              \
>    ? short_opt_str (c)                                \
>    : LONG_OPT_STR (opt_idx, long_options))
>
> /* Define in a .c file. */
> const char *
> short_opt_str (char c)
> {
>   static char opt_str_storage[3] = { '-', 0, 0 };
>   opt_str_storage[1] = c;
>   return opt_str_storage)
> }

Yep.  I might put that in a separate file eventually, but for
now, adding a file just for that tiny function isn't worth it.
I've encapsulated it in a static inline function in system.h,
as I suggested initially.  Changes just pushed:

  http://git.sv.gnu.org/gitweb/?p=coreutils.git


Reply via email to