From a35db9027526a8cad59c4e139ab224946245a7f7 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Wed, 7 Jan 2004 19:36:39 +0000 Subject: Fix order-only prerequisites for pattern rules. (Savannah patch #2349). Add a regression test for this. Older libraries don't allow *alloc(0), so make sure we don't ever do that. --- .cvsignore | 2 +- ChangeLog | 12 ++++++++++++ implicit.c | 10 +++++++--- misc.c | 5 ++++- tests/ChangeLog | 5 +++++ tests/scripts/features/order_only | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+), 5 deletions(-) diff --git a/.cvsignore b/.cvsignore index 7fc3895..54d5923 100644 --- a/.cvsignore +++ b/.cvsignore @@ -11,7 +11,7 @@ makebook* *.dep *.dvi *.toc *.aux *.log *.cp *.cps *.fn *.fns *.vr *.vrs *.tp *.tps *.ky *.kys *.pg *.pgs -README README.DOS README.W32 +README README.DOS README.W32 README.OS2 aclocal.m4 autom4te.cache config.h.in config.h config.status config.cache configure Makefile.in Makefile diff --git a/ChangeLog b/ChangeLog index 4a28b1c..2932ea8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-01-07 Paul D. Smith + + * implicit.c (pattern_search): When matching an implicit rule, + remember which dependencies have the ignore_mtime flag set. + Original fix provided in Savannah patch #2349, by Benoit + Poulot-Cazajous . + 2003-11-02 Paul D. Smith * function.c (func_if): Strip all the trailing whitespace from the @@ -17,6 +24,11 @@ (get-config/config.guess get-config/config.sub): Get these files from the Savannah config project instead of ftp.gnu.org. +2003-08-22 Paul D. Smith + + * misc.c (xmalloc, xrealloc): Add one to 0 sizes, to cater to + systems which don't yet implement the C89 standard :-/. + 2003-07-18 Paul D. Smith * dir.c (directory_contents_hash_1, directory_contents_hash_1) diff --git a/implicit.c b/implicit.c index 944d57a..1fa0534 100644 --- a/implicit.c +++ b/implicit.c @@ -103,6 +103,8 @@ pattern_search (struct file *file, int archive, /* This buffer records all the dependencies actually found for a rule. */ char **found_files = (char **) alloca (max_pattern_deps * sizeof (char *)); + /* This list notes if the associated dep has an "ignore_mtime" flag set. */ + unsigned char *found_files_im = (unsigned char *) alloca (max_pattern_deps * sizeof (unsigned char)); /* Number of dep names now in FOUND_FILES. */ unsigned int deps_found = 0; @@ -397,6 +399,7 @@ pattern_search (struct file *file, int archive, if (lookup_file (p) != 0 || ((!dep->changed || check_lastslash) && file_exists_p (p))) { + found_files_im[deps_found] = dep->ignore_mtime; found_files[deps_found++] = xstrdup (p); continue; } @@ -408,6 +411,7 @@ pattern_search (struct file *file, int archive, DBS (DB_IMPLICIT, (_("Found prerequisite `%s' as VPATH `%s'\n"), p, vp)); strcpy (vp, p); + found_files_im[deps_found] = dep->ignore_mtime; found_files[deps_found++] = vp; continue; } @@ -437,11 +441,11 @@ pattern_search (struct file *file, int archive, intermediate_file->name = p; intermediate_files[deps_found] = intermediate_file; intermediate_file = 0; + found_files_im[deps_found] = dep->ignore_mtime; /* Allocate an extra copy to go in FOUND_FILES, because every elt of FOUND_FILES is consumed or freed later. */ - found_files[deps_found] = xstrdup (p); - ++deps_found; + found_files[deps_found++] = xstrdup (p); continue; } @@ -541,7 +545,7 @@ pattern_search (struct file *file, int archive, } dep = (struct dep *) xmalloc (sizeof (struct dep)); - dep->ignore_mtime = 0; + dep->ignore_mtime = found_files_im[deps_found]; s = found_files[deps_found]; if (recursions == 0) { diff --git a/misc.c b/misc.c index ef754e5..9e5a516 100644 --- a/misc.c +++ b/misc.c @@ -357,7 +357,8 @@ pfatal_with_name (const char *name) char * xmalloc (unsigned int size) { - char *result = (char *) malloc (size); + /* Make sure we don't allocate 0, for pre-ANSI libraries. */ + char *result = (char *) malloc (size ? size : 1); if (result == 0) fatal (NILF, _("virtual memory exhausted")); return result; @@ -370,6 +371,8 @@ xrealloc (char *ptr, unsigned int size) char *result; /* Some older implementations of realloc() don't conform to ANSI. */ + if (! size) + size = 1; result = ptr ? realloc (ptr, size) : malloc (size); if (result == 0) fatal (NILF, _("virtual memory exhausted")); diff --git a/tests/ChangeLog b/tests/ChangeLog index 0f6da1b..76e725d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2004-01-07 Paul D. Smith + + * scripts/features/order_only: Test order-only prerequisites in + pattern rules (patch #2349). + 2003-11-02 Paul D. Smith * scripts/functions/if: Test if on conditionals with trailing diff --git a/tests/scripts/features/order_only b/tests/scripts/features/order_only index e324d68..ac0d538 100644 --- a/tests/scripts/features/order_only +++ b/tests/scripts/features/order_only @@ -109,4 +109,39 @@ $answer = "touch baz\n"; unlink(qw(foo baz)); +# Test order-only in pattern rules + +$makefile4 = &get_tmpfile; + +open(MAKEFILE,"> $makefile4"); + +print MAKEFILE <<'EOF'; +%.w : %.x | baz + @echo '$$^ = $^' + @echo '$$| = $|' + touch $@ + +all: foo.w + +.PHONY: baz +foo.x baz: + touch $@ +EOF + +close(MAKEFILE); + +# TEST #7 -- make sure the parser was correct. + +&run_make_with_options($makefile4, "", &get_logfile); +$answer = "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #8 -- now we do it again: this time foo.w won't be built + +&run_make_with_options($makefile4, "", &get_logfile); +$answer = "touch baz\n"; +&compare_output($answer,&get_logfile(1)); + +unlink(qw(foo.w foo.x baz)); + 1; -- cgit v1.2.3