aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2002-01-02 18:51:23 +0000
committerMatt Kraai <kraai@debian.org>2002-01-02 18:51:23 +0000
commit0733e840bd1f94eee6a07f2a1986e29c9ddfe20c (patch)
tree2476ab020f6664d69f247bfef800d50e05a983b0
parentd21735de2d7380d96cd42458c6d9775143abe6ea (diff)
downloadbusybox-w32-0733e840bd1f94eee6a07f2a1986e29c9ddfe20c.tar.gz
busybox-w32-0733e840bd1f94eee6a07f2a1986e29c9ddfe20c.tar.bz2
busybox-w32-0733e840bd1f94eee6a07f2a1986e29c9ddfe20c.zip
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.
-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