From 0733e840bd1f94eee6a07f2a1986e29c9ddfe20c Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 2 Jan 2002 18:51:23 +0000 Subject: chomp should only remove the newline if it occurs at the end of the input. This was caught by the test suite (in sed/sed-aic-commands). * libbb/chomp.c: Revert to revision 1.5. --- libbb/chomp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libbb/chomp.c') diff --git a/libbb/chomp.c b/libbb/chomp.c index e5a522f01..94404a98d 100644 --- a/libbb/chomp.c +++ b/libbb/chomp.c @@ -25,11 +25,13 @@ #include #include "libbb.h" + void chomp(char *s) { - if (!(s && *s)) return; - while (*s && (*s != '\n')) s++; - *s = 0; + char *lc = last_char_is(s, '\n'); + + if(lc) + *lc = 0; } -- cgit v1.2.3