diff options
author | kraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-01-02 18:51:23 +0000 |
---|---|---|
committer | kraai <kraai@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-01-02 18:51:23 +0000 |
commit | 6b6b4ac350169ab09145854274de9580051d8588 (patch) | |
tree | 2476ab020f6664d69f247bfef800d50e05a983b0 /libbb | |
parent | 510e104cd328b9957fec758de3da66169e750f0a (diff) | |
download | busybox-w32-6b6b4ac350169ab09145854274de9580051d8588.tar.gz busybox-w32-6b6b4ac350169ab09145854274de9580051d8588.tar.bz2 busybox-w32-6b6b4ac350169ab09145854274de9580051d8588.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.
git-svn-id: svn://busybox.net/trunk/busybox@3992 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/chomp.c | 8 |
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 | |||
28 | void chomp(char *s) | 29 | void 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 | ||