]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
wrapper guard must be a function of *both* the file name and the fix name
authorBruce Korb <bkorb@gnu.org>
Sat, 25 Jan 2003 17:10:48 +0000 (17:10 +0000)
committerBruce Korb <korbb@gcc.gnu.org>
Sat, 25 Jan 2003 17:10:48 +0000 (17:10 +0000)
From-SVN: r61780

gcc/ChangeLog
gcc/fixinc/fixfixes.c

index 74f127d6468565bb14e2269dc52b83575ce47622..45d82e68205577c089441d2daf3f89e6db42948c 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-25  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.
+
 2003-01-25  Eric Botcazou  <ebotcazou@libertysurf.fr>
             Christian Ehrhardt  <ehrhardt@mathematik.uni-ulm.de>
 
index ad54960d13bd8991175f12b27d0579f54737fac4..8297eb0e40cc2ff9929f2d83a0fca0498406ffff 100644 (file)
@@ -3,7 +3,7 @@
 
    Test to see if a particular fix should be applied to a header file.
 
-   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
 
 = = = = = = = = = = = = = = = = = = = = = = = = =
 
@@ -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 );
+  }
 }