. Fix chomp()'s checking of empty strings.

This commit is contained in:
Emil Mikulic 2003-11-30 11:04:37 +00:00
parent c58880c10a
commit 7df4b55839

View File

@ -788,8 +788,9 @@ static char *read_line(FILE *fp)
*/
static void chomp(char *str)
{
size_t pos = strlen(str) - 1;
if ((pos >= 0) && (str[pos] == '\n')) str[pos] = '\0';
size_t len = strlen(str);
if (len == 0) return;
if (str[len-1] == '\n') str[len-1] = '\0';
}