]> git.saurik.com Git - bison.git/commitdiff
Sync with gnulib again.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 22 Nov 2002 00:30:58 +0000 (00:30 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 22 Nov 2002 00:30:58 +0000 (00:30 +0000)
lib/argmatch.c
lib/argmatch.h

index 81f95f75cda4e15b14f6f2ff651137b43e7557f4..4ff5a492ea75643d9ff453c7eb2fa386103b4bf9 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).
    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
 
    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'.  */
 
      "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.  */
 {
   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++)
     {
   /* 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.  */
        {
          if (strlen (arglist[i]) == arglen)
            /* Exact match found.  */
@@ -121,22 +117,6 @@ __argmatch_internal (const char *arg, const char *const *arglist,
     return matchind;
 }
 
     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.
 /* 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,
 __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)
 {
                      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;
   if (res >= 0)
     /* Success. */
     return res;
@@ -282,12 +259,12 @@ main (int argc, const char *const *argv)
     }
 
   if ((cp = getenv ("VERSION_CONTROL")))
     }
 
   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)
 
   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));
 
   printf ("The version control is `%s'\n",
          ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
index 4b65ca4b72e1079e0660d885738544479cf04822..deb908fb9d1b03427caa9805a5379a52985d6670 100644 (file)
 
 int argmatch (char const *arg, char const *const *arglist,
              char const *vallist, size_t valsize);
 
 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 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)'.  */
 /* 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 __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. */
 
 
 /* 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),          \
   ((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. */
 
 
 /* Convert a value into a corresponding argument. */