Patch for else/endif labels

korbb@egcs.cygnus.com korbb@egcs.cygnus.com
Tue Jun 22 09:37:00 GMT 1999


The following patch should be applied to both branches.
It will now correctly delete endif labels that look like:

	# endif  / * something */

Pretty disgusting :-(


1999-06-22  Bruce Korb <ddsinc09@ix.netcom.com>

	*fixinc/inclhack.def(end_else_label): combined else_label
	and endif_label and fixed the sed expression.
	*fixinc/{fixincl.x|inclhack.sh}: regen

Index: inclhack.def
===================================================================
RCS file: /cvs/egcs/egcs/gcc/fixinc/inclhack.def,v
retrieving revision 1.28
diff -u -r1.28 inclhack.def
--- inclhack.def	1999/06/18 12:44:12	1.28
+++ inclhack.def	1999/06/22 16:19:38
@@ -416,31 +416,13 @@
 
 
 /*
- *  Fix else directives that contain non-commentary text
- *
- * The fixinc_eol stuff is to work around a bug in the sed
+ *  Fix else and endif directives that contain non-commentary text
  */
 fix = {
-    hackname = else_label;
-    select   = "^[ \t]*#[ \t]*else[ \t]+[!-.0-~]";
-    sed =      ":loop\n"
-               '/\\\\$/'                       "N\n"
-               's/\\\\$/\\\\+++fixinc_eol+++/' "\n"
-               '/\\\\$/'                       "b loop\n"
-               's/\\\\+++fixinc_eol+++/\\\\/g' "\n"
+    hackname = end_else_label;
 
-               "s%^\\([ \t]*#[ \t]*else\\)[ \t]*/[^*].*%\\1%\n"
-               "s%^\\([ \t]*#[ \t]*else\\)[ \t]*[^/ \t].*%\\1%";
-};
-
-
-/*
- *  Fix endif directives that contain non-commentary text
- */
-fix = {
-    hackname = endif_label;
     /*
-     *  Select files that contain '#endif' directives with
+     *  Select files that contain '#endif' or '#else' directives with
      *  some sort of following junk.  (Between the ascii '.'
      *  and '0' lies the character '/'.  This will *NOT*
      *  match '#endif / * foo * /', but it also wont match
@@ -452,13 +434,14 @@
      *  "#endif /% blah %/ which appear on OSF4.0A and AIX4.2
      *  repsectively.
      * 
-     *  We use the pattern [!-.0-z{|}~] instead of [^/ \t] to match a noncomment
-     *  following #else or #endif because some buggy egreps think [^/] matches
-     *  newline, and they thus think `#else ' matches
+     *  We use the pattern [!-.0-z{|}~] instead of [^/ \t] to match a
+     *  noncomment following #else or #endif because some buggy egreps
+     *  think [^/] matches newline, and they thus think `#else ' matches
      *  `#e[ndiflse]*[ \t]+[^/ \t]'.
      *  [!-.0-~] does not work properly on AIX 4.1.
      */
-    select   = "^[ \t]*#[ \t]*endif[ \t]+[!-.0-z\{\|\}\~]|^[ \t]*#[ \t]*endif[ \t]+/[^\*]";
+    select   = "^[ \t]*#[ \t]*(else|endif)[ \t]+"
+               "("  '[!-.0-z\{\|\}\~]'  "|"  '/[^\*]'  ")";
 
     /*
      *  First, join the continued input lines.
@@ -476,9 +459,11 @@
                '/\\\\$/'                       "b loop\n"
                's/\\\\+++fixinc_eol+++/\\\\/g' "\n"
 
-               "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*/[^*].*%\\1%\n"
-               "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*\\*[^/].*%\\1%\n"
-               "s%^\\([ \t]*#[ \t]*endif\\)[ \t]*[^/* \t].*%\\1%";
+               "s%^\\([ \t]*#[ \t]*else\\)[ \t][ \t]*/[^*].*%\\1%\n"
+               "s%^\\([ \t]*#[ \t]*else\\)[ \t][ \t]*[^/ \t].*%\\1%\n"
+               "s%^\\([ \t]*#[ \t]*endif\\)[ \t][ \t]*/[^*].*%\\1%\n"
+               "s%^\\([ \t]*#[ \t]*endif\\)[ \t][ \t]*\*[^/].*%\\1%\n"
+               "s%^\\([ \t]*#[ \t]*endif\\)[ \t][ \t]*[^/* \t].*%\\1%";
 };
 
 


More information about the Gcc-patches mailing list