mirror of git://gcc.gnu.org/git/gcc.git
Use fnmatch for name matching.
Co-Authored-By: Daniel Franke <franke.daniel@gmail.com> From-SVN: r120528
This commit is contained in:
parent
2dee695bfc
commit
401be4b658
|
|
@ -1,3 +1,15 @@
|
||||||
|
2007-01-05 Bruce Korb <bkorb@gnu.org>,
|
||||||
|
Daniel Franke <franke.daniel@gmail.com>
|
||||||
|
|
||||||
|
PR target/30008
|
||||||
|
* fixincl.tpl (List): separate file name patterns with a NUL byte instead
|
||||||
|
of a vertical bar ("|").
|
||||||
|
* fixincl.c (fix_applies, machine_matches): Use fnmatch for name matching.
|
||||||
|
* fixincl.x: Regenerate.
|
||||||
|
* inclhack.def (glibc_c99_inline_[1234], broken_cabs, broken_nan,
|
||||||
|
kandr_concat, sco_math): Replace lists of specfic file names by search
|
||||||
|
patterns.
|
||||||
|
|
||||||
2006-12-12 Olivier Hainque <hainque@adacore.com>
|
2006-12-12 Olivier Hainque <hainque@adacore.com>
|
||||||
|
|
||||||
* fixincludes/mkfixinc.sh: Add "*-*-vxworks*" to the list of
|
* fixincludes/mkfixinc.sh: Add "*-*-vxworks*" to the list of
|
||||||
|
|
|
||||||
|
|
@ -69,14 +69,17 @@ MAKING CHANGES TO INCLHACK.DEF
|
||||||
for variable names and is unique without regard to alphabetic case.
|
for variable names and is unique without regard to alphabetic case.
|
||||||
Please keep them alphabetical by this name. :-)
|
Please keep them alphabetical by this name. :-)
|
||||||
|
|
||||||
2. If the problem is known to exist only in certain files,
|
2. If the problem is known to exist only in certain files, then
|
||||||
then name each such file with a "files = " entry.
|
identify the files with "files = " entries. If you use fnmatch(3C)
|
||||||
|
wild card characters in a "files" entry, be certain that the first
|
||||||
|
"files" entry has no such character. Otherwise, the "make check"
|
||||||
|
machinery will attempt to create files with those characters in the
|
||||||
|
name. That is inconvenient.
|
||||||
|
|
||||||
3. It is relatively expensive to fire off a process to fix a source
|
3. It is relatively expensive to fire off a process to fix a source
|
||||||
file, therefore write apply tests to avoid unnecessary fix
|
file, therefore write apply tests to avoid unnecessary fix
|
||||||
processes. The preferred apply tests are "select", "bypass" and
|
processes. The preferred apply tests are "select", "bypass", "mach"
|
||||||
"c_test" because they are performed internally. The available
|
and "c-test" because they are performed internally:
|
||||||
tests are:
|
|
||||||
|
|
||||||
* select - Run a regex on the contents of the file being considered.
|
* select - Run a regex on the contents of the file being considered.
|
||||||
All such regex-es must match.
|
All such regex-es must match.
|
||||||
|
|
@ -84,17 +87,16 @@ MAKING CHANGES TO INCLHACK.DEF
|
||||||
* bypass - Run a regex on the contents of the file being considered.
|
* bypass - Run a regex on the contents of the file being considered.
|
||||||
No such regex may match.
|
No such regex may match.
|
||||||
|
|
||||||
* c_test - call a function in fixtests.c. See that file.
|
* c-test - call a function in fixtests.c. See that file.
|
||||||
|
|
||||||
The next two tests are relatively slow because they must be handled
|
* mach - Match the output of config.conf against a series of fnmatch
|
||||||
in a separate shell process. Some platforms do not support server
|
|
||||||
shells, so the whole process is even slower and more cumbersome there.
|
|
||||||
|
|
||||||
* mach - Match the output of config.conf against a series of globbing
|
|
||||||
patterns. It must match at least one of the patterns, unless
|
patterns. It must match at least one of the patterns, unless
|
||||||
"not-machine" has also been specified. If that has been
|
"not-machine" has also been specified. In that case, the
|
||||||
specified, then the config.conf output may not match any of
|
config.conf output must not match any of the patterns.
|
||||||
the patterns.
|
|
||||||
|
The next test is relatively slow because it must be handled in a
|
||||||
|
separate shell process. Some platforms do not support server shells,
|
||||||
|
so the whole process is even slower and more cumbersome there.
|
||||||
|
|
||||||
* test - These should be arguments to the program, "/bin/test".
|
* test - These should be arguments to the program, "/bin/test".
|
||||||
You may perform multiple commands, if you enclose them
|
You may perform multiple commands, if you enclose them
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
#include "fixlib.h"
|
#include "fixlib.h"
|
||||||
|
|
||||||
|
#include <fnmatch.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifndef SEPARATE_FIX_PROC
|
#ifndef SEPARATE_FIX_PROC
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
@ -360,94 +361,29 @@ load_file ( const char* fname )
|
||||||
static int
|
static int
|
||||||
machine_matches( tFixDesc* p_fixd )
|
machine_matches( tFixDesc* p_fixd )
|
||||||
{
|
{
|
||||||
# ifndef SEPARATE_FIX_PROC
|
char const ** papz_machs = p_fixd->papz_machs;
|
||||||
tSCC case_fmt[] = "case %s in\n"; /* 9 bytes, plus string */
|
int have_match = BOOL_FALSE;
|
||||||
tSCC esac_fmt[] =
|
|
||||||
" )\n echo %s ;;\n* ) echo %s ;;\nesac";/* 4 bytes */
|
|
||||||
tSCC skip[] = "skip"; /* 4 bytes */
|
|
||||||
tSCC run[] = "run"; /* 3 bytes */
|
|
||||||
/* total bytes to add to machine sum: 49 - see fixincl.tpl */
|
|
||||||
|
|
||||||
const char **papz_machs = p_fixd->papz_machs;
|
for (;;)
|
||||||
char *pz;
|
{
|
||||||
const char *pz_sep = "";
|
char const * pz_mpat = *(papz_machs++);
|
||||||
tCC *pz_if_true;
|
if (pz_mpat == NULL)
|
||||||
tCC *pz_if_false;
|
break;
|
||||||
char cmd_buf[ MACH_LIST_SIZE_LIMIT ]; /* size lim from fixincl.tpl */
|
if (fnmatch(pz_mpat, pz_machine, 0) == 0)
|
||||||
|
{
|
||||||
/* Start the case statement */
|
have_match = BOOL_TRUE;
|
||||||
|
break;
|
||||||
sprintf (cmd_buf, case_fmt, pz_machine);
|
}
|
||||||
pz = cmd_buf + strlen (cmd_buf);
|
}
|
||||||
|
|
||||||
/* Determine if a match means to apply the fix or not apply it */
|
|
||||||
|
|
||||||
if (p_fixd->fd_flags & FD_MACH_IFNOT)
|
if (p_fixd->fd_flags & FD_MACH_IFNOT)
|
||||||
{
|
return ! have_match;
|
||||||
pz_if_true = skip;
|
return have_match;
|
||||||
pz_if_false = run;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pz_if_true = run;
|
|
||||||
pz_if_false = skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Emit all the machine names. If there are more than one,
|
|
||||||
then we will insert " | \\\n" between the names */
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
const char* pz_mach = *(papz_machs++);
|
|
||||||
|
|
||||||
if (pz_mach == (const char*) NULL)
|
|
||||||
break;
|
|
||||||
sprintf (pz, "%s%s", pz_sep, pz_mach);
|
|
||||||
pz += strlen (pz);
|
|
||||||
pz_sep = " | \\\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now emit the match and not-match actions and the esac */
|
|
||||||
|
|
||||||
sprintf (pz, esac_fmt, pz_if_true, pz_if_false);
|
|
||||||
|
|
||||||
/* Run the script.
|
|
||||||
The result will start either with 's' or 'r'. */
|
|
||||||
|
|
||||||
{
|
|
||||||
int skip;
|
|
||||||
pz = run_shell (cmd_buf);
|
|
||||||
skip = (*pz == 's');
|
|
||||||
free ( (void*)pz );
|
|
||||||
if (skip)
|
|
||||||
{
|
|
||||||
p_fixd->fd_flags |= FD_SKIP_TEST;
|
|
||||||
return BOOL_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return BOOL_TRUE;
|
|
||||||
# else /* is SEPARATE_FIX_PROC */
|
|
||||||
const char **papz_machs = p_fixd->papz_machs;
|
|
||||||
int invert = (p_fixd->fd_flags & FD_MACH_IFNOT) != 0;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
const char* pz_mach = *(papz_machs++);
|
|
||||||
|
|
||||||
if (pz_mach == (const char*) NULL)
|
|
||||||
break;
|
|
||||||
if (strstr (pz_mach, "dos") != NULL && !invert)
|
|
||||||
return BOOL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
p_fixd->fd_flags |= FD_SKIP_TEST;
|
|
||||||
return BOOL_FALSE;
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* * * * * * * * * * * * *
|
/* * * * * * * * * * * * *
|
||||||
|
*
|
||||||
run_compiles run all the regexp compiles for all the fixes once.
|
* run_compiles run all the regexp compiles for all the fixes once.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
run_compiles (void)
|
run_compiles (void)
|
||||||
|
|
@ -1074,11 +1010,11 @@ start_fixer (int read_fd, tFixDesc* p_fixd, char* pz_fix_file)
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * *
|
/* * * * * * * * * * * * *
|
||||||
|
*
|
||||||
Process the potential fixes for a particular include file.
|
* Process the potential fixes for a particular include file.
|
||||||
Input: the original text of the file and the file's name
|
* Input: the original text of the file and the file's name
|
||||||
Result: none. A new file may or may not be created. */
|
* Result: none. A new file may or may not be created.
|
||||||
|
*/
|
||||||
static t_bool
|
static t_bool
|
||||||
fix_applies (tFixDesc* p_fixd)
|
fix_applies (tFixDesc* p_fixd)
|
||||||
{
|
{
|
||||||
|
|
@ -1113,17 +1049,11 @@ fix_applies (tFixDesc* p_fixd)
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
pz_scan = strstr (pz_scan + 1, pz_fname);
|
if (fnmatch (pz_scan, pz_fname, 0) == 0)
|
||||||
/* IF we can't match the string at all,
|
|
||||||
THEN bail */
|
|
||||||
if (pz_scan == (char *) NULL)
|
|
||||||
return BOOL_FALSE;
|
|
||||||
|
|
||||||
/* IF the match is surrounded by the '|' markers,
|
|
||||||
THEN we found a full match -- time to run the tests */
|
|
||||||
|
|
||||||
if ((pz_scan[-1] == '|') && (pz_scan[name_len] == '|'))
|
|
||||||
break;
|
break;
|
||||||
|
pz_scan += strlen (pz_scan) + 1;
|
||||||
|
if (*pz_scan == NUL)
|
||||||
|
return BOOL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
x=fixincl.x =]
|
x=fixincl.x =]
|
||||||
[= (dne " * " "/* ")=]
|
[= (dne " * " "/* ")=]
|
||||||
*/
|
*/
|
||||||
/* DO NOT CVS-MERGE THIS FILE, EITHER [=`date`=]
|
/* DO NOT SVN-MERGE THIS FILE, EITHER [=`date`=]
|
||||||
*
|
*
|
||||||
* You must regenerate it. Use the ./genfixes script.
|
* You must regenerate it. Use the ./genfixes script.
|
||||||
*
|
*
|
||||||
|
|
@ -48,7 +48,7 @@ tSCC z[=(. Hack)=]Name[] =
|
||||||
|
|
||||||
IF (exist? "files")=]
|
IF (exist? "files")=]
|
||||||
tSCC z[=(. Hack)=]List[] =
|
tSCC z[=(. Hack)=]List[] =
|
||||||
"[=FOR files =]|[=files=][=ENDFOR=]|";[=
|
"[= (join "\\0" (stack "files")) =]\0";[=
|
||||||
|
|
||||||
ELSE =]
|
ELSE =]
|
||||||
#define z[=(. Hack)=]List (char*)NULL[=
|
#define z[=(. Hack)=]List (char*)NULL[=
|
||||||
|
|
@ -73,7 +73,7 @@ tSCC* apz[=(. Hack)=]Machs[] = {[=
|
||||||
|
|
||||||
ELSE =]
|
ELSE =]
|
||||||
#define apz[=(. Hack)=]Machs (const char**)NULL[=
|
#define apz[=(. Hack)=]Machs (const char**)NULL[=
|
||||||
ENDIF (exist? "files") =][=
|
ENDIF (exist? "mach") =][=
|
||||||
|
|
||||||
IF (exist? "select")=]
|
IF (exist? "select")=]
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1028,9 +1028,7 @@ fix = {
|
||||||
*/
|
*/
|
||||||
fix = {
|
fix = {
|
||||||
hackname = broken_cabs;
|
hackname = broken_cabs;
|
||||||
files = "math.h";
|
files = math.h, "architecture/*/math.h";
|
||||||
files = "architecture/ppc/math.h";
|
|
||||||
files = "architecture/i386/math.h";
|
|
||||||
select = "^extern[ \t]+double[ \t]+cabs";
|
select = "^extern[ \t]+double[ \t]+cabs";
|
||||||
|
|
||||||
c_fix = format;
|
c_fix = format;
|
||||||
|
|
@ -1054,8 +1052,14 @@ fix = {
|
||||||
|
|
||||||
fix = {
|
fix = {
|
||||||
hackname = broken_nan;
|
hackname = broken_nan;
|
||||||
|
/*
|
||||||
|
* It is tempting to omit the first "files" entry. Do not.
|
||||||
|
* The testing machinery will take the first "files" entry as the name
|
||||||
|
* of a test file to play with. It would be a nuisance to have a directory
|
||||||
|
* with the name "*".
|
||||||
|
*/
|
||||||
files = "architecture/ppc/math.h";
|
files = "architecture/ppc/math.h";
|
||||||
files = "architecture/i386/math.h";
|
files = "architecture/*/math.h";
|
||||||
select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
|
select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
|
||||||
bypass = "powl";
|
bypass = "powl";
|
||||||
c_fix = format;
|
c_fix = format;
|
||||||
|
|
@ -1294,7 +1298,7 @@ fix = {
|
||||||
*/
|
*/
|
||||||
fix = {
|
fix = {
|
||||||
hackname = glibc_c99_inline_1;
|
hackname = glibc_c99_inline_1;
|
||||||
files = features.h;
|
files = features.h, '*/features.h';
|
||||||
select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
|
select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
|
||||||
c_fix = format;
|
c_fix = format;
|
||||||
c_fix_arg = "%0 && __STDC_VERSION__ < 199901L";
|
c_fix_arg = "%0 && __STDC_VERSION__ < 199901L";
|
||||||
|
|
@ -1314,7 +1318,7 @@ EOT;
|
||||||
*/
|
*/
|
||||||
fix = {
|
fix = {
|
||||||
hackname = glibc_c99_inline_2;
|
hackname = glibc_c99_inline_2;
|
||||||
files = sys/stat.h;
|
files = sys/stat.h, '*/sys/stat.h';
|
||||||
select = "extern __inline__ int";
|
select = "extern __inline__ int";
|
||||||
sed = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
|
sed = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
|
||||||
"#if __STDC_VERSION__ < 199901L\\\nextern\\\n#endif\\\n"
|
"#if __STDC_VERSION__ < 199901L\\\nextern\\\n#endif\\\n"
|
||||||
|
|
@ -1336,7 +1340,7 @@ EOT;
|
||||||
|
|
||||||
fix = {
|
fix = {
|
||||||
hackname = glibc_c99_inline_3;
|
hackname = glibc_c99_inline_3;
|
||||||
files = bits/string2.h;
|
files = bits/string2.h, '*/bits/string2.h';
|
||||||
bypass = "__STDC_VERSION__";
|
bypass = "__STDC_VERSION__";
|
||||||
c_fix = format;
|
c_fix = format;
|
||||||
c_fix_arg = "# if defined(__cplusplus) || __STDC_VERSION__ >= 19901L";
|
c_fix_arg = "# if defined(__cplusplus) || __STDC_VERSION__ >= 19901L";
|
||||||
|
|
@ -1353,7 +1357,7 @@ EOT;
|
||||||
|
|
||||||
fix = {
|
fix = {
|
||||||
hackname = glibc_c99_inline_4;
|
hackname = glibc_c99_inline_4;
|
||||||
files = sys/sysmacros.h;
|
files = sys/sysmacros.h, '*/sys/sysmacros.h';
|
||||||
bypass = "__STDC_VERSION__";
|
bypass = "__STDC_VERSION__";
|
||||||
c_fix = format;
|
c_fix = format;
|
||||||
c_fix_arg = "\n#if __STDC_VERSION__ < 19901L\nextern\n#endif\n";
|
c_fix_arg = "\n#if __STDC_VERSION__ < 19901L\nextern\n#endif\n";
|
||||||
|
|
@ -2250,13 +2254,7 @@ fix = {
|
||||||
fix = {
|
fix = {
|
||||||
hackname = kandr_concat;
|
hackname = kandr_concat;
|
||||||
files = "sparc/asm_linkage.h";
|
files = "sparc/asm_linkage.h";
|
||||||
files = "sun3/asm_linkage.h";
|
files = "sun*/asm_linkage.h";
|
||||||
files = "sun3x/asm_linkage.h";
|
|
||||||
files = "sun4/asm_linkage.h";
|
|
||||||
files = "sun4c/asm_linkage.h";
|
|
||||||
files = "sun4m/asm_linkage.h";
|
|
||||||
files = "sun4c/debug/asm_linkage.h";
|
|
||||||
files = "sun4m/debug/asm_linkage.h";
|
|
||||||
files = "arm/as_support.h";
|
files = "arm/as_support.h";
|
||||||
files = "arm/mc_type.h";
|
files = "arm/mc_type.h";
|
||||||
files = "arm/xcb.h";
|
files = "arm/xcb.h";
|
||||||
|
|
@ -2851,14 +2849,7 @@ fix = {
|
||||||
*/
|
*/
|
||||||
fix = {
|
fix = {
|
||||||
hackname = sco_math;
|
hackname = sco_math;
|
||||||
files = math.h;
|
files = math.h, '*/math.h';
|
||||||
files = ansi/math.h;
|
|
||||||
files = posix/math.h;
|
|
||||||
files = xpg4/math.h;
|
|
||||||
files = xpg4v2/math.h;
|
|
||||||
files = xpg4plus/math.h;
|
|
||||||
files = ods_30_compat/math.h;
|
|
||||||
files = oldstyle/math.h;
|
|
||||||
select = "inline double abs";
|
select = "inline double abs";
|
||||||
bypass = "__GNUG__";
|
bypass = "__GNUG__";
|
||||||
sed = "/#define.*__fp_class(a) \\\\/i\\\n"
|
sed = "/#define.*__fp_class(a) \\\\/i\\\n"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue