Blame SOURCES/glibc-rh1505492-prototypes-6.patch

c6d234
commit c079afb7724ce4b9ff2d6b1ca4d7e3cdebcbcd1f
c6d234
Author: Roland McGrath <roland@hack.frob.com>
c6d234
Date:   Fri Sep 12 14:58:55 2014 -0700
c6d234
c6d234
    Don't use a nested function in rpmatch.
c6d234
c6d234
diff --git a/stdlib/rpmatch.c b/stdlib/rpmatch.c
c6d234
index 31285879ee7e6ff6..8c6290551bae1bcf 100644
c6d234
--- a/stdlib/rpmatch.c
c6d234
+++ b/stdlib/rpmatch.c
c6d234
@@ -22,42 +22,40 @@
c6d234
 #include <regex.h>
c6d234
 
c6d234
 
c6d234
-int
c6d234
-rpmatch (response)
c6d234
-     const char *response;
c6d234
+/* Match against one of the response patterns, compiling the pattern
c6d234
+   first if necessary.  */
c6d234
+static int
c6d234
+try (const char *response,
c6d234
+     const int tag, const int match, const int nomatch,
c6d234
+     const char **lastp, regex_t *re)
c6d234
 {
c6d234
-  /* Match against one of the response patterns, compiling the pattern
c6d234
-     first if necessary.  */
c6d234
-  auto int try (const int tag, const int match, const int nomatch,
c6d234
-		const char **lastp, regex_t *re);
c6d234
-
c6d234
-  int try (const int tag, const int match, const int nomatch,
c6d234
-	   const char **lastp, regex_t *re)
c6d234
+  const char *pattern = nl_langinfo (tag);
c6d234
+  if (pattern != *lastp)
c6d234
     {
c6d234
-      const char *pattern = nl_langinfo (tag);
c6d234
-      if (pattern != *lastp)
c6d234
-	{
c6d234
-	  /* The pattern has changed.  */
c6d234
-	  if (*lastp)
c6d234
-	    {
c6d234
-	      /* Free the old compiled pattern.  */
c6d234
-	      __regfree (re);
c6d234
-	      *lastp = NULL;
c6d234
-	    }
c6d234
-	  /* Compile the pattern and cache it for future runs.  */
c6d234
-	  if (__regcomp (re, pattern, REG_EXTENDED) != 0)
c6d234
-	    return -1;
c6d234
-	  *lastp = pattern;
c6d234
-	}
c6d234
-
c6d234
-      /* Try the pattern.  */
c6d234
-      return __regexec (re, response, 0, NULL, 0) == 0 ? match : nomatch;
c6d234
+      /* The pattern has changed.  */
c6d234
+      if (*lastp != NULL)
c6d234
+        {
c6d234
+          /* Free the old compiled pattern.  */
c6d234
+          __regfree (re);
c6d234
+          *lastp = NULL;
c6d234
+        }
c6d234
+      /* Compile the pattern and cache it for future runs.  */
c6d234
+      if (__regcomp (re, pattern, REG_EXTENDED) != 0)
c6d234
+        return -1;
c6d234
+      *lastp = pattern;
c6d234
     }
c6d234
 
c6d234
+  /* Try the pattern.  */
c6d234
+  return __regexec (re, response, 0, NULL, 0) == 0 ? match : nomatch;
c6d234
+}
c6d234
+
c6d234
+int
c6d234
+rpmatch (const char *response)
c6d234
+{
c6d234
   /* We cache the response patterns and compiled regexps here.  */
c6d234
   static const char *yesexpr, *noexpr;
c6d234
   static regex_t yesre, nore;
c6d234
 
c6d234
-  return (try (YESEXPR, 1, 0, &yesexpr, &yesre) ?:
c6d234
-	  try (NOEXPR, 0, -1, &noexpr, &nore));
c6d234
+  return (try (response, YESEXPR, 1, 0, &yesexpr, &yesre) ?:
c6d234
+	  try (response, NOEXPR, 0, -1, &noexpr, &nore));
c6d234
 }