[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] Patch to argp
From: |
Sergey Poznyakoff |
Subject: |
[Bug-gnulib] Patch to argp |
Date: |
Sun, 19 Sep 2004 11:44:45 +0300 |
Hello,
Attached is the patch that fixes a couple of bugs discovered recently in
argp.
The ChangeLog entry:
2004-09-19 Sergey Poznyakoff <address@hidden>
* lib/argp-help.c (canon_doc_option): Fixed coredump if *name==NULL
(hol_entry_help): Never translate an empty string.
Do not translate option tag (opt->name) if OPTION_NO_TRANS is set
* lib/argp.h (OPTION_NO_TRANS): New option
Paul, may I have write access to the repository?
Regards,
Sergey
Index: lib/argp-help.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/argp-help.c,v
retrieving revision 1.11
diff -p -u -r1.11 argp-help.c
--- lib/argp-help.c 12 Aug 2004 07:57:07 -0000 1.11
+++ lib/argp-help.c 19 Sep 2004 08:35:06 -0000
@@ -228,6 +228,9 @@ fill_in_uparams (const struct argp_state
/* Returns true if OPT is an documentation-only entry. */
#define odoc(opt) ((opt)->flags & OPTION_DOC)
+/* Returns true if OPT should not be translated */
+#define onotrans(opt) ((opt)->flags & OPTION_NO_TRANS)
+
/* Returns true if OPT is the end-of-list marker for a list of options. */
#define oend(opt) __option_is_end (opt)
@@ -676,14 +679,20 @@ static int
canon_doc_option (const char **name)
{
int non_opt;
- /* Skip initial whitespace. */
- while (isspace (**name))
- (*name)++;
- /* Decide whether this looks like an option (leading `-') or not. */
- non_opt = (**name != '-');
- /* Skip until part of name used for sorting. */
- while (**name && !isalnum (**name))
- (*name)++;
+
+ if (!*name)
+ non_opt = 1;
+ else
+ {
+ /* Skip initial whitespace. */
+ while (isspace (**name))
+ (*name)++;
+ /* Decide whether this looks like an option (leading `-') or not. */
+ non_opt = (**name != '-');
+ /* Skip until part of name used for sorting. */
+ while (**name && !isalnum (**name))
+ (*name)++;
+ }
return non_opt;
}
@@ -1081,13 +1090,15 @@ hol_entry_help (struct hol_entry *entry,
{
__argp_fmtstream_set_wmargin (stream, uparams.doc_opt_col);
for (opt = real, num = entry->num; num > 0; opt++, num--)
- if (opt->name && ovisible (opt))
+ if (opt->name && *opt->name && ovisible (opt))
{
comma (uparams.doc_opt_col, &pest);
- /* Calling gettext here isn't quite right, since sorting will
+ /* Calling dgettext here isn't quite right, since sorting will
have been done on the original; but documentation options
should be pretty rare anyway... */
__argp_fmtstream_puts (stream,
+ onotrans (opt) ?
+ opt->name :
dgettext (state->root_argp->argp_domain,
opt->name));
}
Index: lib/argp.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/argp.h,v
retrieving revision 1.7
diff -p -u -r1.7 argp.h
--- lib/argp.h 8 Sep 2004 13:31:45 -0000 1.7
+++ lib/argp.h 19 Sep 2004 08:35:06 -0000
@@ -126,11 +126,12 @@ struct argp_option
should be displayed in much the same manner as the options. If this flag
is set, then the option NAME field is displayed unmodified (e.g., no `--'
prefix is added) at the left-margin (where a *short* option would normally
- be displayed), and the documentation string in the normal place. For
- purposes of sorting, any leading whitespace and punctuation is ignored,
- except that if the first non-whitespace character is not `-', this entry
- is displayed after all options (and OPTION_DOC entries with a leading `-')
- in the same group. */
+ be displayed), and the documentation string in the normal place. The NAME
+ field will be translated using gettext, unless OPTION_NO_TRANS is set (see
+ below). For purposes of sorting, any leading whitespace and punctuation is
+ ignored, except that if the first non-whitespace character is not `-', this
+ entry is displayed after all options (and OPTION_DOC entries with a leading
+ `-') in the same group. */
#define OPTION_DOC 0x8
/* This option shouldn't be included in `long' usage messages (but is still
@@ -141,6 +142,11 @@ struct argp_option
distinguish these two cases, -x should probably be marked
OPTION_NO_USAGE. */
#define OPTION_NO_USAGE 0x10
+
+/* Valid only in conjunction with OPTION_DOC. This option disables translation
+ of option name. */
+#define OPTION_NO_TRANS 0x20
+
struct argp; /* fwd declare this type */
struct argp_state; /* " */
- [Bug-gnulib] Patch to argp,
Sergey Poznyakoff <=