diff options
-rw-r--r-- | text-utils/rev.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/text-utils/rev.c b/text-utils/rev.c index 0456c2b14..1665772b2 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -154,11 +154,10 @@ int main(int argc, char *argv[]) len = wcslen(buf); } - t = buf + len - 1 - (*(buf+len-1)=='\r' || *(buf+len-1)=='\n'); - for ( ; t >= buf; --t) { - if (*t != 0) - putwchar(*t); - } + if (*(t = buf + len - 1) == '\n') + --t; + for ( ; buf <= t; --t) + putwchar(*t); if (!feof(fp)) putwchar('\n'); } |