rev: fix new line regression

Commit 4b4eb34004 made output incorrect for
input lines that does not have new line.  For example

$ printf "a b c\n1 2 3" | rev
c b a
 2 13

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2013-09-10 20:51:14 +01:00 committed by Karel Zak
parent 050babd4e4
commit d267fdb854
1 changed files with 3 additions and 1 deletions

View File

@ -163,7 +163,9 @@ int main(int argc, char *argv[])
len = wcslen(buf);
}
reverse_str(buf, len - 1);
if (buf[len - 1] == '\n')
buf[len--] = '\0';
reverse_str(buf, len);
fputws(buf, stdout);
}
if (ferror(fp)) {