From: Matt Kraai Date: Wed, 2 Jan 2002 18:51:23 +0000 (-0000) Subject: chomp should only remove the newline if it occurs at the end of the input. X-Git-Tag: 0_60_3~134 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0733e840bd1f94eee6a07f2a1986e29c9ddfe20c;p=oweals%2Fbusybox.git 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. --- 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; }