This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: fixinc/inclhack.def for UnixWare 2.1.3



Rodney Brown wrote:
> How do you escape parenthesis with a backslash
> successfully in the select string?
> In testing I could only get 0 or two backslashes
> in the string in fixincl.x,

This should work:

+    select   = "^([ \t]*[|&][|&][ \t(]*)"
+           "(|!defined\\([A-Z_]*\\)[ \t]*[|&][|&][ \t()]*)"
+               "__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0"
+               "(.*)";

The string being defined here is inside double quotes.
Therefore, the first backslash encountered is always
processed away.  That yields one in this case, internally.
When fixincl.x is emitted, it gets emitted into a C string
that has to be compiled.  So, the template doubles the
backslash again.  This is correct.  Finally, the string
in fixincl.x gets compiled and the compiler reduces the "\\("
to "\(" internally.  That is what the regex parser will see.

You can also do this:

+    select   = "^([ \t]*[|&][|&][ \t(]*)"
+           '(|!defined\([A-Z_]*\)' "[ \t]*[|&][|&][ \t()]*)"
+               "__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0"
+               "(.*)";

if that makes it easier for you to visualize.  End of AG-lesson.
Now, the fixinc issues:

You have apparently found a case where the match fails
because "!defined(A) <<log-op>>".  Lets fix that.

-    select   = "^([ \t]*[|&][|&][ \t(]*)"
-               "(__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)"
-               "(.*)";

First, I remove the trailing "(.*)" because it is pointless,
then I make a cosmetic change where we need to worry about the
``defined'' test.  now we have:

-    select   = "^([ \t]*[|&][|&]"
-               "[ \t(]*)(__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";

Now lets skip over arbitrary numbers of ``defined()'' tests:

-    select   = "^([ \t]*[|&][|&]"
-               "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[
\t]*[|&][|&])*"
-               "[ \t(]*)(__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
+    c_fix_arg = "%1 !defined(__STRICT_ANSI__)";

With this, we should only need one fix.  I haven't tested this,
but I will when I get home tonight.

WRT the test text, three backslashes ought to suffice on the 
continued lines.  cd into the gcc/fixinc build directory and
run "make check" to verify that all is working as expected.

Regards,
	Bruce


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]