mirror of
https://github.com/mirror/make.git
synced 2025-01-28 05:10:24 +08:00
Fixed stem termination and stem triple-expansion bugs.
This commit is contained in:
parent
0759af440a
commit
cb2f200269
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
Thu Mar 3 18:28:15 2005 Boris Kolpackov <boris@kolpackov.net>
|
||||||
|
|
||||||
|
* read.c (record_files): Instead of substituting % with
|
||||||
|
actual stem value in dependency list replace it with $*.
|
||||||
|
This fixes stem triple expansion bug.
|
||||||
|
|
||||||
|
* implicit.c (pattern_search): Copy stem to a separate
|
||||||
|
buffer and make it a properly terminated string. Assign
|
||||||
|
this buffer instead of STEM (which is not terminated) to
|
||||||
|
f->stem. Instead of substituting % with actual stem value
|
||||||
|
in dependency list replace it with $*. This fixes stem
|
||||||
|
triple expansion bug.
|
||||||
|
|
||||||
Tue Mar 1 10:12:20 2005 Boris Kolpackov <boris@kolpackov.net>
|
Tue Mar 1 10:12:20 2005 Boris Kolpackov <boris@kolpackov.net>
|
||||||
|
|
||||||
* read.c (record_files): Add a check for the list of prerequisites
|
* read.c (record_files): Add a check for the list of prerequisites
|
||||||
|
26
implicit.c
26
implicit.c
@ -271,6 +271,8 @@ pattern_search (struct file *file, int archive,
|
|||||||
struct idep **id_ptr;
|
struct idep **id_ptr;
|
||||||
struct dep **d_ptr;
|
struct dep **d_ptr;
|
||||||
|
|
||||||
|
PATH_VAR (stem_str); /* @@ Need to get rid of stem, stemlen, etc. */
|
||||||
|
|
||||||
#ifndef NO_ARCHIVES
|
#ifndef NO_ARCHIVES
|
||||||
if (archive || ar_name (filename))
|
if (archive || ar_name (filename))
|
||||||
lastslash = 0;
|
lastslash = 0;
|
||||||
@ -466,8 +468,11 @@ pattern_search (struct file *file, int archive,
|
|||||||
DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
|
DBS (DB_IMPLICIT, (_("Trying pattern rule with stem `%.*s'.\n"),
|
||||||
(int) stemlen, stem));
|
(int) stemlen, stem));
|
||||||
|
|
||||||
|
strncpy (stem_str, stem, stemlen);
|
||||||
|
stem_str[stemlen] = '\0';
|
||||||
|
|
||||||
/* Temporary assign STEM to file->stem and set file variables. */
|
/* Temporary assign STEM to file->stem and set file variables. */
|
||||||
file->stem = stem;
|
file->stem = stem_str;
|
||||||
set_file_variables (file);
|
set_file_variables (file);
|
||||||
|
|
||||||
/* Try each dependency; see if it "exists". */
|
/* Try each dependency; see if it "exists". */
|
||||||
@ -503,7 +508,18 @@ pattern_search (struct file *file, int archive,
|
|||||||
if (p == 0)
|
if (p == 0)
|
||||||
break; /* No more words */
|
break; /* No more words */
|
||||||
|
|
||||||
/* If the dependency name has %, substitute the stem. */
|
/* If the dependency name has %, substitute the stem.
|
||||||
|
Watch out, we are going to do something very smart
|
||||||
|
here. If we just replace % with the stem value,
|
||||||
|
later, when we do the second expansion, we will
|
||||||
|
re-expand this stem value once again. This is not
|
||||||
|
good especially if you have certain characters in
|
||||||
|
your setm (like $).
|
||||||
|
|
||||||
|
Instead, we will replace % with $* and allow the
|
||||||
|
second expansion to take care of it for us. This
|
||||||
|
way (since $* is a simple variable) there won't
|
||||||
|
be additional re-expansion of the stem.*/
|
||||||
|
|
||||||
for (p2 = p; p2 < p + len && *p2 != '%'; ++p2);
|
for (p2 = p; p2 < p + len && *p2 != '%'; ++p2);
|
||||||
|
|
||||||
@ -511,9 +527,9 @@ pattern_search (struct file *file, int archive,
|
|||||||
{
|
{
|
||||||
register unsigned int i = p2 - p;
|
register unsigned int i = p2 - p;
|
||||||
bcopy (p, depname, i);
|
bcopy (p, depname, i);
|
||||||
bcopy (stem, depname + i, stemlen);
|
bcopy ("$*", depname + i, 2);
|
||||||
bcopy (p2 + 1, depname + i + stemlen, len - i - 1);
|
bcopy (p2 + 1, depname + i + 2, len - i - 1);
|
||||||
depname[len + stemlen - 1] = '\0';
|
depname[len + 2 - 1] = '\0';
|
||||||
|
|
||||||
if (check_lastslash)
|
if (check_lastslash)
|
||||||
add_dir = 1;
|
add_dir = 1;
|
||||||
|
23
read.c
23
read.c
@ -1911,32 +1911,17 @@ record_files (struct nameseq *filenames, char *pattern, char *pattern_percent,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* We use patsubst_expand to do the work of translating
|
/* We use subst_expand to do the work of translating
|
||||||
the target pattern, the target's name and the dependencies'
|
% to $* in the dependency line. */
|
||||||
patterns into plain dependency names. */
|
|
||||||
|
|
||||||
if (this != 0 && find_percent (this->name) != 0)
|
if (this != 0 && find_percent (this->name) != 0)
|
||||||
{
|
{
|
||||||
PATH_VAR (stem);
|
|
||||||
char *o;
|
char *o;
|
||||||
char *buffer = variable_expand ("");
|
char *buffer = variable_expand ("");
|
||||||
|
|
||||||
o = patsubst_expand (buffer, name, pattern, "%",
|
o = subst_expand (buffer, this->name, "%", "$*",
|
||||||
pattern_percent + 1, 0);
|
1, 2, 0);
|
||||||
|
|
||||||
|
|
||||||
strncpy (stem, buffer, o - buffer);
|
|
||||||
stem[o - buffer] = '\0';
|
|
||||||
|
|
||||||
o = subst_expand (buffer, this->name, "%", stem,
|
|
||||||
1, strlen (stem), 0);
|
|
||||||
|
|
||||||
/* If the name expanded to the empty string, that's
|
|
||||||
illegal. */
|
|
||||||
if (o == buffer)
|
|
||||||
fatal (flocp,
|
|
||||||
_("target `%s' leaves prerequisite pattern empty"),
|
|
||||||
name);
|
|
||||||
free (this->name);
|
free (this->name);
|
||||||
this->name = savestring (buffer, o - buffer);
|
this->name = savestring (buffer, o - buffer);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
|
Thu Mar 3 18:34:06 2005 Boris Kolpackov <boris@kolpackov.net>
|
||||||
|
|
||||||
|
* scripts/features/se_implicit: Add a test for stem
|
||||||
|
termination bug. Add a test for stem triple-expansion bug.
|
||||||
|
|
||||||
|
* scripts/features/se_statpat: Add a test for stem
|
||||||
|
triple-expansion bug.
|
||||||
|
|
||||||
|
* scripts/features/statipattrules: Change test #4 to reflect
|
||||||
|
new way empty prerequisite list is handled.
|
||||||
|
|
||||||
|
|
||||||
Tue Mar 1 10:15:25 2005 Boris Kolpackov <boris@kolpackov.net>
|
Tue Mar 1 10:15:25 2005 Boris Kolpackov <boris@kolpackov.net>
|
||||||
|
|
||||||
* tests/scripts/features/statipattrules: Add a test for
|
* scripts/features/statipattrules: Add a test for
|
||||||
Savannah bug #12180.
|
Savannah bug #12180.
|
||||||
|
|
||||||
2005-02-28 Paul D. Smith <psmith@gnu.org>
|
2005-02-28 Paul D. Smith <psmith@gnu.org>
|
||||||
|
@ -183,6 +183,42 @@ foo.c: ; @echo $@
|
|||||||
foo.o: {foo.c} foo.c
|
foo.o: {foo.c} foo.c
|
||||||
');
|
');
|
||||||
|
|
||||||
|
# Test #7: Test stem from the middle of the name.
|
||||||
|
#
|
||||||
|
run_make_test('
|
||||||
|
foobarbaz:
|
||||||
|
|
||||||
|
foo%baz: % $$*.1
|
||||||
|
@echo $*
|
||||||
|
|
||||||
|
bar bar.1:
|
||||||
|
@echo $@
|
||||||
|
|
||||||
|
',
|
||||||
|
'',
|
||||||
|
'bar
|
||||||
|
bar.1
|
||||||
|
bar
|
||||||
|
');
|
||||||
|
|
||||||
|
# Test #8: Make sure stem triple-expansion does not happen.
|
||||||
|
#
|
||||||
|
run_make_test('
|
||||||
|
foo$$bar:
|
||||||
|
|
||||||
|
f%r: % $$*.1
|
||||||
|
@echo \'$*\'
|
||||||
|
|
||||||
|
oo$$ba oo$$ba.1:
|
||||||
|
@echo \'$@\'
|
||||||
|
|
||||||
|
',
|
||||||
|
'',
|
||||||
|
'oo$ba
|
||||||
|
oo$ba.1
|
||||||
|
oo$ba
|
||||||
|
');
|
||||||
|
|
||||||
|
|
||||||
# This tells the test driver that the perl test script executed properly.
|
# This tells the test driver that the perl test script executed properly.
|
||||||
1;
|
1;
|
||||||
|
@ -102,5 +102,23 @@ baz.a.1
|
|||||||
baz.a.2
|
baz.a.2
|
||||||
');
|
');
|
||||||
|
|
||||||
|
|
||||||
|
# Test #4: Make sure stem triple-expansion does not happen.
|
||||||
|
#
|
||||||
|
run_make_test('
|
||||||
|
foo$$bar: f%r: % $$*.1
|
||||||
|
@echo \'$*\'
|
||||||
|
|
||||||
|
oo$$ba oo$$ba.1:
|
||||||
|
@echo \'$@\'
|
||||||
|
|
||||||
|
',
|
||||||
|
'',
|
||||||
|
'oo$ba
|
||||||
|
oo$ba.1
|
||||||
|
oo$ba
|
||||||
|
');
|
||||||
|
|
||||||
|
|
||||||
# This tells the test driver that the perl test script executed properly.
|
# This tells the test driver that the perl test script executed properly.
|
||||||
1;
|
1;
|
||||||
|
@ -55,11 +55,11 @@ unlink('foo.el', 'bar.c', 'lose.c');
|
|||||||
|
|
||||||
$makefile2 = &get_tmpfile;
|
$makefile2 = &get_tmpfile;
|
||||||
open(MAKEFILE, "> $makefile2");
|
open(MAKEFILE, "> $makefile2");
|
||||||
print MAKEFILE "foo: foo%: % ; \@echo $@\n";
|
print MAKEFILE "foo: foo%: % ; \@echo \$@\n";
|
||||||
close(MAKEFILE);
|
close(MAKEFILE);
|
||||||
|
|
||||||
&run_make_with_options($makefile2, '', &get_logfile, 512);
|
&run_make_with_options($makefile2, '', &get_logfile);
|
||||||
$answer = "$makefile2:1: *** target `foo' leaves prerequisite pattern empty. Stop.\n";
|
$answer = "foo\n";
|
||||||
&compare_output($answer, &get_logfile(1));
|
&compare_output($answer, &get_logfile(1));
|
||||||
|
|
||||||
# TEST #5 -- bug #12180: core dump on a stat pattern rule with an empty
|
# TEST #5 -- bug #12180: core dump on a stat pattern rule with an empty
|
||||||
|
Loading…
Reference in New Issue
Block a user