A patch from Vladimir to simplify chomp()
This commit is contained in:
parent
4ad13e5d95
commit
f3f9f3efa7
@ -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';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user