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

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