diff options
author | Paul Smith <psmith@gnu.org> | 2014-04-08 18:25:27 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2014-07-07 01:59:03 -0400 |
commit | e364498113e145b5ac424325e3903cc2287d7e7f (patch) | |
tree | e27af5556c7f8ff34393979ea4b2a3a206052202 /function.c | |
parent | 85047eb9044d4b72d50e6620c505c675d55ab98b (diff) | |
download | gunmake-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.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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); |