From e364498113e145b5ac424325e3903cc2287d7e7f Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Tue, 8 Apr 2014 18:25:27 -0400 Subject: [SV 41983] Support omitting the text argument to $(file ...) Reported by Tim Murphy * function.c (func_file): Only write TEXT if it is not NULL. * NEWS, doc/make.texi: Document the new feature * tests/scripts/functions/file: Verify that the no-text version of $(file ...) works and doesn't add a newline. --- function.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'function.c') diff --git a/function.c b/function.c index 72ecb7f..bb62187 100644 --- a/function.c +++ b/function.c @@ -2154,18 +2154,18 @@ func_file (char *o, char **argv, const char *funcname UNUSED) const char *err = strerror (errno); OSS (fatal, reading_file, _("open: %s: %s"), fn, err); } - else + if (argv[1]) { int l = strlen (argv[1]); - int nl = (l == 0 || argv[1][l-1] != '\n'); + int nl = l == 0 || argv[1][l-1] != '\n'; if (fputs (argv[1], fp) == EOF || (nl && fputc ('\n', fp) == EOF)) { const char *err = strerror (errno); OSS (fatal, reading_file, _("write: %s: %s"), fn, err); } - fclose (fp); } + fclose (fp); } else OS (fatal, reading_file, _("Invalid file operation: %s"), fn); -- cgit v1.2.3