mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Update.
* argp/argp-help.c: Likewise. * argp/argp-parse.c: Likewise.
This commit is contained in:
@ -19,6 +19,8 @@
|
|||||||
* stdlib/strtol.c: Likewise.
|
* stdlib/strtol.c: Likewise.
|
||||||
* string/strcoll.c: Likewise.
|
* string/strcoll.c: Likewise.
|
||||||
* string/strxfrm.c: Likewise.
|
* string/strxfrm.c: Likewise.
|
||||||
|
* argp/argp-help.c: Likewise.
|
||||||
|
* argp/argp-parse.c: Likewise.
|
||||||
|
|
||||||
1998-09-07 09:58 Ulrich Drepper <drepper@cygnus.com>
|
1998-09-07 09:58 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
156
argp/argp-help.c
156
argp/argp-help.c
@ -800,63 +800,65 @@ hol_append (struct hol *hol, struct hol *more)
|
|||||||
|
|
||||||
/* Merge entries. */
|
/* Merge entries. */
|
||||||
if (more->num_entries > 0)
|
if (more->num_entries > 0)
|
||||||
if (hol->num_entries == 0)
|
{
|
||||||
{
|
if (hol->num_entries == 0)
|
||||||
hol->num_entries = more->num_entries;
|
{
|
||||||
hol->entries = more->entries;
|
hol->num_entries = more->num_entries;
|
||||||
hol->short_options = more->short_options;
|
hol->entries = more->entries;
|
||||||
more->num_entries = 0; /* Mark MORE's fields as invalid. */
|
hol->short_options = more->short_options;
|
||||||
}
|
more->num_entries = 0; /* Mark MORE's fields as invalid. */
|
||||||
else
|
}
|
||||||
/* Append the entries in MORE to those in HOL, taking care to only add
|
else
|
||||||
non-shadowed SHORT_OPTIONS values. */
|
/* Append the entries in MORE to those in HOL, taking care to only add
|
||||||
{
|
non-shadowed SHORT_OPTIONS values. */
|
||||||
unsigned left;
|
{
|
||||||
char *so, *more_so;
|
unsigned left;
|
||||||
struct hol_entry *e;
|
char *so, *more_so;
|
||||||
unsigned num_entries = hol->num_entries + more->num_entries;
|
struct hol_entry *e;
|
||||||
struct hol_entry *entries =
|
unsigned num_entries = hol->num_entries + more->num_entries;
|
||||||
malloc (num_entries * sizeof (struct hol_entry));
|
struct hol_entry *entries =
|
||||||
unsigned hol_so_len = strlen (hol->short_options);
|
malloc (num_entries * sizeof (struct hol_entry));
|
||||||
char *short_options =
|
unsigned hol_so_len = strlen (hol->short_options);
|
||||||
malloc (hol_so_len + strlen (more->short_options) + 1);
|
char *short_options =
|
||||||
|
malloc (hol_so_len + strlen (more->short_options) + 1);
|
||||||
|
|
||||||
__mempcpy (__mempcpy (entries, hol->entries,
|
__mempcpy (__mempcpy (entries, hol->entries,
|
||||||
hol->num_entries * sizeof (struct hol_entry)),
|
hol->num_entries * sizeof (struct hol_entry)),
|
||||||
more->entries,
|
more->entries,
|
||||||
more->num_entries * sizeof (struct hol_entry));
|
more->num_entries * sizeof (struct hol_entry));
|
||||||
|
|
||||||
__mempcpy (short_options, hol->short_options, hol_so_len);
|
__mempcpy (short_options, hol->short_options, hol_so_len);
|
||||||
|
|
||||||
/* Fix up the short options pointers from HOL. */
|
/* Fix up the short options pointers from HOL. */
|
||||||
for (e = entries, left = hol->num_entries; left > 0; e++, left--)
|
for (e = entries, left = hol->num_entries; left > 0; e++, left--)
|
||||||
e->short_options += (short_options - hol->short_options);
|
e->short_options += (short_options - hol->short_options);
|
||||||
|
|
||||||
/* Now add the short options from MORE, fixing up its entries too. */
|
/* Now add the short options from MORE, fixing up its entries too. */
|
||||||
so = short_options + hol_so_len;
|
so = short_options + hol_so_len;
|
||||||
more_so = more->short_options;
|
more_so = more->short_options;
|
||||||
for (left = more->num_entries; left > 0; e++, left--)
|
for (left = more->num_entries; left > 0; e++, left--)
|
||||||
{
|
{
|
||||||
int opts_left;
|
int opts_left;
|
||||||
const struct argp_option *opt;
|
const struct argp_option *opt;
|
||||||
|
|
||||||
e->short_options = so;
|
e->short_options = so;
|
||||||
|
|
||||||
for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--)
|
for (opts_left = e->num, opt = e->opt; opts_left; opt++, opts_left--)
|
||||||
{
|
{
|
||||||
int ch = *more_so;
|
int ch = *more_so;
|
||||||
if (oshort (opt) && ch == opt->key)
|
if (oshort (opt) && ch == opt->key)
|
||||||
/* The next short option in MORE_SO, CH, is from OPT. */
|
/* The next short option in MORE_SO, CH, is from OPT. */
|
||||||
{
|
{
|
||||||
if (! find_char (ch, short_options,
|
if (! find_char (ch, short_options,
|
||||||
short_options + hol_so_len))
|
short_options + hol_so_len))
|
||||||
/* The short option CH isn't shadowed by HOL's options,
|
/* The short option CH isn't shadowed by HOL's options,
|
||||||
so add it to the sum. */
|
so add it to the sum. */
|
||||||
*so++ = ch;
|
*so++ = ch;
|
||||||
more_so++;
|
more_so++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*so = '\0';
|
*so = '\0';
|
||||||
|
|
||||||
@ -900,10 +902,14 @@ arg (const struct argp_option *real, const char *req_fmt, const char *opt_fmt,
|
|||||||
const char *domain, argp_fmtstream_t stream)
|
const char *domain, argp_fmtstream_t stream)
|
||||||
{
|
{
|
||||||
if (real->arg)
|
if (real->arg)
|
||||||
if (real->flags & OPTION_ARG_OPTIONAL)
|
{
|
||||||
__argp_fmtstream_printf (stream, opt_fmt, dgettext (domain, real->arg));
|
if (real->flags & OPTION_ARG_OPTIONAL)
|
||||||
else
|
__argp_fmtstream_printf (stream, opt_fmt,
|
||||||
__argp_fmtstream_printf (stream, req_fmt, dgettext (domain, real->arg));
|
dgettext (domain, real->arg));
|
||||||
|
else
|
||||||
|
__argp_fmtstream_printf (stream, req_fmt,
|
||||||
|
dgettext (domain, real->arg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper functions for hol_entry_help. */
|
/* Helper functions for hol_entry_help. */
|
||||||
@ -1245,16 +1251,18 @@ usage_long_opt (const struct argp_option *opt,
|
|||||||
arg = real->arg;
|
arg = real->arg;
|
||||||
|
|
||||||
if (! (flags & OPTION_NO_USAGE))
|
if (! (flags & OPTION_NO_USAGE))
|
||||||
if (arg)
|
{
|
||||||
{
|
if (arg)
|
||||||
arg = dgettext (domain, arg);
|
{
|
||||||
if (flags & OPTION_ARG_OPTIONAL)
|
arg = dgettext (domain, arg);
|
||||||
__argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg);
|
if (flags & OPTION_ARG_OPTIONAL)
|
||||||
else
|
__argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg);
|
||||||
__argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg);
|
else
|
||||||
}
|
__argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg);
|
||||||
else
|
}
|
||||||
__argp_fmtstream_printf (stream, " [--%s]", opt->name);
|
else
|
||||||
|
__argp_fmtstream_printf (stream, " [--%s]", opt->name);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1385,16 +1393,18 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
|
|||||||
advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream);
|
advance = !argp_args_usage ((child++)->argp, state, levels, advance, stream);
|
||||||
|
|
||||||
if (advance && multiple)
|
if (advance && multiple)
|
||||||
/* Need to increment our level. */
|
{
|
||||||
if (*nl)
|
/* Need to increment our level. */
|
||||||
/* There's more we can do here. */
|
if (*nl)
|
||||||
{
|
/* There's more we can do here. */
|
||||||
(*our_level)++;
|
{
|
||||||
advance = 0; /* Our parent shouldn't advance also. */
|
(*our_level)++;
|
||||||
}
|
advance = 0; /* Our parent shouldn't advance also. */
|
||||||
else if (*our_level > 0)
|
}
|
||||||
/* We had multiple levels, but used them up; reset to zero. */
|
else if (*our_level > 0)
|
||||||
*our_level = 0;
|
/* We had multiple levels, but used them up; reset to zero. */
|
||||||
|
*our_level = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return !advance;
|
return !advance;
|
||||||
}
|
}
|
||||||
|
@ -605,39 +605,43 @@ parser_finalize (struct parser *parser,
|
|||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
if (! err)
|
if (! err)
|
||||||
if (parser->state.next == parser->state.argc)
|
{
|
||||||
/* We successfully parsed all arguments! Call all the parsers again,
|
if (parser->state.next == parser->state.argc)
|
||||||
just a few more times... */
|
/* We successfully parsed all arguments! Call all the parsers again,
|
||||||
{
|
just a few more times... */
|
||||||
for (group = parser->groups;
|
{
|
||||||
group < parser->egroup && (!err || err==EBADKEY);
|
for (group = parser->groups;
|
||||||
group++)
|
group < parser->egroup && (!err || err==EBADKEY);
|
||||||
if (group->args_processed == 0)
|
group++)
|
||||||
err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
|
if (group->args_processed == 0)
|
||||||
for (group = parser->groups;
|
err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
|
||||||
group < parser->egroup && (!err || err==EBADKEY);
|
for (group = parser->groups;
|
||||||
group++)
|
group < parser->egroup && (!err || err==EBADKEY);
|
||||||
err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
|
group++)
|
||||||
|
err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
|
||||||
|
|
||||||
if (err == EBADKEY)
|
if (err == EBADKEY)
|
||||||
err = 0; /* Some parser didn't understand. */
|
err = 0; /* Some parser didn't understand. */
|
||||||
|
|
||||||
/* Tell the user that all arguments are parsed. */
|
/* Tell the user that all arguments are parsed. */
|
||||||
if (end_index)
|
if (end_index)
|
||||||
*end_index = parser->state.next;
|
*end_index = parser->state.next;
|
||||||
}
|
}
|
||||||
else if (end_index)
|
else if (end_index)
|
||||||
/* Return any remaining arguments to the user. */
|
/* Return any remaining arguments to the user. */
|
||||||
*end_index = parser->state.next;
|
*end_index = parser->state.next;
|
||||||
else
|
else
|
||||||
/* No way to return the remaining arguments, they must be bogus. */
|
/* No way to return the remaining arguments, they must be bogus. */
|
||||||
{
|
{
|
||||||
if (!(parser->state.flags & ARGP_NO_ERRS) && parser->state.err_stream)
|
if (!(parser->state.flags & ARGP_NO_ERRS)
|
||||||
fprintf (parser->state.err_stream,
|
&& parser->state.err_stream)
|
||||||
dgettext (parser->argp->argp_domain,
|
fprintf (parser->state.err_stream,
|
||||||
"%s: Too many arguments\n"), parser->state.name);
|
dgettext (parser->argp->argp_domain,
|
||||||
err = EBADKEY;
|
"%s: Too many arguments\n"),
|
||||||
}
|
parser->state.name);
|
||||||
|
err = EBADKEY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Okay, we're all done, with either an error or success; call the parsers
|
/* Okay, we're all done, with either an error or success; call the parsers
|
||||||
to indicate which one. */
|
to indicate which one. */
|
||||||
@ -849,20 +853,22 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey)
|
|||||||
opt = KEY_END;
|
opt = KEY_END;
|
||||||
|
|
||||||
if (opt == KEY_END)
|
if (opt == KEY_END)
|
||||||
/* We're past what getopt considers the options. */
|
{
|
||||||
if (parser->state.next >= parser->state.argc
|
/* We're past what getopt considers the options. */
|
||||||
|| (parser->state.flags & ARGP_NO_ARGS))
|
if (parser->state.next >= parser->state.argc
|
||||||
/* Indicate that we're done. */
|
|| (parser->state.flags & ARGP_NO_ARGS))
|
||||||
{
|
/* Indicate that we're done. */
|
||||||
*arg_ebadkey = 1;
|
{
|
||||||
return EBADKEY;
|
*arg_ebadkey = 1;
|
||||||
}
|
return EBADKEY;
|
||||||
else
|
}
|
||||||
/* A non-option arg; simulate what getopt might have done. */
|
else
|
||||||
{
|
/* A non-option arg; simulate what getopt might have done. */
|
||||||
opt = KEY_ARG;
|
{
|
||||||
optarg = parser->state.argv[parser->state.next++];
|
opt = KEY_ARG;
|
||||||
}
|
optarg = parser->state.argv[parser->state.next++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (opt == KEY_ARG)
|
if (opt == KEY_ARG)
|
||||||
/* A non-option argument; try each parser in turn. */
|
/* A non-option argument; try each parser in turn. */
|
||||||
|
@ -404,12 +404,14 @@ noconv:
|
|||||||
hexadecimal digits. This is no error case. We return 0 and
|
hexadecimal digits. This is no error case. We return 0 and
|
||||||
ENDPTR points to the `x`. */
|
ENDPTR points to the `x`. */
|
||||||
if (endptr != NULL)
|
if (endptr != NULL)
|
||||||
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
|
{
|
||||||
&& save[-2] == L_('0'))
|
if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')
|
||||||
*endptr = (STRING_TYPE *) &save[-1];
|
&& save[-2] == L_('0'))
|
||||||
else
|
*endptr = (STRING_TYPE *) &save[-1];
|
||||||
/* There was no number to convert. */
|
else
|
||||||
*endptr = (STRING_TYPE *) nptr;
|
/* There was no number to convert. */
|
||||||
|
*endptr = (STRING_TYPE *) nptr;
|
||||||
|
}
|
||||||
|
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
@ -172,32 +172,35 @@ STRCOLL (s1, s2, l)
|
|||||||
/* We have to increment the index counters. */
|
/* We have to increment the index counters. */
|
||||||
if ((forward && ++s1idx >= s1run->data[pass].number)
|
if ((forward && ++s1idx >= s1run->data[pass].number)
|
||||||
|| (!forward && --s1idx < 0))
|
|| (!forward && --s1idx < 0))
|
||||||
if (forward)
|
{
|
||||||
{
|
if (forward)
|
||||||
s1run = s1run->next;
|
{
|
||||||
s1idx = 0;
|
s1run = s1run->next;
|
||||||
}
|
s1idx = 0;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
s1run = s1run->prev;
|
{
|
||||||
if (s1run != NULL)
|
s1run = s1run->prev;
|
||||||
s1idx = s1run->data[pass].number - 1;
|
if (s1run != NULL)
|
||||||
}
|
s1idx = s1run->data[pass].number - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((forward && ++s2idx >= s2run->data[pass].number)
|
if ((forward && ++s2idx >= s2run->data[pass].number)
|
||||||
|| (!forward && --s2idx < 0))
|
|| (!forward && --s2idx < 0))
|
||||||
if (forward)
|
{
|
||||||
{
|
if (forward)
|
||||||
s2run = s2run->next;
|
{
|
||||||
s2idx = 0;
|
s2run = s2run->next;
|
||||||
}
|
s2idx = 0;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
s2run = s2run->prev;
|
{
|
||||||
if (s2run != NULL)
|
s2run = s2run->prev;
|
||||||
s2idx = s2run->data[pass].number - 1;
|
if (s2run != NULL)
|
||||||
}
|
s2idx = s2run->data[pass].number - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s1run != s2run)
|
if (s1run != s2run)
|
||||||
|
@ -250,17 +250,19 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
|
|||||||
/* We have to increment the index counters. */
|
/* We have to increment the index counters. */
|
||||||
if ((forward && ++idx >= run->data[pass].number)
|
if ((forward && ++idx >= run->data[pass].number)
|
||||||
|| (!forward && --idx < 0))
|
|| (!forward && --idx < 0))
|
||||||
if (forward)
|
{
|
||||||
{
|
if (forward)
|
||||||
run = run->next;
|
{
|
||||||
idx = 0;
|
run = run->next;
|
||||||
}
|
idx = 0;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
run = run->prev;
|
{
|
||||||
if (run != NULL)
|
run = run->prev;
|
||||||
idx = run->data[pass].number - 1;
|
if (run != NULL)
|
||||||
}
|
idx = run->data[pass].number - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write marker for end of word. */
|
/* Write marker for end of word. */
|
||||||
|
Reference in New Issue
Block a user