and translate the two parts separately, instead of feeding
the whole string to gettext. This allows to exclude
'\v' from the strings visible to the translator by writing doc
strings as N_("..") "\v" N_("..").
{
const char *text;
const char *inp_text;
{
const char *text;
const char *inp_text;
+ size_t inp_text_len = 0;
void *input = 0;
int anything = 0;
void *input = 0;
int anything = 0;
- size_t inp_text_limit = 0;
- const char *doc = dgettext (argp->argp_domain, argp->doc);
const struct argp_child *child = argp->children;
const struct argp_child *child = argp->children;
- char *vt = strchr (doc, '\v');
- inp_text = post ? (vt ? vt + 1 : 0) : doc;
- inp_text_limit = (!post && vt) ? (vt - doc) : 0;
+ char *vt = strchr (argp->doc, '\v');
+ if (vt)
+ {
+ if (post)
+ inp_text = vt + 1;
+ else
+ {
+ inp_text_len = vt - argp->doc;
+ inp_text = __strndup (argp->doc, inp_text_len);
+ }
+ }
+ else
+ inp_text = dgettext (argp->argp_domain, post ? 0 : argp->doc);
if (argp->help_filter)
/* We have to filter the doc strings. */
{
if (argp->help_filter)
/* We have to filter the doc strings. */
{
- if (inp_text_limit)
- /* Copy INP_TEXT so that it's nul-terminated. */
- inp_text = __strndup (inp_text, inp_text_limit);
input = __argp_input (argp, state);
text =
(*argp->help_filter) (post
input = __argp_input (argp, state);
text =
(*argp->help_filter) (post
if (pre_blank)
__argp_fmtstream_putc (stream, '\n');
if (pre_blank)
__argp_fmtstream_putc (stream, '\n');
- if (text == inp_text && inp_text_limit)
- __argp_fmtstream_write (stream, inp_text, inp_text_limit);
- else
- __argp_fmtstream_puts (stream, text);
+ __argp_fmtstream_puts (stream, text);
if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream))
__argp_fmtstream_putc (stream, '\n');
if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream))
__argp_fmtstream_putc (stream, '\n');
if (text && text != inp_text)
free ((char *) text); /* Free TEXT returned from the help filter. */
if (text && text != inp_text)
free ((char *) text); /* Free TEXT returned from the help filter. */
- if (inp_text && inp_text_limit && argp->help_filter)
+
+ if (inp_text && inp_text_len)
free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */
if (post && argp->help_filter)
free ((char *) inp_text); /* We copied INP_TEXT, so free it now. */
if (post && argp->help_filter)