fixtests.c (is_cxx_header): New fn, split out of double_slash_test.

1999-12-17 13:21 -0800  Zack Weinberg  <zack@rabi.columbia.edu>

	* fixtests.c (is_cxx_header): New fn, split out of
	double_slash_test.
	(else_endif_label): Allow "#endif // comment" in C++ headers,
	as determined by is_cxx_header.
	* fixfixes.c (else_endif_label_fix): Update comment.
	* fixincl.c: Don't output VERB_PROGRESS lines if stdout is not
	a tty.
	* genfixes: Correct double thinko in commandline parsing.
	* hackshell.tpl: Generate correct sh syntax for bypass
	entries.

	* inclhack.def (all): Whenever an inserted preprocessor
	conditional is split over multiple lines, use double
	backslashes in this file so the fixed header will be readable.

	(AAB_fd_zero_glibc_1_0): Rename to AAB_fd_zero_asm_posix_types_h
	and add bypass entry for correct version of this header.
	(AAB_fd_zero_glibc_1_x): Rename to AAB_fd_zero_gnu_types_h.
	(AAB_fd_zero_glibc_2_0): Rename to AAB_fd_zero_selectbits_h.

	(hpux8_bogus_inlines): New fix, split from...
	(ultrix_atof_param) ... here.
	(math_expression): Add bypass entry keyed to glibc comment
	indicating the problem has been dealt with; disable
	unnecessary sed operations; update commentary.
	(math_gcc_ifndefs): Rename to math_huge_val_from_dbl_max,
	add select and bypass entries, simplify shell operation.
	(math_huge_val_ifndef): Split from math_gcc_ifndefs.

	(ip_missing_semi, rs6000_param, tinfo_cplusplus,
	 ultrix_atof_param): Add select entry.
	(stdio_va_list, sunos_mather_decl): Add bypass entry.
	(systypes_for_aix, sysv86_string, tinfo_cplusplus): Put the
	comments with the fixes they describe.

	* fixincl.x, fixincl.sh, inclhack.sh: Regen.

From-SVN: r30999
This commit is contained in:
Zack Weinberg 1999-12-17 21:49:30 +00:00 committed by Zack Weinberg
parent cdfff38e3d
commit d7eb5a45e2
10 changed files with 777 additions and 439 deletions

View file

@ -1,5 +1,40 @@
1999-12-17 13:21 -0800 Zack Weinberg <zack@rabi.columbia.edu>
* fixtests.c (is_cxx_header): New fn, split out of
double_slash_test.
(else_endif_label): Allow "#endif // comment" in C++ headers,
as determined by is_cxx_header.
* fixfixes.c (else_endif_label_fix): Update comment.
* fixincl.c: Don't output VERB_PROGRESS lines if stdout is not
a tty.
* genfixes: Correct double thinko in commandline parsing.
* hackshell.tpl: Generate correct sh syntax for bypass
entries.
* inclhack.def (all): Whenever an inserted preprocessor
conditional is split over multiple lines, use double
backslashes in this file so the fixed header will be readable.
(AAB_fd_zero_glibc_1_0): Rename to AAB_fd_zero_asm_posix_types_h
and add bypass entry for correct version of this header.
(AAB_fd_zero_glibc_1_x): Rename to AAB_fd_zero_gnu_types_h.
(AAB_fd_zero_glibc_2_0): Rename to AAB_fd_zero_selectbits_h.
(hpux8_bogus_inlines): New fix, split from...
(ultrix_atof_param) ... here.
(math_expression): Add bypass entry keyed to glibc comment
indicating the problem has been dealt with; disable
unnecessary sed operations; update commentary.
(math_gcc_ifndefs): Rename to math_huge_val_from_dbl_max,
add select and bypass entries, simplify shell operation.
(math_huge_val_ifndef): Split from math_gcc_ifndefs.
(ip_missing_semi, rs6000_param, tinfo_cplusplus,
ultrix_atof_param): Add select entry.
(stdio_va_list, sunos_mather_decl): Add bypass entry.
(systypes_for_aix, sysv86_string, tinfo_cplusplus): Put the
comments with the fixes they describe.
* c-parse.in (string action): Do not warn about ANSI string
concatenation in system headers. Affects C parser only.
* c-parse.y, c-parse.c, c-parse.h: Rebuild.

