file processing: remove trailing spaces from line

Such as a line feed left there by getline().

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-01-31 17:50:49 +01:00
parent 417fa5b907
commit 134458b85a
1 changed files with 9 additions and 0 deletions

View File

@ -40,6 +40,15 @@ retry:
if (ptr != f->line)
memmove(f->line, ptr, strlen(ptr) + 1);
ptr = f->line + strlen(f->line);
while (ptr > f->line && isspace(ptr[-1]))
--ptr;
*ptr = '\0';
if (f->line[0] == '\0')
goto retry;
return 0;
}