The new line detection is earlier using only '\n' so there should not be need to search for '\r' later. The detection whether allocated address is pointing to null seems to be unnecessary. Assuming xmalloc() returned valid address space the address should never be 0. Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- text-utils/rev.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/text-utils/rev.c b/text-utils/rev.c index 0456c2b..1665772 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'); } -- 1.8.3 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html