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).
No binary (build failed)
—
(log yok)
| @@ -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; |
| } | |