From: Bruce Korb Date: Sat, 25 Jan 2003 17:10:48 +0000 (+0000) Subject: wrapper guard must be a function of *both* the file name and the fix name X-Git-Tag: releases/gcc-3.2.2~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39e9c6e9feff24c8649cd3ad54229114308ebd80;p=thirdparty%2Fgcc.git wrapper guard must be a function of *both* the file name and the fix name From-SVN: r61780 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 74f127d64685..45d82e682055 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-01-25 Bruce Korb + + * 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 Christian Ehrhardt diff --git a/gcc/fixinc/fixfixes.c b/gcc/fixinc/fixfixes.c index ad54960d13bd..8297eb0e40cc 100644 --- a/gcc/fixinc/fixfixes.c +++ b/gcc/fixinc/fixfixes.c @@ -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 ); + } }