From: Jim Meyering Date: Wed, 27 Aug 2003 11:41:49 +0000 (+0000) Subject: (paste_parallel): Don't output `EOF' (aka -1) as a `char'. X-Git-Tag: v5.0.91~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bd780f6a390692682246de54dc222a7898c4233;p=thirdparty%2Fcoreutils.git (paste_parallel): Don't output `EOF' (aka -1) as a `char'. This would happen for nonempty files not ending with a newline. --- diff --git a/src/paste.c b/src/paste.c index dfc46cafc2..a417093811 100644 --- a/src/paste.c +++ b/src/paste.c @@ -294,7 +294,7 @@ paste_parallel (int nfiles, char **fnamptr) /* Except for last file, replace last newline with delim. */ if (fileptr[i + 1] != ENDLIST) { - if (chr != '\n') + if (chr != '\n' && chr != EOF) putc (chr, stdout); if (*delimptr != EMPTY_DELIM) putc (*delimptr, stdout); @@ -302,7 +302,12 @@ paste_parallel (int nfiles, char **fnamptr) delimptr = delims; } else - putc (chr, stdout); + { + /* If the last line of the last file lacks a newline, + print one anyhow. POSIX requires this. */ + char c = (chr == EOF ? '\n' : chr); + putc (c, stdout); + } } } }