This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: fixinc/inclhack.def for UnixWare 2.1.3
- From: rbrown64 at csc dot com dot au
- To: Bruce Korb <bkorb at veritas dot com>
- Cc: GCC-patches <gcc-patches at gcc dot gnu dot org>, Bruce Korb <bkorb at pacbell dot net>
- Date: Wed, 12 Dec 2001 15:44:14 +1100
- Subject: Re: PATCH: fixinc/inclhack.def for UnixWare 2.1.3
Thank you for your patient explanation. Of course the backslashes must be
doubled
in the C strings. Here is the latest version of the patch.
It has been tested with
cd gcc/fixinc; make clean ; cd .. ; rm -rf stmp-fixinc fixinc.sh include ;
make stmp-fixinc
on UnixWare 2.1.3 and UnixWare 7.1.0 with no changes to the relevant files.
I'll try a make check at home this evening.
Here is the fragment from sys/signal.h that previously needed strict_ansi_not_ctd2 .
#if (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 >= 1) || \
- ( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \
+ ( !defined(__STRICT_ANSI__) && !defined(_XOPEN_SOURCE) \
&& !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE))
The select expression is your suggestions with the leading || or && made optional
and some extra parenthesis in the ranges.
20011212 Rodney Brown <rbrown64@csc.com.au>
* fixinc/inclhack.def (strict_ansi_not_ctd): Update for UnixWare 2.1.3.
* fixinc/mkfixinc.sh: Use C fixincludes for UnixWare 2.1.3.
--- gcc/fixinc/inclhack.def.orig Tue Dec 11 11:35:23 2001
+++ gcc/fixinc/inclhack.def Wed Dec 12 15:33:03 2001
@@ -2278,17 +2278,24 @@
*/
fix = {
hackname = strict_ansi_not_ctd;
- files = math.h, limits.h, stdio.h, signal.h, stdlib.h, time.h;
- select = "^([ \t]*[|&][|&][ \t(]*)"
- "(__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0"
- ")(.*)";
+ files = math.h, limits.h, stdio.h, signal.h, stdlib.h, sys/signal.h, time.h;
+ select = "^((|[ \t]*[|&][|&])"
+ "(|[ \t\(]*!*[ \t]*defined\\([a-zA-Z0-9_]*\\)[ \t)]*[|&][|&])*"
+ "[ \t(]*)__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0";
c_test = stdc_0_in_system_headers;
c_fix = format;
- c_fix_arg = "%1 !defined(__STRICT_ANSI__)%3";
+ c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
test_text = "#if 1\\\n"
- "|| __STDC__ - 0 == 0 /* not std C */\nint foo;\n#endif";
+ "|| __STDC__ - 0 == 0 /* not std C */\\\n"
+ "&& !defined(A) && __STDC__ - 0 == 0 \\\n"
+ "&& __STDC__ == 0 \\\n"
+ "|| !defined(A) || __STDC__ - 0 == 0 \\\n"
+ "|| __STDC__ == 0 || \\\n"
+ " ( __STDC__ - 0 == 0 ) || /* not std C */\\\n"
+ " ( __STDC__ == 0) \n"
+ "int foo;\n#endif";
};
/*
UX:sh (sh): ERROR: ---: Not found
+++ gcc/fixinc/mkfixinc.sh Wed Dec 12 12:53:08 2001
@@ -35,6 +35,9 @@
# Check for special fix rules for particular targets
case $machine in
+ i?86-*-sysv4.2uw2*)
+ ;;
+
*-*-sysv4* )
fixincludes=fixinc.svr4
;;
Bruce Korb <bkorb@veritas.com>@svldns02.veritas.com on 12/12/2001 07:50:55
Sent by: bkorb@svldns02.veritas.com
To: Rodney Brown <rbrown64@csc.com.au>, GCC-patches
<gcc-patches@gcc.gnu.org>
cc: Bruce Korb <bkorb@pacbell.net>
Subject: 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