summaryrefslogtreecommitdiff
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 e5a522f..94404a9 100644
--- a/libbb/chomp.c
+++ b/libbb/chomp.c
@@ -25,11 +25,13 @@
#include <string.h>
#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;
}