1
0
Fork 0
mirror of https://github.com/pygos/pkg-utils.git synced 2024-11-22 04:49:46 +01:00

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

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;
}