From 36f955b0e8d2c1b5be292eb84475c44eea6403c8 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 8 Jan 2023 18:06:54 -0500 Subject: [SV 17448] Ignore whitespace around $(file ...) names The other issues related to whitespace reported in this bug are not addressed by this change. * src/functions.c (func_file): Strip whitespace from the start and end of the filename provided to the $(file ...) function. * tests/scripts/functions/file: Add tests for this. * tests/test_driver.pl: Use 3-arg version of open(). --- tests/scripts/functions/file | 12 +++++++++++- tests/test_driver.pl | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/scripts/functions/file b/tests/scripts/functions/file index 50948a04..48318b08 100644 --- a/tests/scripts/functions/file +++ b/tests/scripts/functions/file @@ -23,7 +23,7 @@ define A a b endef -$(file >> file.out,$(A)) +$(file >> file.out ,$(A)) x:;@cat file.out !, '', "a\nb"); @@ -219,4 +219,14 @@ run_make_test('$(file <)', '', run_make_test('$(file foo)', '', "#MAKEFILE#:1: *** file: invalid file operation: foo. Stop.\n", 512); +# SV 17448: check whitespace +create_file('out1', "1\n"); + +run_make_test(q! +all:;$(info $(file < out1 )) +!, + '', "1\n#MAKE#: 'all' is up to date."); + +unlink('out1'); + 1; diff --git a/tests/test_driver.pl b/tests/test_driver.pl index e7e57763..38ec4587 100644 --- a/tests/test_driver.pl +++ b/tests/test_driver.pl @@ -434,7 +434,7 @@ sub get_osname # See if the filesystem supports long file names with multiple # dots. DOS doesn't. $short_filenames = 0; - (open (TOUCHFD, "> fancy.file.name") and close (TOUCHFD)) + (open (TOUCHFD, '>', 'fancy.file.name') and close (TOUCHFD)) or $short_filenames = 1; unlink ("fancy.file.name") or $short_filenames = 1; @@ -1287,7 +1287,7 @@ sub remove_directory_tree_inner # # foreach my $file (@filenames) { # utime ($now, $now, $file) -# or (open (TOUCHFD, ">> $file") and close (TOUCHFD)) +# or (open (TOUCHFD, '>>', $file) and close (TOUCHFD)) # or &error ("Couldn't touch $file: $!\n", 1); # } # return 1; @@ -1334,7 +1334,7 @@ sub create_file { my ($filename, @lines) = @_; - open (CF, "> $filename") or &error ("Couldn't open $filename: $!\n", 1); + open (CF, '>', $filename) or &error ("Couldn't open '$filename': $!\n", 1); foreach $line (@lines) { print CF $line; } -- cgit v1.2.1