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

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