summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fixinc/fixfixes.c66
-rw-r--r--gcc/fixinc/tests/base/assert.h12
-rw-r--r--gcc/fixinc/tests/base/math.h12
-rw-r--r--gcc/fixinc/tests/base/stdio.h6
-rw-r--r--gcc/fixinc/tests/base/strings.h6
-rw-r--r--gcc/fixinc/tests/base/sys/mman.h6
7 files changed, 57 insertions, 56 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4fe99f7ad03..3de1fc84ad9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2003-01-04 Bruce Korb <bkorb@gnu.org>
+
+ * fixinc/fixfixes.c(wrap_fix): the wrapper guard must be a function
+ of *both* the file name and the fix name.
+
2002-01-04 John David Anglin <dave.anglin@nrc.ca>
* config.gcc (hppa*64*-*-hpux11*): Define extra_parts. Don't use
diff --git a/gcc/fixinc/fixfixes.c b/gcc/fixinc/fixfixes.c
index ad54960d13b..9c775b55425 100644
--- a/gcc/fixinc/fixfixes.c
+++ b/gcc/fixinc/fixfixes.c
@@ -597,47 +597,44 @@ FIX_PROC_HEAD( wrap_fix )
tSCC z_no_wrap_pat[] = "^#if.*__need_";
static regex_t no_wrapping_re; /* assume zeroed data */
- char z_fixname[ 64 ];
- tCC* pz_src = p_fixd->fix_name;
- tCC* pz_name = z_fixname;
- char* pz_dst = z_fixname;
- int do_end = 0;
- size_t len = 0;
- IGNORE_ARG(filname);
+ tCC* pz_name = NULL;
if (no_wrapping_re.allocated == 0)
compile_re( z_no_wrap_pat, &no_wrapping_re, 0, "no-wrap pattern",
"wrap-fix" );
- for (;;) {
- char ch = *pz_src++;
-
- if (ch == NUL) {
- *pz_dst++ = ch;
- break;
- } else if (! ISALNUM (ch)) {
- *pz_dst++ = '_';
- } else {
- *pz_dst++ = TOUPPER (ch);
- }
-
- if (++len >= sizeof( z_fixname )) {
- void* p = xmalloc( len + strlen( pz_src ) + 1 );
- memcpy( p, (void*)z_fixname, len );
- pz_name = (tCC*)p;
- pz_dst = (char*)pz_name + len;
- }
- }
-
/*
* IF we do *not* match the no-wrap re, then we have a double negative.
* A double negative means YES.
*/
- if (regexec (&no_wrapping_re, text, 0, NULL, 0) != 0)
+ if (regexec( &no_wrapping_re, text, 0, NULL, 0 ) != 0)
{
- printf( "#ifndef FIXINC_%s_CHECK\n", pz_name );
- printf( "#define FIXINC_%s_CHECK 1\n\n", pz_name );
- do_end = 1;
+ /*
+ * A single file can get wrapped more than once by different fixes.
+ * A single fix can wrap multiple files. Therefore, guard with
+ * *both* the fix name and the file name.
+ */
+ size_t ln = strlen( filname ) + strlen( p_fixd->fix_name ) + 14;
+ char* pz = xmalloc( ln );
+ pz_name = pz;
+ sprintf( pz, "FIXINC_WRAP_%s-%s", filname, p_fixd->fix_name );
+
+ for (pz += 12; 1; pz++) {
+ char ch = *pz;
+
+ if (ch == NUL)
+ break;
+
+ if (! ISALNUM( ch )) {
+ *pz = '_';
+ }
+ else {
+ *pz = TOUPPER( ch );
+ }
+ }
+
+ printf( "#ifndef %s\n", pz_name );
+ printf( "#define %s 1\n\n", pz_name );
}
if (p_fixd->patch_args[1] == (tCC*)NULL)
@@ -650,11 +647,10 @@ FIX_PROC_HEAD( wrap_fix )
fputs( p_fixd->patch_args[2], stdout );
}
- if (do_end != 0)
- printf( "\n#endif /* FIXINC_%s_CHECK */\n", pz_name );
-
- if (pz_name != z_fixname)
+ if (pz_name != NULL) {
+ printf( "\n#endif /* %s */\n", pz_name );
free( (void*)pz_name );
+ }
}
diff --git a/gcc/fixinc/tests/base/assert.h b/gcc/fixinc/tests/base/assert.h
index 5140e892e3c..2642cbe49c4 100644
--- a/gcc/fixinc/tests/base/assert.h
+++ b/gcc/fixinc/tests/base/assert.h
@@ -7,14 +7,14 @@
This had to be done to correct non-standard usages in the
original, manufacturer supplied header file. */
-#ifndef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
-#define FIXINC_BROKEN_ASSERT_STDLIB_CHECK 1
+#ifndef FIXINC_WRAP_ASSERT_H_BROKEN_ASSERT_STDLIB
+#define FIXINC_WRAP_ASSERT_H_BROKEN_ASSERT_STDLIB 1
#ifdef __cplusplus
#include <stdlib.h>
#endif
-#ifndef FIXINC_BROKEN_ASSERT_STDIO_CHECK
-#define FIXINC_BROKEN_ASSERT_STDIO_CHECK 1
+#ifndef FIXINC_WRAP_ASSERT_H_BROKEN_ASSERT_STDIO
+#define FIXINC_WRAP_ASSERT_H_BROKEN_ASSERT_STDIO 1
#include <stdio.h>
@@ -38,6 +38,6 @@ extern FILE* stderr;
extern void exit ( int );
#endif /* BROKEN_ASSERT_STDLIB_CHECK */
-#endif /* FIXINC_BROKEN_ASSERT_STDIO_CHECK */
+#endif /* FIXINC_WRAP_ASSERT_H_BROKEN_ASSERT_STDIO */
-#endif /* FIXINC_BROKEN_ASSERT_STDLIB_CHECK */
+#endif /* FIXINC_WRAP_ASSERT_H_BROKEN_ASSERT_STDLIB */
diff --git a/gcc/fixinc/tests/base/math.h b/gcc/fixinc/tests/base/math.h
index 292e567eeb1..dd29057fc54 100644
--- a/gcc/fixinc/tests/base/math.h
+++ b/gcc/fixinc/tests/base/math.h
@@ -7,12 +7,12 @@
This had to be done to correct non-standard usages in the
original, manufacturer supplied header file. */
-#ifndef FIXINC_SUNOS_MATHERR_DECL_CHECK
-#define FIXINC_SUNOS_MATHERR_DECL_CHECK 1
+#ifndef FIXINC_WRAP_MATH_H_SUNOS_MATHERR_DECL
+#define FIXINC_WRAP_MATH_H_SUNOS_MATHERR_DECL 1
struct exception;
-#ifndef FIXINC_MATH_EXCEPTION_CHECK
-#define FIXINC_MATH_EXCEPTION_CHECK 1
+#ifndef FIXINC_WRAP_MATH_H_MATH_EXCEPTION
+#define FIXINC_WRAP_MATH_H_MATH_EXCEPTION 1
#ifdef __cplusplus
#define exception __math_exception
@@ -122,6 +122,6 @@ extern double atof(const char *__nptr);
#undef exception
#endif
-#endif /* FIXINC_MATH_EXCEPTION_CHECK */
+#endif /* FIXINC_WRAP_MATH_H_MATH_EXCEPTION */
-#endif /* FIXINC_SUNOS_MATHERR_DECL_CHECK */
+#endif /* FIXINC_WRAP_MATH_H_SUNOS_MATHERR_DECL */
diff --git a/gcc/fixinc/tests/base/stdio.h b/gcc/fixinc/tests/base/stdio.h
index 00d3c836ff4..bfa929fb666 100644
--- a/gcc/fixinc/tests/base/stdio.h
+++ b/gcc/fixinc/tests/base/stdio.h
@@ -7,8 +7,8 @@
This had to be done to correct non-standard usages in the
original, manufacturer supplied header file. */
-#ifndef FIXINC_STDIO_STDARG_H_CHECK
-#define FIXINC_STDIO_STDARG_H_CHECK 1
+#ifndef FIXINC_WRAP_STDIO_H_STDIO_STDARG_H
+#define FIXINC_WRAP_STDIO_H_STDIO_STDARG_H 1
#define __need___va_list
#include <stdarg.h>
@@ -80,4 +80,4 @@ extern char *tempnam( const char *, const char *);
void f (char * __restrict__ x);
#endif /* UNICOSMK_RESTRICT_CHECK */
-#endif /* FIXINC_STDIO_STDARG_H_CHECK */
+#endif /* FIXINC_WRAP_STDIO_H_STDIO_STDARG_H */
diff --git a/gcc/fixinc/tests/base/strings.h b/gcc/fixinc/tests/base/strings.h
index 23f0d00e1ab..36ca0b4c0f1 100644
--- a/gcc/fixinc/tests/base/strings.h
+++ b/gcc/fixinc/tests/base/strings.h
@@ -7,8 +7,8 @@
This had to be done to correct non-standard usages in the
original, manufacturer supplied header file. */
-#ifndef FIXINC_ULTRIX_STRINGS_CHECK
-#define FIXINC_ULTRIX_STRINGS_CHECK 1
+#ifndef FIXINC_WRAP_STRINGS_H_ULTRIX_STRINGS
+#define FIXINC_WRAP_STRINGS_H_ULTRIX_STRINGS 1
@@ -22,4 +22,4 @@
#endif /* ULTRIX_STRINGS_CHECK */
-#endif /* FIXINC_ULTRIX_STRINGS_CHECK */
+#endif /* FIXINC_WRAP_STRINGS_H_ULTRIX_STRINGS */
diff --git a/gcc/fixinc/tests/base/sys/mman.h b/gcc/fixinc/tests/base/sys/mman.h
index 90b10f43b29..8fa2fb18c2a 100644
--- a/gcc/fixinc/tests/base/sys/mman.h
+++ b/gcc/fixinc/tests/base/sys/mman.h
@@ -7,8 +7,8 @@
This had to be done to correct non-standard usages in the
original, manufacturer supplied header file. */
-#ifndef FIXINC_CXX_UNREADY_CHECK
-#define FIXINC_CXX_UNREADY_CHECK 1
+#ifndef FIXINC_WRAP_SYS_MMAN_H_CXX_UNREADY
+#define FIXINC_WRAP_SYS_MMAN_H_CXX_UNREADY 1
#ifdef __cplusplus
extern "C" {
@@ -22,4 +22,4 @@ extern void* malloc( size_t );
}
#endif
-#endif /* FIXINC_CXX_UNREADY_CHECK */
+#endif /* FIXINC_WRAP_SYS_MMAN_H_CXX_UNREADY */