[fixincludes patch] Add getrnge() fix for svr4, version 2

Nathanael Nerode neroden@twcny.rr.com
Mon Aug 4 18:28:00 GMT 2003


This "Does the Right Thing" on sequent/ptx (corresponding to the existing
weird script), and it doesn't trigger (which is also correct) on i386-linux.
See the comments in the patch for motivation.  :-)

It should be safe since the 'select' and 'bypass' together are pretty
restrictive; worst case is that it introduces a redundant declaration.

This incorporates changes due to insightful commentary from
various people.  :-)

OK for mainline?

(New test base result omitted, since it's generated.)

	* fixinc/inclhack.def (svr4_undeclared_getrnge): Introduce and enable.
	* fixinc/inclhack.def (static_getrnge): Remove disabled hack.
	* fixinc/fixincl.x: Rebuild.
	* fixinc/tests/base/regexp.h: New test.

Index: inclhack.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/inclhack.def,v
retrieving revision 1.170
diff -u -r1.170 inclhack.def
--- inclhack.def	1 Aug 2003 22:48:23 -0000	1.170
+++ inclhack.def	4 Aug 2003 18:27:56 -0000
@@ -2305,25 +2305,6 @@
 
 
 /*
- *  Add a `static' declaration of `getrnge' into <regexp.h>.
- *
- *  Don't do this if there is already a `static void getrnge' declaration
- *  present, since this would cause a redeclaration error.  Solaris 2.x has
- *  such a declaration.
- */
-#ifdef SVR4
-fix = {
-    hackname = static_getrnge;
-    files    = regexp.h;
-    bypass   = "static void getrnge";
-    sed      = "/^static int[ \t]*size;/c\\\n"
-               "static int      size ;\\\n\\\n"
-               "static int getrnge ();";
-};
-#endif
-
-
-/*
  *  a missing semi-colon at the end of the statsswtch structure definition.
  */
 fix = {
@@ -2987,6 +2968,35 @@
     sed      = 's/const extern/extern const/g';
 };
 #endif
+
+
+/*
+ *  Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
+ *  function 'getrnge' in <regexp.h> before they declare it.  For these
+ *  systems add a 'static int' declaration of 'getrnge' into <regexp.h>
+ *  early on.
+ *
+ *  'getrnge' traditionally manipulates a file-scope global called 'size',
+ *  so put the declaration right after the declaration of 'size'.
+ *
+ *  Don't do this if there is already a `static void getrnge' declaration
+ *  present, since this would cause a redeclaration error.  Solaris 2.x has
+ *  such a declaration.
+ */
+fix = {
+    hackname  = svr4_undeclared_getrnge;
+    files     = regexp.h;
+    select    = "getrnge";
+    bypass    = "static void getrnge";
+    c_fix     = format;
+    c_fix_arg = "%0\n"
+                "static int getrnge ();";
+    c_fix_arg = "^static int[ \t]+size;";
+    test_text = "static int size;\n"
+                "/* stuff which calls getrnge() */\n"
+                "static getrnge()\n"
+                "{}";
+};
 
 
 /*

-- 
Nathanael Nerode  <neroden at gcc.gnu.org>
http://home.twcny.rr.com/nerode/neroden/fdl.html



More information about the Gcc-patches mailing list