From b233676db696ec4bb4a9d55e76ec8012e6f7a22c Mon Sep 17 00:00:00 2001
From: Denis Vlasenko <vda.linux@googlemail.com>
Date: Wed, 17 Dec 2008 01:28:36 +0000
Subject: resolv: fix testcase failure test/regex/tst-regex2.c: fix testcase to
 compile with just "gcc <file>.c"

---
 libc/inet/resolv.c      |  4 ++--
 test/regex/tst-regex2.c | 21 +++++++++++++--------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index dc2ae7ba3..6be3a866d 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1462,9 +1462,9 @@ int attribute_hidden __read_etc_hosts_r(
 			*result = NULL;
 			return errno;
 		}
+		addr_list[0] = in;
+		addr_list[1] = NULL;
 	}
-	addr_list[0] = in;
-	addr_list[1] = NULL;
 
 	*h_errnop = HOST_NOT_FOUND;
 	while (fgets(buf, buflen, fp)) {
diff --git a/test/regex/tst-regex2.c b/test/regex/tst-regex2.c
index 94be59d85..1cf3e1d09 100644
--- a/test/regex/tst-regex2.c
+++ b/test/regex/tst-regex2.c
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE 1
+
 #include <fcntl.h>
 #include <locale.h>
 #include <regex.h>
@@ -42,8 +44,8 @@ do_test (void)
       return 1;
     }
 
-  struct stat64 st;
-  if (fstat64 (fd, &st) < 0)
+  struct stat st;
+  if (fstat (fd, &st) < 0)
     {
       printf ("Couldn't fstat ChangeLog.14: %s\n", strerror(errno));
       return 1;
@@ -71,9 +73,10 @@ do_test (void)
 
   char *string = buf;
   size_t len = st.st_size;
+  int testno, i;
 
-  for (int testno = 0; testno < 4; ++testno)
-    for (int i = 0; i < sizeof (pat) / sizeof (pat[0]); ++i)
+  for (testno = 0; testno < 4; ++testno)
+    for (i = 0; i < sizeof (pat) / sizeof (pat[0]); ++i)
       {
 	printf ("test %d pattern %d", testno, i);
 
@@ -142,9 +145,10 @@ do_test (void)
 		  return 1;
 		}
 
+	      int j, k, l;
 	      if (i > 0)
-		for (int j = 0, l = 1; j < 7; ++j)
-		  for (int k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
+		for (j = 0, l = 1; j < 7; ++j)
+		  for (k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
 		    if (pmatch[l].rm_so != pmatch[0].rm_so + j
 			|| pmatch[l].rm_eo != pmatch[l].rm_so + 1)
 		      {
@@ -199,9 +203,10 @@ do_test (void)
 		  return 1;
 		}
 
+	      int j, k, l;
 	      if (i > 0)
-		for (int j = 0, l = 1; j < 7; ++j)
-		  for (int k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
+		for (j = 0, l = 1; j < 7; ++j)
+		  for (k = 0; k < (i == 1 ? 1 : 10); ++k, ++l)
 		    if (regs.start[l] != match + j
 			|| regs.end[l] != regs.start[l] + 1)
 		      {
-- 
cgit v1.2.3