summaryrefslogtreecommitdiff
path: root/libbb/chomp.c
diff options
context:
space:
mode:
authorMatt Kraai2002-01-02 18:51:23 +0000
committerMatt Kraai2002-01-02 18:51:23 +0000
commit0733e840bd1f94eee6a07f2a1986e29c9ddfe20c (patch)
tree2476ab020f6664d69f247bfef800d50e05a983b0 /libbb/chomp.c
parentd21735de2d7380d96cd42458c6d9775143abe6ea (diff)
downloadbusybox-0733e840bd1f94eee6a07f2a1986e29c9ddfe20c.zip
busybox-0733e840bd1f94eee6a07f2a1986e29c9ddfe20c.tar.gz
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.
Diffstat (limited to 'libbb/chomp.c')
-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;
}