This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fixincludes] PR29867 - [4.3 Regression] fixes not applied due to distro-specific subdirectories
Daniel Franke wrote:
> On Thursday 21 December 2006 21:17, Bruce Korb wrote:
>> On 12/21/06, Daniel Franke <franke.daniel@gmail.com> wrote:
>>> Any hints how to proceed? Bruce?
>> Convert "strstr()" to use "fnmatch()" and use a globbing pattern. [...]
>> I'll try to get to it over new year, if someone doesn't scratch the
>> itch before then.
>
> Bruce,
>
> I attached a patch to PR29867 that replaces strstr() by fnmatch() in
> fixincl.c(fix_applies). This solves the issue for me, now everything
> bootstrapps and regtests fine.
>
> However, the patch did not improve the matter for Jean-Pierre, the reporter.
> It seems that we have to deal with two different issues here ...
>
> Regards
> Daniel
Hi Daniel,
I don't see your patch :(. So, attached is _my_ patch :-).
(My niece seems to sleep late, so I had a few moments....)
I'm doing a bootstrap test now, so I'm not 100% certain it
even compiles yet. ;)
Cheers - Bruce
P.S. I abbreviated the patch because 95% of the diff is generated and boring.
Anyone using it would need to regenerate fixincl.x.
Index: fixincl.tpl
===================================================================
--- fixincl.tpl (revision 120173)
+++ fixincl.tpl (working copy)
@@ -48,7 +48,7 @@
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 @@
ELSE =]
#define apz[=(. Hack)=]Machs (const char**)NULL[=
- ENDIF (exist? "files") =][=
+ ENDIF (exist? "mach") =][=
IF (exist? "select")=]
Index: fixincl.c
===================================================================
--- fixincl.c (revision 120173)
+++ fixincl.c (working copy)
@@ -359,96 +359,31 @@
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_mach == 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 +1009,11 @@
/* * * * * * * * * * * * *
-
- 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 +1022,7 @@
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 +1030,10 @@
*/
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 +1048,11 @@
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;
}
}
Index: fixincl.x
===================================================================
--- fixincl.x (revision 120173)
+++ fixincl.x (working copy)
@@ -2,11 +2,11 @@
*
* DO NOT EDIT THIS FILE (fixincl.x)
*
- * It has been AutoGen-ed Monday November 6, 2006 at 11:04:01 AM CET
+ * It has been AutoGen-ed Saturday December 23, 2006 at 10:38:16 AM PST
* From the definitions inclhack.def
* and the template file fixincl
*/
-/* DO NOT CVS-MERGE THIS FILE, EITHER Mon Nov 6 11:04:01 CET 2006
+/* DO NOT CVS-MERGE THIS FILE, EITHER Sat Dec 23 10:38:16 PST 2006
*
* You must regenerate it. Use the ./genfixes script.
*
@@ -26,7 +26,8 @@
*
* You may redistribute it and/or modify it under the terms of the
* GNU General Public License, as published by the Free Software
- * Foundation; either version 2, or (at your option) any later version.
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
*
* inclhack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -34,10 +35,10 @@
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with inclhack. See the file "COPYING". If not,
- * write to: The Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * along with inclhack. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * *
@@ -51,7 +52,7 @@
* File name selection pattern
*/
tSCC zAab_Darwin7_9_Long_Double_FuncsList[] =
- "|architecture/ppc/math.h|";
+ "architecture/ppc/math.h\0";
/*
* Machine/OS name selection pattern
*/
## [[ ... ]]
@@ -1362,7 +1363,7 @@
* File name selection pattern
*/
tSCC zAvoid_Bool_DefineList[] =
- "|curses.h|curses_colr/curses.h|term.h|tinfo.h|";
+ "curses.h\0curses_colr/curses.h\0term.h\0tinfo.h\0";
/*
* Machine/OS name selection pattern
*/
@@ -1407,7 +1408,7 @@
* File name selection pattern
*/
tSCC zAvoid_Bool_TypeList[] =
- "|curses.h|curses_colr/curses.h|term.h|tinfo.h|";
+ "curses.h\0curses_colr/curses.h\0term.h\0tinfo.h\0";
/*
* Machine/OS name selection pattern
*/
## [[ ... ]]