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; }