aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.cumb.org>2000-01-20 18:25:12 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-01-20 18:25:12 +0000
commit52c207e293ff4337278208ed3638e3b5be78ae63 (patch)
tree088b6ad9fd2e111425c3ac61d68bf0b55e82c712
parentd3de1cf7f0f0e2c98460a3fb50b2aee18ddbdc51 (diff)
downloadgcc-52c207e293ff4337278208ed3638e3b5be78ae63.zip
gcc-52c207e293ff4337278208ed3638e3b5be78ae63.tar.gz
gcc-52c207e293ff4337278208ed3638e3b5be78ae63.tar.bz2
Makefile.in (fixinc.sh): Depend on specs.
* Makefile.in (fixinc.sh): Depend on specs. * fixinc/Makefile.in: Add rule to create machname.h. (fixlib.o): Depend on machname.h. * fixinc/fixtests.c (machine_name): New test. * fixinc/fixfixes.c (machine_name): New fix. * fixinc/fixlib.c (mn_get_regexps): New helper function for the machine_name test and fix. * fixinc/fixlib.h: Prototype it. * fixinc/inclhack.def (machine_name): Use the C test and fix. * fixinc/fixincl.x, fixinc/inclhack.sh: Rebuild. * gcc.c (do_spec_1) [case P]: Take care not to create identifiers with three leading or trailing underscores. * fixinc/Makefile.in (FIXINC_DEFS): Add -DIN_GCC. (fixincl): Don't specify libraries twice on link line. (gnu-regex.o): Remove special rule. * fixinc/gnu-regex.c: Define REGEX_MALLOC if C_ALLOCA was defined by config.h. Do not define _REGEX_RE_COMP. (regcomp): Allocate and initialize a fastmap. * fixinc/gnu-regex.h: Do not define _REGEX_RE_COMP. From-SVN: r31542
-rw-r--r--gcc/ChangeLog26
-rw-r--r--gcc/Makefile.in2
-rw-r--r--gcc/fixinc/Makefile.in24
-rw-r--r--gcc/fixinc/fixfixes.c101
-rw-r--r--gcc/fixinc/fixincl.x48
-rw-r--r--gcc/fixinc/fixlib.c31
-rw-r--r--gcc/fixinc/fixlib.h2
-rw-r--r--gcc/fixinc/fixtests.c49
-rw-r--r--gcc/fixinc/gnu-regex.c43
-rw-r--r--gcc/fixinc/gnu-regex.h5
-rw-r--r--gcc/fixinc/inclhack.def86
-rwxr-xr-xgcc/fixinc/inclhack.sh44
-rw-r--r--gcc/gcc.c21
13 files changed, 279 insertions, 203 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9f6a283..1c71eb3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,29 @@
+2000-01-20 Zack Weinberg <zack@wolery.cumb.org>
+
+ * Makefile.in (fixinc.sh): Depend on specs.
+ * fixinc/Makefile.in: Add rule to create machname.h.
+ (fixlib.o): Depend on machname.h.
+ * fixinc/fixtests.c (machine_name): New test.
+ * fixinc/fixfixes.c (machine_name): New fix.
+ * fixinc/fixlib.c (mn_get_regexps): New helper function for
+ the machine_name test and fix.
+ * fixinc/fixlib.h: Prototype it.
+ * fixinc/inclhack.def (machine_name): Use the C test and fix.
+ * fixinc/fixincl.x, fixinc/inclhack.sh: Rebuild.
+
+ * gcc.c (do_spec_1) [case P]: Take care not to create
+ identifiers with three leading or trailing underscores.
+
+ * fixinc/Makefile.in (FIXINC_DEFS): Add -DIN_GCC.
+ (fixincl): Don't specify libraries twice on link line.
+ (gnu-regex.o): Remove special rule.
+ * fixinc/gnu-regex.c: Define REGEX_MALLOC if C_ALLOCA was
+ defined by config.h. Do not define _REGEX_RE_COMP.
+ (regcomp): Allocate and initialize a fastmap.
+ * fixinc/gnu-regex.h: Do not define _REGEX_RE_COMP.
+
+
+
2000-01-20 Brad Lucier <lucier@math.purdue.edu>
* Makefile.in (predict.o): Depend on $(EXPR_H), not expr.h.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 89d2508..8d91ab3 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2161,7 +2161,7 @@ FIXINCSRCDIR=$(srcdir)/fixinc
fixinc.sh: $(FIXINCSRCDIR)/mkfixinc.sh $(FIXINCSRCDIR)/fixincl.c \
$(FIXINCSRCDIR)/procopen.c $(FIXINCSRCDIR)/gnu-regex.c \
$(FIXINCSRCDIR)/server.c $(FIXINCSRCDIR)/gnu-regex.h \
- $(FIXINCSRCDIR)/server.h $(FIXINCSRCDIR)/inclhack.def
+ $(FIXINCSRCDIR)/server.h $(FIXINCSRCDIR)/inclhack.def specs
MAKE="$(MAKE)"; srcdir=`cd $(srcdir)/fixinc; pwd` ; \
export MAKE srcdir ; \
cd ./fixinc; $(SHELL) $${srcdir}/mkfixinc.sh $(target)
diff --git a/gcc/fixinc/Makefile.in b/gcc/fixinc/Makefile.in
index a2448c1..43d3855 100644
--- a/gcc/fixinc/Makefile.in
+++ b/gcc/fixinc/Makefile.in
@@ -22,7 +22,7 @@
# Its purpose is to build the any-platforms fixinc.sh script.
CFLAGS = -g
-FIXINC_DEFS = $(CFLAGS) $(CPPFLAGS) @fixinc_defs@ $(INCLUDES)
+FIXINC_DEFS = -DIN_GCC $(CFLAGS) $(CPPFLAGS) @fixinc_defs@ $(INCLUDES)
CC = @CC@
SHELL = /bin/sh
@@ -77,8 +77,8 @@ gen : $(SH_TARGET) fixincl.x
$(FIOBJ): $(HDR)
fixincl: $(FIOBJ)
- @echo $(CC) -o $@ $(FIOBJ) $(LIBERTY) $(LIB) ; \
- if $(CC) -o $@ $(FIOBJ) $(LIBERTY) $(LIB) ; then : ; else \
+ @echo $(CC) $(FIXINC_DEFS) -o $@ $(FIOBJ) ; \
+ if $(CC) $(FIXINC_DEFS) -o $@ $(FIOBJ) ; then : ; else \
rm -f $@ ; (echo "#! /bin/sh" ; echo exit 1 ) > $@ ; \
chmod 777 $@ ; fi
@@ -90,13 +90,10 @@ fixtests: fixtests.c $(LIBOBJ)
$(CC) -o $@ $(FIXINC_DEFS) -DMAIN \
$(srcdir)/fixtests.c $(LIBOBJ) $(LIB)
-gnu-regex.o: gnu-regex.c
- -$(CC) $(CFLAGS) $(FIXINC_DEFS) $(INCLUDES) -DREGEX_MALLOC \
- -c $(srcdir)/gnu-regex.c
-
fixincl.o : fixincl.x fixincl.c fixfixes.c fixtests.c
server.o : server.c server.h
procopen.o : procopen.c server.h
+fixlib.o: machname.h
fixincl.x: fixincl.tpl inclhack.def
cd $(srcdir) ; ./genfixes $@
@@ -139,3 +136,16 @@ install: $(TARGETS)
Makefile: Makefile.in ../config.status
cd .. \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+# Black magic.
+# Note dependency on ASCII. \040 = space, \011 = tab, \012 = newline.
+
+machname.h: ../specs
+ @tr -s '\040\011' '\012\012' < ../specs | \
+ sed -n 's/^.*-D\([a-zA-Z_][a-zA-Z0-9_]*\).*$$/\1/p' | sort -u | \
+ grep -v '^_[_A-Z]' > mn.T
+ @echo "Forbidden identifiers: `tr '\012' ' ' <mn.T`"
+ @sed 's/^/\\\\</; s/$$/\\\\>/' <mn.T | tr '\012' '|' | \
+ sed 's/^/#define MN_NAME_PAT "/; s/|$$/"/' > machname.h
+ @echo >> machname.h
+ @-rm -f mn.T
diff --git a/gcc/fixinc/fixfixes.c b/gcc/fixinc/fixfixes.c
index 33f5f19..109c611 100644
--- a/gcc/fixinc/fixfixes.c
+++ b/gcc/fixinc/fixfixes.c
@@ -77,7 +77,8 @@ typedef struct {
_FT_( "IO_use", IO_use_fix ) \
_FT_( "CTRL_use", CTRL_use_fix) \
_FT_( "IO_defn", IO_defn_fix ) \
- _FT_( "CTRL_defn", CTRL_defn_fix )
+ _FT_( "CTRL_defn", CTRL_defn_fix ) \
+ _FT_( "machine_name", machine_name_fix )
#define FIX_PROC_HEAD( fix ) \
@@ -548,6 +549,104 @@ FIX_PROC_HEAD( CTRL_defn_fix )
}
+/* Fix for machine name #ifdefs that are not in the namespace reserved
+ by the C standard. They won't be defined if compiling with -ansi,
+ and the headers will break. We go to some trouble to only change
+ #ifdefs where the macro is defined by GCC in non-ansi mode; this
+ minimizes the number of headers touched. */
+
+#define SCRATCHSZ 64 /* hopefully long enough */
+
+FIX_PROC_HEAD( machine_name_fix )
+{
+ regmatch_t match[2];
+ char *line, *base, *limit, *p, *q;
+ regex_t *label_re, *name_re;
+ char scratch[SCRATCHSZ];
+ size_t len;
+
+ mn_get_regexps (&label_re, &name_re, "machine_name_fix");
+ scratch[0] = '_';
+ scratch[1] = '_';
+
+ for (base = text;
+ regexec (label_re, base, 2, match, 0) == 0;
+ base = limit)
+ {
+ base += match[0].rm_eo;
+ /* We're looking at an #if or #ifdef. Scan forward for the
+ next non-escaped newline. */
+ line = limit = base;
+ do
+ {
+ limit++;
+ limit = strchr (limit, '\n');
+ if (!limit)
+ goto done;
+ }
+ while (limit[-1] == '\\');
+
+ /* If the 'name_pat' matches in between base and limit, we have
+ a bogon. It is not worth the hassle of excluding comments
+ because comments on #if/#ifdef lines are rare, and strings on
+ such lines are illegal.
+
+ REG_NOTBOL means 'base' is not at the beginning of a line, which
+ shouldn't matter since the name_re has no ^ anchor, but let's
+ be accurate anyway. */
+
+ for (;;)
+ {
+ again:
+ if (base == limit)
+ break;
+
+ if (regexec (name_re, base, 1, match, REG_NOTBOL))
+ goto done; /* No remaining match in this file */
+
+ /* Match; is it on the line? */
+ if (match[0].rm_eo > limit - base)
+ break;
+
+ p = base + match[0].rm_so;
+ base += match[0].rm_eo;
+
+ /* One more test: if on the same line we have the same string
+ with the appropriate underscores, then leave it alone.
+ We want exactly two leading and trailing underscores. */
+ if (*p == '_')
+ {
+ len = base - p - ((*base == '_') ? 2 : 1);
+ q = p + 1;
+ }
+ else
+ {
+ len = base - p - ((*base == '_') ? 1 : 0);
+ q = p;
+ }
+ if (len + 4 > SCRATCHSZ)
+ abort ();
+ memcpy (&scratch[2], q, len);
+ len += 2;
+ scratch[len++] = '_';
+ scratch[len++] = '_';
+
+ for (q = line; q <= limit - len; q++)
+ if (*q == '_' && !strncmp (q, scratch, len))
+ goto again;
+
+ fwrite (text, 1, p - text, stdout);
+ fwrite (scratch, 1, len, stdout);
+
+ text = base;
+ }
+ }
+ done:
+ fputs (text, stdout);
+ free (scratch);
+}
+
+
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
test for fix selector
diff --git a/gcc/fixinc/fixincl.x b/gcc/fixinc/fixincl.x
index 64d7367..5c40891 100644
--- a/gcc/fixinc/fixincl.x
+++ b/gcc/fixinc/fixincl.x
@@ -2341,56 +2341,18 @@ tSCC zMachine_NameName[] =
#define apzMachine_NameMachs (const char**)NULL
/*
- * content selection pattern - do fix if pattern found
- * This is a special pattern that not all egrep commands
- * are capable of coping with. We use the GNU library, tho :)
+ * perform the C function call test
*/
-tSCC zMachine_NameSelect0[] =
- "^#[ \t]*(if|elif).*[^a-zA-Z0-9_](M32|_*MIPSE[LB]|_*SYSTYPE_[A-Z0-9]|_*[Rr][34]000|_*host_mips|_*i386|_*mips|bsd4|is68k|m[68]8k|mc680|news|ns32000|pdp11|pyr|sel|sony_news|sparc|sun|tahoe|tower|u370|u3b|unix|vax)";
+tSCC zMachine_NameFTst0[] = "machine_name";
#define MACHINE_NAME_TEST_CT 1
tTestDesc aMachine_NameTests[] = {
- { TT_EGREP, zMachine_NameSelect0, (regex_t*)NULL }, };
+ { TT_FUNCTION, zMachine_NameFTst0, 0 /* unused */ }, };
/*
* Fix Command Arguments for Machine_Name
*/
-const char* apzMachine_NamePatch[] = { "sed",
- "-e", ":loop\n\
-/\\\\$/N\n\
-s/\\\\$/\\\\+++fixinc_eol+++/\n\
-/\\\\$/b loop\n\
-s/\\\\+++fixinc_eol+++/\\\\/g\n\
-/#[\t ]*[el]*if/ {\n\
-\ts/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g\n\
-\ts/ M32 / __M32__ /g\n\
-\ts/ _*MIPSE\\([LB]\\) / __MIPSE\\1__ /g\n\
-\ts/ _*SYSTYPE_\\([A-Z0-9]*\\) / __SYSTYPE_\\1__ /g\n\
-\ts/ _*\\([Rr][34]\\)000 / __\\1000__ /g\n\
-\ts/ _*host_mips / __host_mips__ /g\n\
-\ts/ _*i386 / __i386__ /g\n\
-\ts/ _*mips / __mips__ /g\n\
-\ts/ bsd4\\([0-9]\\) / __bsd4\\1__ /g\n\
-\ts/ is68k / __is68k__ /g\n\
-\ts/ m68k / __m68k__ /g\n\
-\ts/ m88k / __m88k__ /g\n\
-\ts/ mc680\\([0-9]\\)0 / __mc680\\10__ /g\n\
-\ts/ news\\([0-9]*\\) / __news\\1__ /g\n\
-\ts/ ns32000 / __ns32000__ /g\n\
-\ts/ pdp11 / __pdp11__ /g\n\
-\ts/ pyr / __pyr__ /g\n\
-\ts/ sel / __sel__ /g\n\
-\ts/ sony_news / __sony_news__ /g\n\
-\ts/ sparc / __sparc__ /g\n\
-\ts/ sun\\([a-z0-9]*\\) / __sun\\1__ /g\n\
-\ts/ tahoe / __tahoe__ /g\n\
-\ts/ tower\\([_0-9]*\\) / __tower\\1__ /g\n\
-\ts/ u370 / __u370__ /g\n\
-\ts/ u3b\\([0-9]*\\) / __u3b\\1__ /g\n\
-\ts/ unix / __unix__ /g\n\
-\ts/ vax / __vax__ /g\n\
-\ts/ \\([a-zA-Z0-9_][a-zA-Z0-9_]*\\) /\\1/g\n\
-\t}",
+const char* apzMachine_NamePatch[] = {"machine_name",
(char*)NULL };
/* * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -4696,7 +4658,7 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
{ zMachine_NameName, zMachine_NameList,
apzMachine_NameMachs, (regex_t*)NULL,
- MACHINE_NAME_TEST_CT, FD_MACH_ONLY,
+ MACHINE_NAME_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
aMachine_NameTests, apzMachine_NamePatch },
{ zMath_ExceptionName, zMath_ExceptionList,
diff --git a/gcc/fixinc/fixlib.c b/gcc/fixinc/fixlib.c
index 40d2bbb..edd0be6 100644
--- a/gcc/fixinc/fixlib.c
+++ b/gcc/fixinc/fixlib.c
@@ -171,3 +171,34 @@ compile_re( pat, re, match, e1, e2 )
exit (EXIT_FAILURE);
}
}
+
+/* * * * * * * * * * * * *
+
+ Helper routine and data for the machine_name test and fix.
+ machname.h is created by black magic in the Makefile. */
+
+#include "machname.h"
+
+tSCC mn_label_pat[] = "^[ \t]*#[ \t]*(if|ifdef|ifndef)[ \t]+";
+static regex_t mn_label_re;
+
+tSCC mn_name_pat[] = MN_NAME_PAT;
+static regex_t mn_name_re;
+
+static int mn_compiled = 0;
+
+void
+mn_get_regexps( label_re, name_re, who )
+ regex_t **label_re;
+ regex_t **name_re;
+ tCC *who;
+{
+ if (! mn_compiled)
+ {
+ compile_re (mn_label_pat, &mn_label_re, 1, "label pattern", who);
+ compile_re (mn_name_pat, &mn_name_re, 1, "name pattern", who);
+ mn_compiled++;
+ }
+ *label_re = &mn_label_re;
+ *name_re = &mn_name_re;
+}
diff --git a/gcc/fixinc/fixlib.h b/gcc/fixinc/fixlib.h
index 76cb3a9..22ab56a 100644
--- a/gcc/fixinc/fixlib.h
+++ b/gcc/fixinc/fixlib.h
@@ -99,4 +99,6 @@ char * load_file_data _P_(( FILE* fp ));
t_bool is_cxx_header _P_(( tCC* filename, tCC* filetext ));
void compile_re _P_(( tCC* pat, regex_t* re, int match,
tCC *e1, tCC *e2 ));
+void mn_get_regexps _P_(( regex_t** label_re, regex_t** name_re,
+ tCC *who ));
#endif /* FIXINCLUDES_FIXLIB_H */
diff --git a/gcc/fixinc/fixtests.c b/gcc/fixinc/fixtests.c
index 22fea35..72fa7ee 100644
--- a/gcc/fixinc/fixtests.c
+++ b/gcc/fixinc/fixtests.c
@@ -58,7 +58,8 @@ typedef struct {
#define FIX_TEST_TABLE \
_FT_( "double_slash", double_slash_test ) \
- _FT_( "else_endif_label", else_endif_label_test )
+ _FT_( "else_endif_label", else_endif_label_test ) \
+ _FT_( "machine_name", machine_name_test )
#define TEST_FOR_FIX_PROC_HEAD( test ) \
@@ -268,6 +269,52 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test )
return SKIP_FIX;
}
+TEST_FOR_FIX_PROC_HEAD( machine_name_test )
+{
+ regex_t *label_re, *name_re;
+ regmatch_t match[2];
+ tCC *base, *limit;
+
+ mn_get_regexps(&label_re, &name_re, "machine_name_test");
+
+ for (base = text;
+ regexec (label_re, base, 2, match, 0) == 0;
+ base = limit)
+ {
+ base += match[0].rm_eo;
+ /* We're looking at an #if or #ifdef. Scan forward for the
+ next non-escaped newline. */
+ limit = base;
+ do
+ {
+ limit++;
+ limit = strchr (limit, '\n');
+ if (!limit)
+ return SKIP_FIX;
+ }
+ while (limit[-1] == '\\');
+
+ /* If the 'name_pat' matches in between base and limit, we have
+ a bogon. It is not worth the hassle of excluding comments,
+ because comments on #if/#ifdef/#ifndef lines are rare,
+ and strings on such lines are illegal.
+
+ REG_NOTBOL means 'base' is not at the beginning of a line, which
+ shouldn't matter since the name_re has no ^ anchor, but let's
+ be accurate anyway. */
+
+ if (regexec (name_re, base, 1, match, REG_NOTBOL))
+ return SKIP_FIX; /* No match in file - no fix needed */
+
+ /* Match; is it on the line? */
+ if (match[0].rm_eo < limit - base)
+ return APPLY_FIX; /* Yup */
+
+ /* Otherwise, keep looking... */
+ }
+ return SKIP_FIX;
+}
+
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
diff --git a/gcc/fixinc/gnu-regex.c b/gcc/fixinc/gnu-regex.c
index b24845b..007aec1 100644
--- a/gcc/fixinc/gnu-regex.c
+++ b/gcc/fixinc/gnu-regex.c
@@ -21,11 +21,6 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* AIX requires this to be the first thing in the file. */
-#if defined _AIX && !defined REGEX_MALLOC
- #pragma alloca
-#endif
-
#undef _GNU_SOURCE
#define _GNU_SOURCE
@@ -33,6 +28,16 @@
# include <config.h>
#endif
+/* Do not use a C alloca, we will leak memory and crash. */
+#ifdef C_ALLOCA
+# define REGEX_MALLOC
+#endif
+
+/* AIX requires this to be the first thing in the file. */
+#if defined _AIX && !defined REGEX_MALLOC
+ #pragma alloca
+#endif
+
#ifndef PARAMS
# if defined __GNUC__ || (defined __STDC__ && __STDC__)
# define PARAMS(args) args
@@ -153,11 +158,6 @@ char *realloc ();
/* How many characters in the character set. */
# define CHAR_SET_SIZE 256
-/* GDB LOCAL: define _REGEX_RE_COMP to get BSD style re_comp and re_exec */
-#ifndef _REGEX_RE_COMP
-#define _REGEX_RE_COMP
-#endif
-
# ifdef SYNTAX_TABLE
extern char *re_syntax_table;
@@ -5561,7 +5561,8 @@ re_exec (s)
REG_EXTENDED bit in CFLAGS is set; otherwise, to
RE_SYNTAX_POSIX_BASIC;
`newline_anchor' to REG_NEWLINE being set in CFLAGS;
- `fastmap' and `fastmap_accurate' to zero;
+ `fastmap' to an allocated space for the fastmap;
+ `fastmap_accurate' to 1;
`re_nsub' to the number of subexpressions in PATTERN.
PATTERN is the address of the pattern string.
@@ -5600,11 +5601,8 @@ regcomp (preg, pattern, cflags)
preg->allocated = 0;
preg->used = 0;
- /* Don't bother to use a fastmap when searching. This simplifies the
- REG_NEWLINE case: if we used a fastmap, we'd have to put all the
- characters after newlines into the fastmap. This way, we just try
- every character. */
- preg->fastmap = 0;
+ /* Try to allocate space for the fastmap. */
+ preg->fastmap = (char *) malloc (1 << BYTEWIDTH);
if (cflags & REG_ICASE)
{
@@ -5644,6 +5642,19 @@ regcomp (preg, pattern, cflags)
unmatched close-group: both are REG_EPAREN. */
if (ret == REG_ERPAREN) ret = REG_EPAREN;
+ if (ret == REG_NOERROR && preg->fastmap)
+ {
+ /* Compute the fastmap now, since regexec cannot modify the pattern
+ buffer. */
+ if (re_compile_fastmap (preg) == -2)
+ {
+ /* Some error occured while computing the fastmap, just forget
+ about it. */
+ free (preg->fastmap);
+ preg->fastmap = NULL;
+ }
+ }
+
return (int) ret;
}
#ifdef _LIBC
diff --git a/gcc/fixinc/gnu-regex.h b/gcc/fixinc/gnu-regex.h
index 9153ea1..57a4f14 100644
--- a/gcc/fixinc/gnu-regex.h
+++ b/gcc/fixinc/gnu-regex.h
@@ -36,11 +36,6 @@ extern "C" {
# include <stddef.h>
#endif
-/* GDB LOCAL: define _REGEX_RE_COMP to get BSD style re_comp and re_exec */
-#ifndef _REGEX_RE_COMP
-#define _REGEX_RE_COMP
-#endif
-
/* The following two types have to be signed and unsigned integer type
wide enough to hold a value of a pointer. For most ANSI compilers
ptrdiff_t and size_t should be likely OK. Still size of these two
diff --git a/gcc/fixinc/inclhack.def b/gcc/fixinc/inclhack.def
index 5f804b2..370ac253 100644
--- a/gcc/fixinc/inclhack.def
+++ b/gcc/fixinc/inclhack.def
@@ -1253,93 +1253,11 @@ fix = {
/*
* Fix non-ansi machine name defines
- * File selection is split into two parts: the shell version as
- * a single patch, and the program version with each patch separate.
- * Each is substantially faster for the particular environment.
- * You have a dual maintenance problem here.
*/
fix = {
hackname = machine_name;
- /*
- * Select '#if.*' and '#elif" with possible non-ansi symbols
- * The only non-ansi symbols we know about start with one of:
- * MRS_bhimnprstuv
- * If any are added to the substitution list, then add it to
- * the selection list as well. Hopefully we can avoid names
- * starting with "d" and "l", because this pattern would then
- * match "defined" and "lint" as well. I suppose we could add
- * a "bypass = lint" if we had to though.
- *
- * The fixinc_eol stuff is to work around a bug in the sed
- */
- select = "^#[ \t]*(if|elif).*"
- "[^a-zA-Z0-9_](_*[MSRrhim]|[Mbimnpstuv])[a-zA-Z0-9_]";
- exesel = "^#[ \t]*(if|elif).*[^a-zA-Z0-9_]"
- "("
- "M32"
- "|_*MIPSE[LB]"
- "|_*SYSTYPE_[A-Z0-9]"
- "|_*[Rr][34]000"
- "|_*host_mips"
- "|_*i386"
- "|_*mips"
- "|bsd4"
- "|is68k"
- "|m[68]8k"
- "|mc680"
- "|news"
- "|ns32000"
- "|pdp11"
- "|pyr"
- "|sel"
- "|sony_news"
- "|sparc"
- "|sun"
- "|tahoe"
- "|tower"
- "|u370"
- "|u3b"
- "|unix"
- "|vax"
- ")";
-
- sed = ":loop\n"
- '/\\\\$/' "N\n"
- 's/\\\\$/\\\\+++fixinc_eol+++/' "\n"
- '/\\\\$/' "b loop\n"
- 's/\\\\+++fixinc_eol+++/\\\\/g' "\n"
-
- "/#[\t ]*[el]*if/ {\n"
- "\ts/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g\n"
-
- "\ts/ M32 / __M32__ /g\n"
- "\ts/ _*MIPSE\\([LB]\\) / __MIPSE\\1__ /g\n"
- "\ts/ _*SYSTYPE_\\([A-Z0-9]*\\) / __SYSTYPE_\\1__ /g\n"
- "\ts/ _*\\([Rr][34]\\)000 / __\\1000__ /g\n"
- "\ts/ _*host_mips / __host_mips__ /g\n"
- "\ts/ _*i386 / __i386__ /g\n"
- "\ts/ _*mips / __mips__ /g\n"
- "\ts/ bsd4\\([0-9]\\) / __bsd4\\1__ /g\n"
- "\ts/ is68k / __is68k__ /g\n"
- "\ts/ m68k / __m68k__ /g\n"
- "\ts/ m88k / __m88k__ /g\n"
- "\ts/ mc680\\([0-9]\\)0 / __mc680\\10__ /g\n"
- "\ts/ news\\([0-9]*\\) / __news\\1__ /g\n"
- "\ts/ ns32000 / __ns32000__ /g\n"
- "\ts/ pdp11 / __pdp11__ /g\n"
- "\ts/ pyr / __pyr__ /g\n"
- "\ts/ sel / __sel__ /g\n"
- "\ts/ sony_news / __sony_news__ /g\n"
- "\ts/ sparc / __sparc__ /g\n"
- "\ts/ sun\\([a-z0-9]*\\) / __sun\\1__ /g\n"
- "\ts/ tahoe / __tahoe__ /g\n"
- "\ts/ tower\\([_0-9]*\\) / __tower\\1__ /g\n"
- "\ts/ u370 / __u370__ /g\n"
- "\ts/ u3b\\([0-9]*\\) / __u3b\\1__ /g\n"
- "\ts/ unix / __unix__ /g\n"
- "\ts/ vax / __vax__ /g\n"
-
- "\ts/ \\([a-zA-Z0-9_][a-zA-Z0-9_]*\\) /\\1/g\n\t}";
+ c_test = machine_name;
+ c_fix = machine_name;
};
diff --git a/gcc/fixinc/inclhack.sh b/gcc/fixinc/inclhack.sh
index c68f2d7..7de99b6 100755
--- a/gcc/fixinc/inclhack.sh
+++ b/gcc/fixinc/inclhack.sh
@@ -1995,53 +1995,17 @@ static __inline__ double fake_hypot (x, y)\
#
# Fix Machine_Name
#
- if ( test -n "`egrep '^#[ ]*(if|elif).*[^a-zA-Z0-9_](_*[MSRrhim]|[Mbimnpstuv])[a-zA-Z0-9_]' ${file}`"
- ) > /dev/null 2>&1 ; then
+ if ${FIXTESTS} ${file} machine_name
+ then
fixlist="${fixlist}
machine_name"
if [ ! -r ${DESTFILE} ]
then infile=${file}
else infile=${DESTFILE} ; fi
-
- sed -e ':loop
-/\\$/N
-s/\\$/\\+++fixinc_eol+++/
-/\\$/b loop
-s/\\+++fixinc_eol+++/\\/g
-/#[ ]*[el]*if/ {
- s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g
- s/ M32 / __M32__ /g
- s/ _*MIPSE\([LB]\) / __MIPSE\1__ /g
- s/ _*SYSTYPE_\([A-Z0-9]*\) / __SYSTYPE_\1__ /g
- s/ _*\([Rr][34]\)000 / __\1000__ /g
- s/ _*host_mips / __host_mips__ /g
- s/ _*i386 / __i386__ /g
- s/ _*mips / __mips__ /g
- s/ bsd4\([0-9]\) / __bsd4\1__ /g
- s/ is68k / __is68k__ /g
- s/ m68k / __m68k__ /g
- s/ m88k / __m88k__ /g
- s/ mc680\([0-9]\)0 / __mc680\10__ /g
- s/ news\([0-9]*\) / __news\1__ /g
- s/ ns32000 / __ns32000__ /g
- s/ pdp11 / __pdp11__ /g
- s/ pyr / __pyr__ /g
- s/ sel / __sel__ /g
- s/ sony_news / __sony_news__ /g
- s/ sparc / __sparc__ /g
- s/ sun\([a-z0-9]*\) / __sun\1__ /g
- s/ tahoe / __tahoe__ /g
- s/ tower\([_0-9]*\) / __tower\1__ /g
- s/ u370 / __u370__ /g
- s/ u3b\([0-9]*\) / __u3b\1__ /g
- s/ unix / __unix__ /g
- s/ vax / __vax__ /g
- s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g
- }' \
- < $infile > ${DESTDIR}/fixinc.tmp
+ ${FIXFIXES} ${file} machine_name < $infile > ${DESTDIR}/fixinc.tmp
rm -f ${DESTFILE}
mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}
- fi # end of select 'if'
+ fi # end of c_test 'if'
#
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 7c77d46..6ad53f0 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -4263,7 +4263,12 @@ do_spec_1 (spec, inswitch, soft_matched_part)
char *y;
/* Copy all of CPP_PREDEFINES into BUF,
- but put __ after every -D and at the end of each arg. */
+ but force them all into the reserved name space if they aren't already there. The reserved name space is all
+ identifiers beginning with two underscores or with one
+ underscore and a capital letter. We do the forcing by
+ adding up to two underscores to the beginning and end
+ of each symbol. e.g. mips, _mips, mips_, and _mips_ all
+ become __mips__. */
y = cpp_predefines;
while (*y != 0)
{
@@ -4279,7 +4284,8 @@ do_spec_1 (spec, inswitch, soft_matched_part)
&& ! ISUPPER ((unsigned char)*(y+1))))
{
/* Stick __ at front of macro name. */
- *x++ = '_';
+ if (*y != '_')
+ *x++ = '_';
*x++ = '_';
/* Arrange to stick __ at the end as well. */
flag = 1;
@@ -4291,8 +4297,12 @@ do_spec_1 (spec, inswitch, soft_matched_part)
if (flag)
{
- *x++ = '_';
- *x++ = '_';
+ if (x[-1] != '_')
+ {
+ if (x[-2] != '_')
+ *x++ = '_';
+ *x++ = '_';
+ }
}
/* Copy the value given, if any. */
@@ -4324,7 +4334,8 @@ do_spec_1 (spec, inswitch, soft_matched_part)
/* Stick -D__ at front of macro name. */
*x++ = '-';
*x++ = 'D';
- *x++ = '_';
+ if (*y != '_')
+ *x++ = '_';
*x++ = '_';
/* Copy the macro name. */