A patch from Vladimir to simplify chomp()

This commit is contained in:
Eric Andersen 2001-05-07 23:02:39 +00:00
parent 4ad13e5d95
commit f3f9f3efa7

View File

@ -32,13 +32,10 @@
void chomp(char *s) void chomp(char *s)
{ {
size_t len = strlen(s); char *lc = (char *)last_char_is(s, '\n');
if (len == 0) if(lc)
return; *lc = 0;
if (s[len-1] == '\n')
s[len-1] = '\0';
} }