- This program is free software; you can redistribute it and/or modify
+ Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+ 2009, 2010 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* When reporting an invalid argument, show nonprinting characters
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
/* When reporting an invalid argument, show nonprinting characters
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
of the matched element, else -1 if it does not match any element
or -2 if it is ambiguous (is a prefix of more than one element).
of the matched element, else -1 if it does not match any element
or -2 if it is ambiguous (is a prefix of more than one element).
- int i; /* Temporary index in ARGLIST. */
- size_t arglen; /* Length of ARG. */
- int matchind = -1; /* Index of first nonexact match. */
- int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
+ size_t i; /* Temporary index in ARGLIST. */
+ size_t arglen; /* Length of ARG. */
+ ptrdiff_t matchind = -1; /* Index of first nonexact match. */
+ bool ambiguous = false; /* If true, multiple nonexact match(es). */
for (i = 0; arglist[i]; i++)
{
if (!strncmp (arglist[i], arg, arglen))
for (i = 0; arglist[i]; i++)
{
if (!strncmp (arglist[i], arg, arglen))
- {
- if (strlen (arglist[i]) == arglen)
- /* Exact match found. */
- return i;
- else if (matchind == -1)
- /* First nonexact match found. */
- matchind = i;
- else
- {
- /* Second nonexact match found. */
- if (vallist == NULL
- || memcmp (vallist + valsize * matchind,
- vallist + valsize * i, valsize))
- {
- /* There is a real ambiguity, or we could not
- disambiguate. */
- ambiguous = 1;
- }
- }
- }
+ {
+ if (strlen (arglist[i]) == arglen)
+ /* Exact match found. */
+ return i;
+ else if (matchind == -1)
+ /* First nonexact match found. */
+ matchind = i;
+ else
+ {
+ /* Second nonexact match found. */
+ if (vallist == NULL
+ || memcmp (vallist + valsize * matchind,
+ vallist + valsize * i, valsize))
+ {
+ /* There is a real ambiguity, or we could not
+ disambiguate. */
+ ambiguous = true;
+ }
+ }
+ }
error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value),
error (0, 0, format, quotearg_n_style (0, ARGMATCH_QUOTING_STYLE, value),
VALSIZE is the size of the elements of VALLIST */
void
argmatch_valid (const char *const *arglist,
VALSIZE is the size of the elements of VALLIST */
void
argmatch_valid (const char *const *arglist,
fprintf (stderr, _("Valid arguments are:"));
for (i = 0; arglist[i]; i++)
if ((i == 0)
fprintf (stderr, _("Valid arguments are:"));
for (i = 0; arglist[i]; i++)
if ((i == 0)
- fprintf (stderr, "\n - `%s'", arglist[i]);
- last_val = vallist + valsize * i;
+ fprintf (stderr, "\n - `%s'", arglist[i]);
+ last_val = vallist + valsize * i;
- fprintf (stderr, ", `%s'", arglist[i]);
+ fprintf (stderr, ", `%s'", arglist[i]);
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
calls the (supposed never to return) function EXIT_FN. */
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
calls the (supposed never to return) function EXIT_FN. */
- const char *arg, const char *const *arglist,
- const char *vallist, size_t valsize,
- argmatch_exit_fn exit_fn)
+ const char *arg, const char *const *arglist,
+ const char *vallist, size_t valsize,
+ argmatch_exit_fn exit_fn)
- int res = argmatch (arg, arglist, vallist, valsize);
+ ptrdiff_t res = argmatch (arg, arglist, vallist, valsize);
return the first corresponding argument in ARGLIST */
const char *
argmatch_to_argument (const char *value,
return the first corresponding argument in ARGLIST */
const char *
argmatch_to_argument (const char *value,
- const char *const *arglist,
- const char *vallist, size_t valsize)
+ const char *const *arglist,
+ const char *vallist, size_t valsize)
for (i = 0; arglist[i]; i++)
if (!memcmp (value, vallist + valsize * i, valsize))
for (i = 0; arglist[i]; i++)
if (!memcmp (value, vallist + valsize * i, valsize))
/* Make numbered backups of files that already have numbered backups,
and simple backups of the others. */
/* Make numbered backups of files that already have numbered backups,
and simple backups of the others. */
- none, none, none,
- simple, simple,
- numbered_existing, numbered_existing,
- numbered, numbered
+ no_backups, no_backups, no_backups,
+ simple_backups, simple_backups,
+ numbered_existing_backups, numbered_existing_backups,
+ numbered_backups, numbered_backups
if ((cp = getenv ("VERSION_CONTROL")))
backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
if ((cp = getenv ("VERSION_CONTROL")))
backup_type = XARGMATCH ("$VERSION_CONTROL", cp,