From: Sami Kerola Date: Tue, 10 Sep 2013 19:51:14 +0000 (+0100) Subject: rev: fix new line regression X-Git-Tag: v2.24-rc1~271 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d267fdb8540202f77efb28fdf5dddd9826626757;p=thirdparty%2Futil-linux.git rev: fix new line regression Commit 4b4eb34004378fe70259acd8f2f859e7b5cc3726 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 --- diff --git a/text-utils/rev.c b/text-utils/rev.c index 85e16306b3..f1341cb3d2 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -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)) {