changeset 20356:7d64c62d8d9b

[STDC_HEADERS]: Guard inclusion of stdlib.h. (_) [!_]: Define it. (try): Add RESPONSE parameter. (rpmatch): Update caller. Change the regular expressions to be ^[yY] and ^[nN].
author Jim Meyering <jim@meyering.net>
date Sun, 21 Jul 1996 22:46:39 +0000
parents 652c280ac947
children 2fb79981992b
files lib/rpmatch.c
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lib/rpmatch.c	Sun Jul 21 22:41:26 1996 +0000
+++ b/lib/rpmatch.c	Sun Jul 21 22:46:39 1996 +0000
@@ -20,12 +20,19 @@
 # include <config.h>
 #endif
 
-#include <stdlib.h>
+#if STDC_HEADERS || _LIBC
+# include <stdlib.h>
+#endif
+
 #include <regex.h>
 
+#ifndef _
+# define _(String) String
+#endif
 
 static int
-try (tag, match, nomatch, lastp, re)
+try (response, pattern, match, nomatch, lastp, re)
+     const char *response;
      const char *pattern;
      const int match;
      const int nomatch;
@@ -47,7 +54,7 @@
       *lastp = pattern;
     }
 
-  /* Try the pattern.  */
+  /* See if the regular expression matches RESPONSE.  */
   return regexec (re, response, 0, NULL, 0) == 0 ? match : nomatch;
 }
 
@@ -64,7 +71,8 @@
   static regex_t yesre, nore;
   int result;
 
-  return ((result = try (_("[yY][[:alpha:]]"), 1, 0, &yesexpr, &yesre))
+  return ((result = try (response, _("^[yY]"), 1, 0,
+			 &yesexpr, &yesre))
 	  ? result
-	  : try (_("[nN][[:alpha:]]"), 0, -1, &noexpr, &nore));
+	  : try (response, _("^[nN]"), 0, -1, &noexpr, &nore));
 }