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.
This commit is contained in:
Matt Kraai 2002-01-02 18:51:23 +00:00
parent d21735de2d
commit 0733e840bd

View File

@ -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;
}