On 11/25/12 14:51, Nikos Mavrogiannopoulos wrote:
> Hello,
> I noticed that in windows the help string of my program is something like:
> -v, --$s$s Output version information and exit
> -h, --$s$s Display extended usage information and exit
>
> The offending code seems to be the string "--%2$s%1$s\0" in usage-txt.h
> and the 2$ and 1$ operators. I couldn't quite get the logic in order to
> simplify it, but if it could be avoided it would fix the --help option
> on that system.
Nope. It isn't in autogen's library where this happens.
It is in "print_one_usage()":
static void
prt_one_usage(tOptions * pOptions, tOptDesc * pOD, arg_types_t * pAT)
{
prt_preamble(pOptions, pOD, pAT);
[...]
snprintf(z, sizeof(z), pAT->pzOptFmt, pzArgType, pOD->pz_Name,
(pOD->optMinCt != 0) ? pAT->pzReq : pAT->pzOpt);
fprintf(option_usage_fp, line_fmt_buf, z, pOD->pzText);
The whole machination is about not having to know if you are printing
a format for a long option, a short option, an option without hyphen
introductions or options in GNU format or in the more elaborate
"autoopts native" format. (This is allowed when all command line
arguments must be options.) So "pzOptFmt" will point to one of these:
"%s"
"--%2$s%1$s"
"%2$s%1$s"
" %3s %s"
" %3s %-14s %s"
So there needs to be some windows only code that checks the value of
"pAT->pzOptFmt":
#ifdef WINDOWS
if (pAT->pzOptFmt == zGnuOptFmt)
snprintf(z, sizeof(z), "--%s%s", pOD->pz_Name, pzArgType);
else if (pAT->pzOptFmt == zGnuOptFmt + 2)
snprintf(z, sizeof(z), "%s%s", pOD->pz_Name, pzArgType);
else
#endif
snprintf(z, sizeof(z), pAT->pzOptFmt, pzArgType, pOD->pz_Name,
(pOD->optMinCt != 0) ? pAT->pzReq : pAT->pzOpt);
Ick. If you confirm the hack, I'll put it out for the next release.
|