MEDIUM: tools: read_line_to_trash() handle empty files without \n

fgets() returns NULL when EOF is reached before newline, handle
that as a success for consistency, current behaviour is arguably a bug,
the API of fgets() is pretty weird after all so someone probably forgot.
This commit is contained in:
Mia Kanashi 2026-05-07 00:17:39 +03:00 committed by William Lallemand
parent faf3e9ac3a
commit 83e6ae3334

View File

@ -6906,6 +6906,9 @@ ssize_t read_line_to_trash(const char *path_fmt, ...)
trash.data--;
trash.area[trash.data] = 0;
ret = trash.data; // success
} else if (feof(file)) {
/* empty file is allowed */
ret = 0;
}
fclose(file);