aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbb/chomp.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/libbb/chomp.c b/libbb/chomp.c
index d2f6d5e6f..e62cb4005 100644
--- a/libbb/chomp.c
+++ b/libbb/chomp.c
@@ -32,13 +32,10 @@
void chomp(char *s)
{
- size_t len = strlen(s);
-
- if (len == 0)
- return;
-
- if (s[len-1] == '\n')
- s[len-1] = '\0';
+ char *lc = (char *)last_char_is(s, '\n');
+
+ if(lc)
+ *lc = 0;
}