+2019-04-18 Akim Demaille <akim@lrde.epita.fr>
+
+ 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.
+
2019-04-21 Akim Demaille <akim@lrde.epita.fr>
prefix-gnulib-mk: fix the support for gnulib-po
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. */
{
/* 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. */
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;
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
{
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);
/* 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;
}
to the same values in VALLIST). */
ptrdiff_t argmatch (char const *arg, char const *const *arglist,
- char const *vallist, size_t valsize) _GL_ATTRIBUTE_PURE;
+ void const *vallist, size_t valsize) _GL_ATTRIBUTE_PURE;
# define ARGMATCH(Arg, Arglist, Vallist) \
- argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist))
+ argmatch (Arg, Arglist, (void const *) (Vallist), sizeof *(Vallist))
/* xargmatch calls this function when it fails. This function should not
return. By default, this is a function that calls ARGMATCH_DIE which
/* Report on stderr the list of possible arguments. */
void argmatch_valid (char const *const *arglist,
- char const *vallist, size_t valsize);
+ void const *vallist, size_t valsize);
# define ARGMATCH_VALID(Arglist, Vallist) \
- argmatch_valid (Arglist, (char const *) (Vallist), sizeof *(Vallist))
+ argmatch_valid (Arglist, (void const *) (Vallist), sizeof *(Vallist))
ptrdiff_t __xargmatch_internal (char const *context,
char const *arg, char const *const *arglist,
- char const *vallist, size_t valsize,
+ void const *vallist, size_t valsize,
argmatch_exit_fn exit_fn);
/* Programmer friendly interface to __xargmatch_internal. */
# define XARGMATCH(Context, Arg, Arglist, Vallist) \
((Vallist) [__xargmatch_internal (Context, Arg, Arglist, \
- (char const *) (Vallist), \
+ (void const *) (Vallist), \
sizeof *(Vallist), \
argmatch_die)])
/* Convert a value into a corresponding argument. */
-char const *argmatch_to_argument (char const *value,
+char const *argmatch_to_argument (void const *value,
char const *const *arglist,
- char const *vallist, size_t valsize)
+ void const *vallist, size_t valsize)
_GL_ATTRIBUTE_PURE;
# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
argmatch_to_argument (Value, Arglist, \
- (char const *) (Vallist), sizeof *(Vallist))
+ (void const *) (Vallist), sizeof *(Vallist))
#ifdef __cplusplus
}