View file

@ -312,10 +312,6 @@ FIX_PROC_HEAD( else_endif_label_fix )
break;
}
/*
FIXME: if this is a C++ file, then a double slash comment
is allowed to follow the directive. */
/* FALLTHROUGH */
default:

View file

@ -114,6 +114,7 @@ typedef enum {
} te_verbose;
te_verbose verbose_level = VERB_PROGRESS;
int have_tty = 0;
#define VLEVEL(l) (verbose_level >= l)
#define NOT_SILENT VLEVEL(VERB_FIXES)
@ -192,6 +193,8 @@ main (argc, argv)
initialize ();
have_tty = isatty (fileno (stderr));
/* Before anything else, ensure we can allocate our file name buffer. */
file_name_buf = load_file_data (stdin);
@ -1336,7 +1339,7 @@ process ()
#ifdef DO_STATS
process_ct++;
#endif
if (VLEVEL( VERB_PROGRESS ))
if (VLEVEL( VERB_PROGRESS ) && have_tty)
fprintf (stderr, "%6d %-50s \r", data_map_size, pz_curr_file );
process_chain_head = NOPROCESS;

View file

@ -6,7 +6,7 @@
# files which are fixed to work correctly with ANSI C and placed in a
# directory that GNU C will search.
#
# This script contains 112 fixup scripts.
# This script contains 114 fixup scripts.
#
# See README-fixinc for more information.
#

File diff suppressed because it is too large Load diff

View file

@ -106,8 +106,10 @@ skip_quote( q, text )
return text;
}
TEST_FOR_FIX_PROC_HEAD( double_slash_test )
static apply_fix_p_t
is_cxx_header (fname, text)
const char *fname;
const char *text;
{
/* First, check to see if the file is in a C++ directory */
if (strstr( fname, "CC/" ) != NULL)
@ -116,9 +118,19 @@ TEST_FOR_FIX_PROC_HEAD( double_slash_test )
return SKIP_FIX;
if (strstr( fname, "++" ) != NULL)
return SKIP_FIX;
/* Or it might contain the phrase 'extern "C++"' */
if (strstr( text, "extern \"C++\"" ) != NULL)
return SKIP_FIX;
return APPLY_FIX;
}
TEST_FOR_FIX_PROC_HEAD( double_slash_test )
{
if (is_cxx_header (fname, text) == SKIP_FIX)
return SKIP_FIX;
/* Now look for the comment markers in the text */
for (;;)
{
@ -167,6 +179,7 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test )
char ch;
const char* pz_next = (char*)NULL;
regmatch_t match[2];
const char *all_text = text;
/*
This routine may be run many times within a single execution.
@ -266,10 +279,15 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test )
pz_next += 2;
break;
}
/*
FIXME: if this is a C++ file, then a double slash comment
is allowed to follow the directive. */
else if (*pz_next == '/'
&& is_cxx_header( fname, all_text ) == SKIP_FIX)
{
pz_next = strchr( pz_next+1, '\n' );
if (pz_next == (char*)NULL)
return SKIP_FIX;
pz_next++;
break;
}
/* FALLTHROUGH */

View file

@ -63,9 +63,9 @@ fi
set -e
case "$1" in
inclhack.def )
inclhack.sh )
echo AutoGen-ing inclhack.sh
$AG inclhack.sh
$AG inclhack.def
;;
fixincl.x )

View file

