chomp: Check for beginning of string while removing \n's

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2019-09-25 08:51:56 +02:00
parent f873635cfe
commit 2aed5a6b3f
+1 -1
View File
@@ -39,7 +39,7 @@ char *chomp(char *str)
}
p = str + strlen(str) - 1;
while (*p == '\n')
while (p >= str && *p == '\n')
*p-- = 0;
return str;