diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2019-04-18 22:23:02 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-04-25 07:59:54 +0200 |
commit | 71f2092d2674c261592462aef90b7abfc042c6dc (patch) | |
tree | 8cfce87fa841363d3ec11b5fd75b9aad23aa6465 /lib/argmatch.c | |
parent | 14a920195eee84550cfdd7a161896363d4796a22 (diff) | |
download | gnulib-71f2092d2674c261592462aef90b7abfc042c6dc.tar.gz |
argmatch: use void* for raw memory pointers
* lib/argmatch.h, lib/argmatch.c (argmatch, argmatch_valid)
(__xargmatch_internal, argmatch_to_argument): Use void* for pointers
to "values", keep char* for strings.
Diffstat (limited to 'lib/argmatch.c')
-rw-r--r-- | lib/argmatch.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/argmatch.c b/lib/argmatch.c index b9a3e400c4..7666ef4144 100644 --- a/lib/argmatch.c +++ b/lib/argmatch.c @@ -82,7 +82,7 @@ argmatch_exit_fn argmatch_die = __argmatch_die; ptrdiff_t argmatch (const char *arg, const char *const *arglist, - const char *vallist, size_t valsize) + const void *vallist, size_t valsize) { size_t i; /* Temporary index in ARGLIST. */ size_t arglen; /* Length of ARG. */ @@ -106,8 +106,8 @@ argmatch (const char *arg, const char *const *arglist, { /* Second nonexact match found. */ if (vallist == NULL - || memcmp (vallist + valsize * matchind, - vallist + valsize * i, valsize)) + || memcmp ((char const *) vallist + valsize * matchind, + (char const *) vallist + valsize * i, valsize)) { /* There is a real ambiguity, or we could not disambiguate. */ @@ -144,7 +144,7 @@ argmatch_invalid (const char *context, const char *value, ptrdiff_t problem) VALSIZE is the size of the elements of VALLIST */ void argmatch_valid (const char *const *arglist, - const char *vallist, size_t valsize) + const void *vallist, size_t valsize) { size_t i; const char *last_val = NULL; @@ -154,10 +154,10 @@ argmatch_valid (const char *const *arglist, fputs (_("Valid arguments are:"), stderr); for (i = 0; arglist[i]; i++) if ((i == 0) - || memcmp (last_val, vallist + valsize * i, valsize)) + || memcmp (last_val, (char const *) vallist + valsize * i, valsize)) { fprintf (stderr, "\n - %s", quote (arglist[i])); - last_val = vallist + valsize * i; + last_val = (char const *) vallist + valsize * i; } else { @@ -175,7 +175,7 @@ argmatch_valid (const char *const *arglist, ptrdiff_t __xargmatch_internal (const char *context, const char *arg, const char *const *arglist, - const char *vallist, size_t valsize, + const void *vallist, size_t valsize, argmatch_exit_fn exit_fn) { ptrdiff_t res = argmatch (arg, arglist, vallist, valsize); @@ -194,14 +194,14 @@ __xargmatch_internal (const char *context, /* Look for VALUE in VALLIST, an array of objects of size VALSIZE and return the first corresponding argument in ARGLIST */ const char * -argmatch_to_argument (const char *value, +argmatch_to_argument (const void *value, const char *const *arglist, - const char *vallist, size_t valsize) + const void *vallist, size_t valsize) { size_t i; for (i = 0; arglist[i]; i++) - if (!memcmp (value, vallist + valsize * i, valsize)) + if (!memcmp (value, (char const *) vallist + valsize * i, valsize)) return arglist[i]; return NULL; } |