[patch]: fix for sed glitch in fixincludes

Bruce Korb bkorb@sco.COM
Mon Aug 21 09:25:00 GMT 2000

My thanks to Eli:


Mission accomplished :-).  The problem was caused by the interaction
of this Sed expression and the one which follows it:

     sed = "/^extern int$/N";
     sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";

When this second expression saw "extern int", it would always cause
Sed to read another line.  Thus, "^\tstrncmp" would never be seen by
Sed, since the previous line says "extern int".

The same happens from the command line if you submit both expressions
to Sed.

The following patch should fix the problem.  I didn't have the
required tools installed to generate fixincl.x, so I patched fixincl.x
manually; that worked for me (the fixed testing.h was identical to
tests/base/testing.h).  I hope that the inclhack.def patch below is

2000-08-12  Eli Zaretskii  <eliz@is.elta.co.il>

        * fixinc/inclhack.def (sysv68_string): Fix the Sed script so it
        works inside fixincl.

--- fixinc/inclhack.d~0 Thu Jul 27 16:28:58 2000
+++ fixinc/inclhack.def Sat Aug 12 19:11:42 2000
@@ -2558,17 +2558,13 @@
     sed = "/^extern char$/N";
     sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
-    /*
-     *  This sed expression is broken inside fixincl.
-     *  The same expression seems to work outside, however :-(
-     */
-    sed = "/^\tstrncmp(),$/N";
-    sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
-            '\1;' "\\\nextern unsigned int\\\n\\2/";
     sed = "/^extern int$/N";
     sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
+    sed = "/^extern int\\n\tstrncmp(),$/N";
+    sed = 's/^\(' "extern int\\n\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
+            '\1;' "\\\nextern unsigned int\\\n\\2/";
     test_text =
     "extern int strlen();\n"

More information about the Gcc-patches mailing list