aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/chomp.c8
1 files changed, 5 insertions, 3 deletions
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 @@
25#include <string.h> 25#include <string.h>
26#include "libbb.h" 26#include "libbb.h"
27 27
28
28void chomp(char *s) 29void chomp(char *s)
29{ 30{
30 if (!(s && *s)) return; 31 char *lc = last_char_is(s, '\n');
31 while (*s && (*s != '\n')) s++; 32
32 *s = 0; 33 if(lc)
34 *lc = 0;
33} 35}
34 36
35 37