[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
# -*-perl-*-
|
1999-09-14 10:03:19 +08:00
|
|
|
$description = "The following test tests that if you specify greater \n"
|
|
|
|
."than one '-f makefilename' on the command line, \n"
|
|
|
|
."that make concatenates them. This test creates three \n"
|
|
|
|
."makefiles and specifies all of them with the -f option \n"
|
|
|
|
."on the command line. To make sure they were concatenated, \n"
|
|
|
|
."we then call make with the rules from the concatenated \n"
|
|
|
|
."makefiles one at a time. Finally, it calls all three \n"
|
|
|
|
."rules in one call to make and checks that the output\n"
|
|
|
|
."is in the correct order.";
|
|
|
|
|
|
|
|
$makefile2 = &get_tmpfile;
|
|
|
|
$makefile3 = &get_tmpfile;
|
|
|
|
|
|
|
|
open(MAKEFILE,"> $makefile");
|
|
|
|
|
|
|
|
# The Contents of the MAKEFILE ...
|
|
|
|
|
|
|
|
print MAKEFILE "all: \n";
|
|
|
|
print MAKEFILE "\t\@echo This is the output from the original makefile\n";
|
|
|
|
|
|
|
|
# END of Contents of MAKEFILE
|
|
|
|
|
|
|
|
close(MAKEFILE);
|
|
|
|
|
|
|
|
# Create a second makefile
|
|
|
|
open(MAKEFILE,"> $makefile2");
|
|
|
|
print MAKEFILE "TWO: \n";
|
|
|
|
print MAKEFILE "\t\@echo This is the output from makefile 2\n";
|
|
|
|
close(MAKEFILE);
|
|
|
|
|
|
|
|
# Create a third makefile
|
|
|
|
open(MAKEFILE,"> $makefile3");
|
|
|
|
print MAKEFILE "THREE: \n";
|
|
|
|
print MAKEFILE "\t\@echo This is the output from makefile 3\n";
|
|
|
|
close(MAKEFILE);
|
|
|
|
|
|
|
|
|
|
|
|
# Create the answer to what should be produced by this Makefile
|
|
|
|
$answer = "This is the output from the original makefile\n";
|
|
|
|
|
|
|
|
# Run make to catch the default rule
|
|
|
|
&run_make_with_options($makefile,"-f $makefile2 -f $makefile3",&get_logfile,0);
|
|
|
|
|
|
|
|
&compare_output($answer,&get_logfile(1));
|
|
|
|
|
|
|
|
|
|
|
|
# Run Make again with the rule from the second makefile: TWO
|
|
|
|
$answer = "This is the output from makefile 2\n";
|
|
|
|
|
|
|
|
&run_make_with_options($makefile,"-f $makefile2 -f $makefile3 TWO",&get_logfile,0);
|
|
|
|
|
|
|
|
&compare_output($answer,&get_logfile(1));
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
|
1999-09-14 10:03:19 +08:00
|
|
|
|
|
|
|
# Run Make again with the rule from the third makefile: THREE
|
|
|
|
|
|
|
|
$answer = "This is the output from makefile 3\n";
|
|
|
|
&run_make_with_options($makefile,
|
|
|
|
"-f $makefile2 -f $makefile3 THREE",
|
|
|
|
&get_logfile,
|
|
|
|
0);
|
|
|
|
&compare_output($answer,&get_logfile(1));
|
|
|
|
|
|
|
|
|
|
|
|
# Run Make again with ALL three rules in the order 2 1 3 to make sure
|
|
|
|
# that all rules are executed in the proper order
|
|
|
|
|
|
|
|
$answer = "This is the output from makefile 2\n";
|
|
|
|
$answer .= "This is the output from the original makefile\n";
|
|
|
|
$answer .= "This is the output from makefile 3\n";
|
|
|
|
&run_make_with_options($makefile,
|
|
|
|
"-f $makefile2 -f $makefile3 TWO all THREE",
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
&get_logfile,
|
1999-09-14 10:03:19 +08:00
|
|
|
0);
|
|
|
|
&compare_output($answer,&get_logfile(1));
|
|
|
|
|
|
|
|
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
# sv 62118.
|
|
|
|
# Validate all sorts of -f etc. options
|
|
|
|
|
|
|
|
my $hello = 'hello.mk';
|
|
|
|
my $bye = 'bye.mk';
|
|
|
|
my $byesrc = 'bye.mk.src';
|
|
|
|
|
|
|
|
create_file($hello, 'all:; $(info hello, world)
|
|
|
|
');
|
|
|
|
|
|
|
|
create_file($bye, 'def:; $(info bye, world)
|
|
|
|
bye.mk: bye.mk.src; touch $@
|
|
|
|
bye.mk.src:; touch $@
|
|
|
|
');
|
|
|
|
|
|
|
|
# These invocations use the empty filename string so that the test framework
|
|
|
|
# doesn't add any -f options on its own.
|
|
|
|
|
|
|
|
# Incorrect order of options. -R follows -f.
|
|
|
|
# Invocation of make is equivalent to
|
|
|
|
# echo 'all:; $(info hello, world)' | make -f bye.mk -fR - all
|
|
|
|
# There is bye.mk, but there is no 'R'.
|
|
|
|
# make runs the recipes from bye.mk and prints the error about missing 'R'.
|
|
|
|
|
|
|
|
# Ensure the newly created bye.src.mk is newer than bye.mk.
|
|
|
|
&utouch(-600, $bye);
|
|
|
|
run_make_test('', "-f$bye -fR - all", "#MAKE#: R: No such file or directory
|
|
|
|
touch bye.mk.src
|
|
|
|
touch bye.mk
|
|
|
|
#MAKE#: *** No rule to make target 'R'. Stop.
|
|
|
|
", 512);
|
|
|
|
|
2022-04-19 04:57:06 +08:00
|
|
|
my @opts;
|
|
|
|
my $answer;
|
|
|
|
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
# Test double -f-.
|
2022-04-19 04:57:06 +08:00
|
|
|
@opts = ('-f- -f-', '-f - -f -', '-f- -f -', '-f - -f-',
|
|
|
|
'-f- --file=-', '-f- --file -', '-f - --file=-', '-f - --file -',
|
|
|
|
'-f- --makefile=-', '-f- --makefile -',
|
|
|
|
'-f - --makefile=-', '-f - --makefile -',
|
|
|
|
'--file=- --makefile=-', '--file=- --makefile -',
|
|
|
|
'--file - --makefile=-', '--file - --makefile -');
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
|
|
|
|
for my $opt (@opts) {
|
|
|
|
# We shouldn't need this; if the options are wrong then make shouldn't try
|
|
|
|
# to read from stdin.
|
|
|
|
close(STDIN);
|
|
|
|
open(STDIN, "<", $hello) || die "$0: cannot open $hello for reading: $!";
|
|
|
|
run_make_test('', "-f$bye $opt", "#MAKE#: *** Makefile from standard input specified twice. Stop.\n", 512);
|
|
|
|
}
|
|
|
|
|
|
|
|
# -f is not followed by filename.
|
2022-04-19 04:57:06 +08:00
|
|
|
@opts = ('-f', '--file', '--makefile');
|
|
|
|
$answer = "/requires an argument/";
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
for my $opt (@opts) {
|
|
|
|
run_make_test('', $opt, $answer, 512);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that make correctly parses all possible syntaxes to pipe make code to
|
|
|
|
# the standard input.
|
|
|
|
|
2022-04-19 04:57:06 +08:00
|
|
|
$answer = "touch bye.mk.src
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
touch bye.mk
|
|
|
|
hello, world
|
|
|
|
#MAKE#: 'all' is up to date.\n";
|
|
|
|
|
2022-04-19 04:57:06 +08:00
|
|
|
@opts = ('-f- all', '-f - all', '-Rf- all', '-Rf - all',
|
|
|
|
'--file=- all', '--file - all',
|
|
|
|
'--makefile=- all', '--makefile - all');
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
for my $opt (@opts) {
|
|
|
|
unlink($byesrc);
|
|
|
|
close(STDIN);
|
|
|
|
open(STDIN, "<", $hello) || die "$0: cannot open $hello for reading: $!";
|
|
|
|
# Ensure the newly created bye.src.mk is newer than bye.mk.
|
|
|
|
&utouch(-600, $bye);
|
|
|
|
|
|
|
|
run_make_test('', "-f$bye $opt", $answer);
|
|
|
|
}
|
|
|
|
|
2022-04-24 22:40:10 +08:00
|
|
|
close(STDIN);
|
[SV 62118] Correctly handle -f- options on re-exec
The -f, -file, and --makefile options were not properly handled when
re-exec'ing due to makefile updates. This problem, plus a patch and
tests, was reported by Dmitry Goncharov <dgoncharov@users.sf.net>.
While examining this I found another bug: after re-exec we forgot the
batch file was temporary and never deleted it.
I decided to fix all these problems at once using a different fix
than Dmitry's: I created a new internal-only command-line option,
--temp-stdin. When reconstructing the make options for a re-exec,
replace the -f/--file/--makefile option that reads from stdin with
--temp-stdin=<filename> so that the re-exec'd version of make knows
it's a temporary batch file and will delete it.
We no longer need to add the -o options because the re-exec'd make
knows this is a temporary makefile and treats it as such.
To simplify, replace the --file and --makefile options taking a
filename, with just -f<filename> on re-exec.
Some examples of the rewrite:
User command line Re-exec command line
----------------- --------------------
-f- --temp-stdin=<batch>
--file - --temp-stdin=<batch>
-f - --makefile a.mk --temp-stdin=<batch> -fa.mk
--file=a.mk -fa.mk
-fa.mk -fa.mk
-Rf a.mk -Rf a.mk
-Rf- -R --temp-stdin=<batch>
* src/main.c (stdin_offset): Remember the offset into the makefiles
list of the batch file read from stdin. Remove stdin_nm.
(struct command_switch): Create a new --temp-stdin option, which
also updates the makefiles list.
(main): Add the temporary filename to the string cache.
Move the tempfile handling after checking makefile arguments for "-"
so that files provided via --temp-stdin are also handled specially.
When rewriting re-exec options, we may need one more than we had
originally so create a new argv list. Walk through the original
list and convert it to the new list, following the above process.
(decode_switches): Set the stdin_offset flag if we see --temp-stdin.
* tests/scripts/options/dash-f: Add many more tests, provided by
Dmitry Goncharov <dgoncharov@users.sf.net>.
2022-02-28 04:24:19 +08:00
|
|
|
unlink($hello, $bye, $byesrc);
|
|
|
|
|
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
|
|
1;
|