Remove case insensitive option matching.
authorBruno Haible <bruno@clisp.org>
Thu, 21 Nov 2002 20:15:39 +0000 (20:15 +0000)
committerBruno Haible <bruno@clisp.org>
Thu, 21 Nov 2002 20:15:39 +0000 (20:15 +0000)
lib/ChangeLog
lib/argmatch.c
lib/argmatch.h

index c196a1b..90bd018 100644 (file)
@@ -1,5 +1,17 @@
 2002-11-21  Bruno Haible  <bruno@clisp.org>
 
+       Remove case insensitive option matching.
+       * argmatch.h (argcasematch): Remove declaration.
+       (ARGCASEMATCH): Remove macro.
+       (__xargmatch_internal): Remove case_sensitive argument.
+       (XARGMATCH): Update.
+       (XARGCASEMATCH): Remove macro.
+       * argmatch.c (argmatch): Renamed from __argmatch_internal. Remove
+       case_sensitive argument.
+       (argcasematch): Remove function.
+       (__xargmatch_internal): Remove case_sensitive argument.
+       (main): Use XARGMATCH instead of XARGCASEMATCH.
+
        * xmalloc.c: Change compile-time error message. Add comment about
        required autoconf version.
 
index 81f95f7..4ff5a49 100644 (file)
@@ -68,7 +68,6 @@ argmatch_exit_fn argmatch_die = __argmatch_die;
    null-terminated array ARGLIST, return the index in ARGLIST
    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).
-   If SENSITIVE, comparison is case sensitive.
 
    If VALLIST is none null, use it to resolve ambiguities limited to
    synonyms, i.e., for
@@ -76,10 +75,9 @@ argmatch_exit_fn argmatch_die = __argmatch_die;
      "no", "nope" -> 1
    "y" is a valid argument, for `0', and "n" for `1'.  */
 
-static int
-__argmatch_internal (const char *arg, const char *const *arglist,
-                    const char *vallist, size_t valsize,
-                    int case_sensitive)
+int
+argmatch (const char *arg, const char *const *arglist,
+         const char *vallist, size_t valsize)
 {
   int i;                       /* Temporary index in ARGLIST.  */
   size_t arglen;               /* Length of ARG.  */
@@ -91,9 +89,7 @@ __argmatch_internal (const char *arg, const char *const *arglist,
   /* Test all elements for either exact match or abbreviated matches.  */
   for (i = 0; arglist[i]; i++)
     {
-      if (case_sensitive
-         ? !strncmp (arglist[i], arg, arglen)
-         : !strncasecmp (arglist[i], arg, arglen))
+      if (!strncmp (arglist[i], arg, arglen))
        {
          if (strlen (arglist[i]) == arglen)
            /* Exact match found.  */
@@ -121,22 +117,6 @@ __argmatch_internal (const char *arg, const char *const *arglist,
     return matchind;
 }
 
-/* argmatch - case sensitive version */
-int
-argmatch (const char *arg, const char *const *arglist,
-         const char *vallist, size_t valsize)
-{
-  return __argmatch_internal (arg, arglist, vallist, valsize, 1);
-}
-
-/* argcasematch - case insensitive version */
-int
-argcasematch (const char *arg, const char *const *arglist,
-             const char *vallist, size_t valsize)
-{
-  return __argmatch_internal (arg, arglist, vallist, valsize, 0);
-}
-
 /* Error reporting for argmatch.
    CONTEXT is a description of the type of entity that was being matched.
    VALUE is the invalid value that was given.
@@ -191,12 +171,9 @@ int
 __xargmatch_internal (const char *context,
                      const char *arg, const char *const *arglist,
                      const char *vallist, size_t valsize,
-                     int case_sensitive,
                      argmatch_exit_fn exit_fn)
 {
-  int res = __argmatch_internal (arg, arglist,
-                                vallist, valsize,
-                                case_sensitive);
+  int res = argmatch (arg, arglist, vallist, valsize);
   if (res >= 0)
     /* Success. */
     return res;
@@ -282,12 +259,12 @@ main (int argc, const char *const *argv)
     }
 
   if ((cp = getenv ("VERSION_CONTROL")))
-    backup_type = XARGCASEMATCH ("$VERSION_CONTROL", cp,
-                                backup_args, backup_vals);
+    backup_type = XARGMATCH ("$VERSION_CONTROL", cp,
+                            backup_args, backup_vals);
 
   if (argc == 2)
-    backup_type = XARGCASEMATCH (program_name, argv[1],
-                                backup_args, backup_vals);
+    backup_type = XARGMATCH (program_name, argv[1],
+                            backup_args, backup_vals);
 
   printf ("The version control is `%s'\n",
          ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
index 4b65ca4..deb908f 100644 (file)
 
 int argmatch (char const *arg, char const *const *arglist,
              char const *vallist, size_t valsize);
-int argcasematch (char const *arg, char const *const *arglist,
-                 char const *vallist, size_t valsize);
 
 # define ARGMATCH(Arg, Arglist, Vallist) \
   argmatch (Arg, Arglist, (char const *) (Vallist), sizeof *(Vallist))
 
-# define ARGCASEMATCH(Arg, Arglist, Vallist) \
-  argcasematch (Arg, Arglist, (char 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
    in turn defaults to `exit (EXIT_FAILURE)'.  */
@@ -91,7 +86,7 @@ void argmatch_valid (char const *const *arglist,
 int __xargmatch_internal (char const *context,
                          char const *arg, char const *const *arglist,
                          char const *vallist, size_t valsize,
-                         int case_sensitive, argmatch_exit_fn exit_fn);
+                         argmatch_exit_fn exit_fn);
 
 /* Programmer friendly interface to __xargmatch_internal. */
 
@@ -99,13 +94,7 @@ int __xargmatch_internal (char const *context,
   ((Vallist) [__xargmatch_internal (Context, Arg, Arglist,     \
                                    (char const *) (Vallist),   \
                                    sizeof *(Vallist),          \
-                                   1, argmatch_die)])
-
-# define XARGCASEMATCH(Context, Arg, Arglist, Vallist)         \
-  ((Vallist) [__xargmatch_internal (Context, Arg, Arglist,     \
-                                   (char const *) (Vallist),   \
-                                   sizeof *(Vallist),          \
-                                   0, argmatch_die)])
+                                   argmatch_die)])
 
 /* Convert a value into a corresponding argument. */