PATCH: Don't dump core in posix/transbug

H. J. Lu hjl@lucon.org
Thu Jun 12 16:28:00 GMT 2003


posix/transbug failed for me with gcc 3.3. It may be a compiler bug.
But it shouldn't dump core. Here is a patch.

BTW, Changelog entry says

	* posux/transbug.c: New file.
	     ^


H.J.
-------------- next part --------------
2003-06-12  H.J. Lu <hongjiu.lu@intel.com>

	* posix/transbug.c (run_test): Return 1 for failure.
	(do_test): Compare only if run_test is successful.

--- posix/transbug.c.bug	2003-06-11 19:31:55.000000000 -0700
+++ posix/transbug.c	2003-06-12 09:23:38.000000000 -0700
@@ -105,7 +105,7 @@ run_test (const char *pattern, struct re
     printf ("search 2: res = %d, start = %d, end = %d\n",
 	    res, regs[1].start[0], regs[1].end[0]);
 
-  return 0;
+  return res < 0 ? 1 : 0;
 }
 
 
@@ -120,17 +120,19 @@ do_test (void)
 
   (void) re_set_syntax (RE_SYNTAX_GNU_AWK);
 
-  run_test (lower, regs);
-  run_test (upper, &regs[2]);
-
-  int result = 0;
+  int result;
 #define CHECK(exp) \
   if (exp) { puts (#exp); result = 1; }
 
-  CHECK (regs[0].start[0] != regs[2].start[0]);
-  CHECK (regs[0].end[0] != regs[2].end[0]);
-  CHECK (regs[1].start[0] != regs[3].start[0]);
-  CHECK (regs[1].end[0] != regs[3].end[0]);
+  result = run_test (lower, regs);
+  result |= run_test (upper, &regs[2]);
+  if (! result)
+    {
+      CHECK (regs[0].start[0] != regs[2].start[0]);
+      CHECK (regs[0].end[0] != regs[2].end[0]);
+      CHECK (regs[1].start[0] != regs[3].start[0]);
+      CHECK (regs[1].end[0] != regs[3].end[0]);
+    }
 
   return result;
 }


More information about the Libc-alpha mailing list