summaryrefslogtreecommitdiff
path: root/function.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2014-04-08 18:25:27 -0400
committerPaul Smith <psmith@gnu.org>2014-07-07 01:59:03 -0400
commite364498113e145b5ac424325e3903cc2287d7e7f (patch)
treee27af5556c7f8ff34393979ea4b2a3a206052202 /function.c
parent85047eb9044d4b72d50e6620c505c675d55ab98b (diff)
downloadgunmake-e364498113e145b5ac424325e3903cc2287d7e7f.tar.gz
[SV 41983] Support omitting the text argument to $(file ...)
Reported by Tim Murphy <tnmurphy@gmail.com> * 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.
Diffstat (limited to 'function.c')
-rw-r--r--function.c6
1 files changed, 3 insertions, 3 deletions
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);