This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Add 'getrnge' fix to regular fixincludes
- From: neroden at twcny dot rr dot com (Nathanael Nerode)
- To: gcc-patches at gcc dot gnu dot org, bkorb at veritas dot com
- Date: Fri, 1 Aug 2003 23:02:32 -0400
- Subject: [patch] Add 'getrnge' fix to regular fixincludes
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.
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 2 Aug 2003 03:00:45 -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,34 @@
sed = 's/const extern/extern const/g';
};
#endif
+
+
+/*
+ * Some SysV r4 systems, including Sequent/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"
+ "getrnge(7);\n"
+ "static getrnge()\n"
+ "{ size = 0; }";
+};
/*
--
Nathanael Nerode <neroden at gcc.gnu.org>
http://home.twcny.rr.com/nerode/neroden/fdl.html