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>
|
||||
|
||||
* 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.
|
||||
Please keep them alphabetical by this name. :-)
|
||||
|
||||
2. If the problem is known to exist only in certain files,
|
||||
then name each such file with a "files = " entry.
|
||||
2. If the problem is known to exist only in certain files, then
|
||||
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
|
||||
file, therefore write apply tests to avoid unnecessary fix
|
||||
processes. The preferred apply tests are "select", "bypass" and
|
||||
"c_test" because they are performed internally. The available
|
||||
tests are:
|
||||
processes. The preferred apply tests are "select", "bypass", "mach"
|
||||
and "c-test" because they are performed internally:
|
||||
|
||||
* select - Run a regex on the contents of the file being considered.
|
||||
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.
|
||||
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
|
||||
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
|
||||
* mach - Match the output of config.conf against a series of fnmatch
|
||||
patterns. It must match at least one of the patterns, unless
|
||||
"not-machine" has also been specified. If that has been
|
||||
specified, then the config.conf output may not match any of
|
||||
the patterns.
|
||||
"not-machine" has also been specified. In that case, the
|
||||
config.conf output must not match any of 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".
|
||||
You may perform multiple commands, if you enclose them
|
||||
|
@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include "fixlib.h"
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef SEPARATE_FIX_PROC
|
||||
#include <sys/wait.h>
|
||||
@ -359,96 +360,31 @@ load_file ( const char* fname )
|
||||
|
||||
static int
|
||||
machine_matches( tFixDesc* p_fixd )
|
||||
{
|
||||
# ifndef SEPARATE_FIX_PROC
|
||||
tSCC case_fmt[] = "case %s in\n"; /* 9 bytes, plus string */
|
||||
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 */
|
||||
{
|
||||
char const ** papz_machs = p_fixd->papz_machs;
|
||||
int have_match = BOOL_FALSE;
|
||||
|
||||
const char **papz_machs = p_fixd->papz_machs;
|
||||
char *pz;
|
||||
const char *pz_sep = "";
|
||||
tCC *pz_if_true;
|
||||
tCC *pz_if_false;
|
||||
char cmd_buf[ MACH_LIST_SIZE_LIMIT ]; /* size lim from fixincl.tpl */
|
||||
|
||||
/* Start the case statement */
|
||||
|
||||
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)
|
||||
{
|
||||
pz_if_true = skip;
|
||||
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)
|
||||
char const * pz_mpat = *(papz_machs++);
|
||||
if (pz_mpat == NULL)
|
||||
break;
|
||||
if (strstr (pz_mach, "dos") != NULL && !invert)
|
||||
return BOOL_TRUE;
|
||||
if (fnmatch(pz_mpat, pz_machine, 0) == 0)
|
||||
{
|
||||
have_match = BOOL_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
p_fixd->fd_flags |= FD_SKIP_TEST;
|
||||
return BOOL_FALSE;
|
||||
# endif
|
||||
if (p_fixd->fd_flags & FD_MACH_IFNOT)
|
||||
return ! have_match;
|
||||
return have_match;
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * *
|
||||
|
||||
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
|
||||
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.
|
||||
Input: the original text of the file and the file's name
|
||||
Result: none. A new file may or may not be created. */
|
||||
|
||||
*
|
||||
* Process the potential fixes for a particular include file.
|
||||
* Input: the original text of the file and the file's name
|
||||
* Result: none. A new file may or may not be created.
|
||||
*/
|
||||
static t_bool
|
||||
fix_applies (tFixDesc* p_fixd)
|
||||
{
|
||||
@ -1087,7 +1023,7 @@ fix_applies (tFixDesc* p_fixd)
|
||||
int test_ct;
|
||||
tTestDesc *p_test;
|
||||
|
||||
# ifdef SEPARATE_FIX_PROC
|
||||
#ifdef SEPARATE_FIX_PROC
|
||||
/*
|
||||
* There is only one fix that uses a shell script as of this writing.
|
||||
* I hope to nuke it anyway, it does not apply to DOS and it would
|
||||
@ -1095,10 +1031,10 @@ fix_applies (tFixDesc* p_fixd)
|
||||
*/
|
||||
if (p_fixd->fd_flags & (FD_SHELL_SCRIPT | FD_SKIP_TEST))
|
||||
return BOOL_FALSE;
|
||||
# else
|
||||
#else
|
||||
if (p_fixd->fd_flags & FD_SKIP_TEST)
|
||||
return BOOL_FALSE;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* IF there is a file name restriction,
|
||||
THEN ensure the current file name matches one in the pattern */
|
||||
@ -1113,17 +1049,11 @@ fix_applies (tFixDesc* p_fixd)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
pz_scan = strstr (pz_scan + 1, pz_fname);
|
||||
/* 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] == '|'))
|
||||
if (fnmatch (pz_scan, pz_fname, 0) == 0)
|
||||
break;
|
||||
pz_scan += strlen (pz_scan) + 1;
|
||||
if (*pz_scan == NUL)
|
||||
return BOOL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
x=fixincl.x =]
|
||||
[= (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.
|
||||
*
|
||||
@ -48,7 +48,7 @@ tSCC z[=(. Hack)=]Name[] =
|
||||
|
||||
IF (exist? "files")=]
|
||||
tSCC z[=(. Hack)=]List[] =
|
||||
"[=FOR files =]|[=files=][=ENDFOR=]|";[=
|
||||
"[= (join "\\0" (stack "files")) =]\0";[=
|
||||
|
||||
ELSE =]
|
||||
#define z[=(. Hack)=]List (char*)NULL[=
|
||||
@ -73,7 +73,7 @@ tSCC* apz[=(. Hack)=]Machs[] = {[=
|
||||
|
||||
ELSE =]
|
||||
#define apz[=(. Hack)=]Machs (const char**)NULL[=
|
||||
ENDIF (exist? "files") =][=
|
||||
ENDIF (exist? "mach") =][=
|
||||
|
||||
IF (exist? "select")=]
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1028,9 +1028,7 @@ fix = {
|
||||
*/
|
||||
fix = {
|
||||
hackname = broken_cabs;
|
||||
files = "math.h";
|
||||
files = "architecture/ppc/math.h";
|
||||
files = "architecture/i386/math.h";
|
||||
files = math.h, "architecture/*/math.h";
|
||||
select = "^extern[ \t]+double[ \t]+cabs";
|
||||
|
||||
c_fix = format;
|
||||
@ -1054,8 +1052,14 @@ fix = {
|
||||
|
||||
fix = {
|
||||
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/i386/math.h";
|
||||
files = "architecture/*/math.h";
|
||||
select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
|
||||
bypass = "powl";
|
||||
c_fix = format;
|
||||
@ -1294,7 +1298,7 @@ fix = {
|
||||
*/
|
||||
fix = {
|
||||
hackname = glibc_c99_inline_1;
|
||||
files = features.h;
|
||||
files = features.h, '*/features.h';
|
||||
select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
|
||||
c_fix = format;
|
||||
c_fix_arg = "%0 && __STDC_VERSION__ < 199901L";
|
||||
@ -1314,7 +1318,7 @@ EOT;
|
||||
*/
|
||||
fix = {
|
||||
hackname = glibc_c99_inline_2;
|
||||
files = sys/stat.h;
|
||||
files = sys/stat.h, '*/sys/stat.h';
|
||||
select = "extern __inline__ int";
|
||||
sed = "s/extern int \\(stat\\|lstat\\|fstat\\|mknod\\)/"
|
||||
"#if __STDC_VERSION__ < 199901L\\\nextern\\\n#endif\\\n"
|
||||
@ -1336,7 +1340,7 @@ EOT;
|
||||
|
||||
fix = {
|
||||
hackname = glibc_c99_inline_3;
|
||||
files = bits/string2.h;
|
||||
files = bits/string2.h, '*/bits/string2.h';
|
||||
bypass = "__STDC_VERSION__";
|
||||
c_fix = format;
|
||||
c_fix_arg = "# if defined(__cplusplus) || __STDC_VERSION__ >= 19901L";
|
||||
@ -1353,7 +1357,7 @@ EOT;
|
||||
|
||||
fix = {
|
||||
hackname = glibc_c99_inline_4;
|
||||
files = sys/sysmacros.h;
|
||||
files = sys/sysmacros.h, '*/sys/sysmacros.h';
|
||||
bypass = "__STDC_VERSION__";
|
||||
c_fix = format;
|
||||
c_fix_arg = "\n#if __STDC_VERSION__ < 19901L\nextern\n#endif\n";
|
||||
@ -2250,13 +2254,7 @@ fix = {
|
||||
fix = {
|
||||
hackname = kandr_concat;
|
||||
files = "sparc/asm_linkage.h";
|
||||
files = "sun3/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 = "sun*/asm_linkage.h";
|
||||
files = "arm/as_support.h";
|
||||
files = "arm/mc_type.h";
|
||||
files = "arm/xcb.h";
|
||||
@ -2851,14 +2849,7 @@ fix = {
|
||||
*/
|
||||
fix = {
|
||||
hackname = sco_math;
|
||||
files = 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;
|
||||
files = math.h, '*/math.h';
|
||||
select = "inline double abs";
|
||||
bypass = "__GNUG__";
|
||||
sed = "/#define.*__fp_class(a) \\\\/i\\\n"
|
||||
|
Loading…
Reference in New Issue
Block a user