summaryrefslogtreecommitdiffstats
path: root/gl/lib/argp-help.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/lib/argp-help.c')
-rw-r--r--gl/lib/argp-help.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/gl/lib/argp-help.c b/gl/lib/argp-help.c
index c509c0c..aa8cc70 100644
--- a/gl/lib/argp-help.c
+++ b/gl/lib/argp-help.c
@@ -1,5 +1,5 @@
/* Hierarchical argument parsing help output
- Copyright (C) 1995-2023 Free Software Foundation, Inc.
+ Copyright (C) 1995-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -175,7 +175,7 @@ fill_in_uparams (const struct argp_state *state)
const char *var = getenv ("ARGP_HELP_FMT");
struct uparams new_params = uparams;
-#define SKIPWS(p) do { while (isspace ((unsigned char) *p)) p++; } while (0);
+#define SKIPWS(p) do { while (isspace ((unsigned char) *p)) p++; } while (0)
if (var)
{
@@ -432,8 +432,8 @@ struct hol
{
/* An array of hol_entry's. */
struct hol_entry *entries;
- /* The number of entries in this hol. If this field is zero, the others
- are undefined. */
+ /* The number of entries in this hol. If this field is zero, entries and
+ short_options are undefined. */
unsigned num_entries;
/* A string containing all short options in this HOL. Each entry contains
@@ -459,7 +459,7 @@ make_hol (const struct argp *argp, struct hol_cluster *cluster)
assert (hol);
hol->num_entries = 0;
- hol->clusters = 0;
+ hol->clusters = NULL;
if (opts)
{
@@ -644,7 +644,7 @@ hol_entry_first_long (const struct hol_entry *entry)
for (opt = entry->opt, num = entry->num; num > 0; opt++, num--)
if (opt->name && ovisible (opt))
return opt->name;
- return 0;
+ return NULL;
}
/* Returns the entry in HOL with the long option name NAME, or NULL if there is
@@ -652,24 +652,29 @@ hol_entry_first_long (const struct hol_entry *entry)
static struct hol_entry *
hol_find_entry (struct hol *hol, const char *name)
{
- struct hol_entry *entry = hol->entries;
unsigned num_entries = hol->num_entries;
- while (num_entries-- > 0)
+ if (num_entries > 0)
{
- const struct argp_option *opt = entry->opt;
- unsigned num_opts = entry->num;
+ struct hol_entry *entry = hol->entries;
+
+ do
+ {
+ const struct argp_option *opt = entry->opt;
+ unsigned num_opts = entry->num;
- while (num_opts-- > 0)
- if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0)
- return entry;
- else
- opt++;
+ while (num_opts-- > 0)
+ if (opt->name && ovisible (opt) && strcmp (opt->name, name) == 0)
+ return entry;
+ else
+ opt++;
- entry++;
+ entry++;
+ }
+ while (--num_entries > 0);
}
- return 0;
+ return NULL;
}
/* If an entry with the long option NAME occurs in HOL, set its special
@@ -950,7 +955,7 @@ hol_append (struct hol *hol, struct hol *more)
while (*cl_end)
cl_end = &(*cl_end)->next;
*cl_end = more->clusters;
- more->clusters = 0;
+ more->clusters = NULL;
/* Merge entries. */
if (more->num_entries > 0)
@@ -1322,7 +1327,7 @@ hol_entry_help (struct hol_entry *entry, const struct argp_state *state,
{
const char *tstr = real->doc ? dgettext (state == NULL ? NULL
: entry->argp->argp_domain,
- real->doc) : 0;
+ real->doc) : NULL;
const char *fstr = filter_doc (tstr, real->key, entry->argp, state);
if (fstr && *fstr)
{
@@ -1484,7 +1489,7 @@ hol_usage (struct hol *hol, argp_fmtstream_t stream)
entry->argp->argp_domain, &snao_end);
if (snao_end > short_no_arg_opts)
{
- *snao_end++ = 0;
+ *snao_end++ = '\0';
__argp_fmtstream_printf (stream, " [-%s]", short_no_arg_opts);
}
@@ -1598,7 +1603,7 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
{
const char *text;
const char *inp_text;
- void *input = 0;
+ void *input = NULL;
int anything = 0;
size_t inp_text_limit = 0;
const char *doc = argp->doc ? dgettext (argp->argp_domain, argp->doc) : NULL;
@@ -1686,7 +1691,7 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
unsigned flags, char *name)
{
int anything = 0; /* Whether we've output anything. */
- struct hol *hol = 0;
+ struct hol *hol = NULL;
argp_fmtstream_t fs;
if (! stream)