@ -59,8 +59,8 @@ _FOR fix "\n\n" =]
_IF bypass _exist =]
if ( test [=
_FOR bypass=] -a \
-z [=bypass _shrstr "#`egrep %s ${file}`"
_FOR bypass " -a \\\n "
=]-z [=bypass _shrstr "#`egrep %s ${file}`"
_printf _shstr =][=
/bypass=]
) > /dev/null 2>&1 ; then[=

View file

@ -155,12 +155,13 @@ typedef char * va_list;
/*
* This fixes __FD_ZERO bug for glibc-1.0.x
* This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
*/
fix = {
hackname = AAB_fd_zero_glibc_1_0;
hackname = AAB_fd_zero_asm_posix_types_h;
files = asm/posix_types.h;
mach = 'i[34567]86-*-linux-gnu*';
bypass = '} while';
/*
* Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
@ -170,20 +171,21 @@ fix = {
*/
replace =
'/* This file fixes __FD_ZERO bug for glibc-1.x. */
'/* This file fixes a bug in the __FD_ZERO macro
for older versions of the Linux kernel. */
\#ifndef _POSIX_TYPES_H_WRAPPER
\#include <features.h>
\#include_next <asm/posix_types.h>
\#if defined(__FD_ZERO) && !defined(__GLIBC__)
\#undef __FD_ZERO
\#define __FD_ZERO(fdsetp) \
do { \
int __d0, __d1; \
__asm__ __volatile__("cld ; rep ; stosl" \
: "=&c" (__d0), "=&D" (__d1) \
: "a" (0), "0" (__FDSET_LONGS), \
"1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
\#define __FD_ZERO(fdsetp) \\
do { \\
int __d0, __d1; \\
__asm__ __volatile__("cld ; rep ; stosl" \\
: "=&c" (__d0), "=&D" (__d1) \\
: "a" (0), "0" (__FDSET_LONGS), \\
"1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \\
} while (0)
\#endif
@ -197,7 +199,7 @@ fix = {
* This fixes __FD_ZERO bug for glibc-1.x
*/
fix = {
hackname = AAB_fd_zero_glibc_1_x;
hackname = AAB_fd_zero_gnu_types_h;
files = gnu/types.h;
mach = 'i[34567]86-*-linux-gnu*';
@ -209,20 +211,20 @@ fix = {
*/
replace =
'/* This file fixes __FD_ZERO bug for glibc-1.x. */
'/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
\#ifndef _TYPES_H_WRAPPER
\#include <features.h>
\#include_next <gnu/types.h>
\#if defined(__FD_ZERO) && !defined(__GLIBC__)
\#undef __FD_ZERO
\# define __FD_ZERO(fdsetp) \
do { \
int __d0, __d1; \
__asm__ __volatile__("cld ; rep ; stosl" \
: "=&c" (__d0), "=&D" (__d1) \
: "a" (0), "0" (__FDSET_LONGS), \
"1" ((__fd_set *) (fdsetp)) :"memory"); \
\# define __FD_ZERO(fdsetp) \\
do { \\
int __d0, __d1; \\
__asm__ __volatile__("cld ; rep ; stosl" \\
: "=&c" (__d0), "=&D" (__d1) \\
: "a" (0), "0" (__FDSET_LONGS), \\
"1" ((__fd_set *) (fdsetp)) :"memory"); \\
} while (0)
\#endif
@ -236,7 +238,7 @@ fix = {
* This fixes __FD_ZERO bug for glibc-2.0.x
*/
fix = {
hackname = AAB_fd_zero_glibc_2_0;
hackname = AAB_fd_zero_selectbits_h;
files = selectbits.h;
mach = 'i[34567]86-*-linux-gnu*';
@ -248,24 +250,24 @@ fix = {
*/
replace =
'/* This file fixes __FD_ZERO bug for glibc-2.0.x. */
'/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
\#ifndef _SELECTBITS_H_WRAPPER
\#include <features.h>
\#include_next <selectbits.h>
\#if defined(__FD_ZERO) && defined(__GLIBC__) \
&& defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \
\#if defined(__FD_ZERO) && defined(__GLIBC__) \\
&& defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
&& __GLIBC_MINOR__ == 0
\#undef __FD_ZERO
\#define __FD_ZERO(fdsetp) \
do { \
int __d0, __d1; \
__asm__ __volatile__ ("cld; rep; stosl" \
: "=&c" (__d0), "=&D" (__d1) \
: "a" (0), "0" (sizeof (__fd_set) \
/ sizeof (__fd_mask)), \
"1" ((__fd_mask *) (fdsetp)) \
: "memory"); \
\#define __FD_ZERO(fdsetp) \\
do { \\
int __d0, __d1; \\
__asm__ __volatile__ ("cld; rep; stosl" \\
: "=&c" (__d0), "=&D" (__d1) \\
: "a" (0), "0" (sizeof (__fd_set) \\
/ sizeof (__fd_mask)), \\
"1" ((__fd_mask *) (fdsetp)) \\
: "memory"); \\
} while (0)
\#endif
@ -357,8 +359,8 @@ htons (unsigned int __arg)
return __result;
}
\#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
|| defined (__ns32k__) || defined (__vax__) \
\#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \\
|| defined (__ns32k__) || defined (__vax__) \\
|| defined (__spur__) || defined (__arm__))
\#ifndef __BYTE_ORDER__
@ -853,6 +855,20 @@ fix = {
sed = "s/^extern struct sigevent;/struct sigevent;/";
};
/*
* get rid of bogus inline definitions in HP-UX 8.0
*/
fix = {
hackname = hpux8_bogus_inlines;
files = math.h;
select = inline;
sed = "s@inline int abs(int [a-z][a-z]*) {.*}@extern \"C\" int abs(int);@";
sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
};
/*
* In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
* of UINT32_C has undefined behavior according to ISO/ANSI:
@ -980,6 +996,7 @@ fix = {
fix = {
hackname = ip_missing_semi;
files = netinet/ip.h;
select = "}$";
sed = "/^struct/,/^};/s/}$/};/";
};
@ -1326,6 +1343,7 @@ fix = {
hackname = math_exception;
files = math.h;
select = "struct exception";
bypass = "We have a problem when using C++";
sed = "/struct exception/i\\\n"
"#ifdef __cplusplus\\\n"
"#define exception __math_exception\\\n"
@ -1335,6 +1353,7 @@ fix = {
"#undef exception\\\n"
"#endif\n";
#ifdef MATH_EXCEPTION_FIXED
sed = "/matherr/i\\\n"
"#ifdef __cplusplus\\\n"
"#define exception __math_exception\\\n"
@ -1345,14 +1364,21 @@ fix = {
"#undef exception\\\n"
"#endif\n";
#ifdef MATH_EXCEPTION_FIXED
I think this patch needs some more thinking.
This is from SVR4.2 (With '#' replaced with '@').
Perhaps we could do without the "/matherr/a" entries?
Can we bypass the entire fix if someone was astute
enough to have '#ifdef __cplusplus' anywhere in the file?
We can definitely do without the "/matherr/a" entries. They are
there to cover the case where matherr is declared with no prototype
-- extern int matherr(); -- but we don't need a fix then since there
is no reference to struct exception.
Bypassing on "#ifdef __cplusplus" is too optimistic, but I've stuck
in a bypass for the comment in the glibc 2.1 header that indicates
awareness of the problem. Hmm. Could we use a shell test that did
cpp -D__cplusplus | grep "struct exception" ?
*** /usr/include/math.h Fri Apr 3 18:54:59 1998
--- math.h Sun May 9 07:28:58 1999
@ -1396,46 +1422,43 @@ enough to have '#ifdef __cplusplus' anywhere in the file?
#endif
};
/*
* In math.h, put #ifndefs around things that might be defined
* in a gcc specific math-*.h file.
*/
fix = {
hackname = math_gcc_ifndefs;
hackname = math_huge_val_from_dbl_max;
files = math.h;
/*
* IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
* in math.h, this fix applies.
*/
select = "define[ \t]*HUGE_VAL[ \t]*DBL_MAX";
bypass = "define[ \t]*DBL_MAX";
shell =
/*
* First see if we have a definition for DBL_MAX in float.h
* See if we have a definition for DBL_MAX in float.h.
* If we do, we will replace the one in math.h with that one.
*/
/*
* IF we have such a define *and* HUGE_VAL is defined to be DBL_MAX
* *and* DBL_MAX is _not_ defined in the current file (math.h),
* THEN replace the defined value of HUGE_VAL
* ELSE just copy stdin to stdout so the main filter can process it
*/
/*
* Put conditional guards around the HUGE_VAL definition.
*/
"\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
"2>/dev/null`\n\n"
"\tif ( test -n \"${dbl_max_def}\" \\\n"
"\t\t-a -n \"`egrep '#define[ \t]*HUGE_VAL[ \t]+DBL_MAX' $file`\" \\\n"
"\t\t-a -z \"`egrep '#define[ \t]+DBL_MAX[ \t]+' $file`\"\n"
"\t ) > /dev/null 2>&1\n"
"\tthen sed -e '/define[ \t]HUGE_VAL[ \t]DBL_MAX/s/DBL_MAX/$dbl_max_def/'"
"\n\telse cat ; fi |\n"
"\tsed -e '/define[ \t]HUGE_VAL[ \t]/i\\\n#ifndef HUGE_VAL\n' "
"-e '/define[ \t]HUGE_VAL[ \t]/a\\\n#endif\n'";
"\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
"\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
"s/DBL_MAX/'\"$dbl_max_def/\"\n"
"\telse cat\n"
"\tfi";
};
/*
* In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h.
*/
fix = {
hackname = math_huge_val_ifndef;
files = math/math.h;
select = "define[ \t]*HUGE_VAL";
sed = "/define[ \t]HUGE_VAL[ \t]/i\\\n#ifndef HUGE_VAL\n";
sed = "/define[ \t]HUGE_VAL[ \t]/a\\\n#endif\n";
};
/*
* nested comment
@ -1626,6 +1649,7 @@ fix = {
hackname = rs6000_param;
files = "stdio.h";
files = "unistd.h";
select = 'const char new';
sed = 's@rename(const char \*old, const char \*new)@'
'rename(const char *_old, const char *_new)@';
@ -1708,6 +1732,7 @@ fix = {
fix = {
hackname = stdio_va_list;
files = stdio.h;
bypass = "__gnuc_va_list";
/*
* Use __gnuc_va_list in arg types in place of va_list.
@ -1907,6 +1932,8 @@ fix = {
fix = {
hackname = sunos_matherr_decl;
files = math.h;
/* If matherr has a prototype already, the header needs no fix. */
bypass = 'matherr.*struct exception';
/*
* Once a declaration for 'struct exception' is found,
* stop trying to insert a forward reference for it.
@ -1922,6 +1949,7 @@ fix = {
fix = {
hackname = sunos_strlen;
files = strings.h;
select = "int[ \t]*strlen";
sed = "s/int[ \t]*strlen();/__SIZE_TYPE__ strlen();/";
};
@ -2314,9 +2342,9 @@ fix = {
/*
* Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
* Also wrap protection around size_t for m88k-sysv3 systems.
* We use a funny name to ensure it follows 'systypes' fix.
* Fix this file to avoid interfering with stddef.h,
* but don't mistakenly match ssize_t present in AIX for the ps/2,
* or typedefs which use (but do not set) size_t.
*/
fix = {
hackname = systypes_for_aix;
@ -2334,8 +2362,9 @@ fix = {
/*
* if the #if says _cplusplus, not the double underscore __cplusplus
* that it should be
* Fix return type of exit and abort in <stdlib.h> on SunOS 4.1.
* Also wrap protection around size_t for m88k-sysv3 systems.
* We use a funny name to ensure it follows 'systypes' fix.
*/
fix = {
hackname = sysv68_string;
@ -2410,13 +2439,13 @@ fix = {
/*
* Fix this file to avoid interfering with stddef.h,
* but don't mistakenly match ssize_t present in AIX for the ps/2,
* or typedefs which use (but do not set) size_t.
* if the #if says _cplusplus, not the double underscore __cplusplus
* that it should be
*/
fix = {
hackname = tinfo_cplusplus;
files = tinfo.h;
select = "[ \t]_cplusplus";
sed = "s/[ \t]_cplusplus/ __cplusplus/";
};
@ -2448,17 +2477,13 @@ fix = {
/*
* parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R.
* also get rid of bogus inline definitions in HP-UX 8.0
*/
fix = {
hackname = ultrix_atof_param;
files = math.h;
select = "atof\\([ \t]*char";
sed = "s@atof(\\([ \t]*char[ \t]*\\*[^)]*\\))@atof(const \\1)@";
sed = "s@inline int abs(int [a-z][a-z]*) {.*}@extern \"C\" int abs(int);@";
sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
};

File diff suppressed because it is too large Load diff