You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use a fileliste edited with an Windows Editor als ASCII with CR+LF line endings and a last empty line,
i get the error
zstd -f -2 --fileliste windows_edited_filelist_with_empty_last_line.txt
Error : util.c, 317 : fgets(buf, (int) len, file)
When debugging zstd I saw, that the readLineFromChar is called
due the fact, that there is still something in the file (not feof() reached).
But the fgets result for the last line is NULL - and errno == 0. And then, after this fgets with result == NULL feof will be true.
To avoid this problem with my filelist, i changed the CONTROL (fgets) to CONTROL ((fgets != NULL) && (errno == 0)) like this, and a had success:
util.c
static size_t readLineFromFile(char* buf, size_t len, FILE* file)
{
...
CONTROL( (fgets(buf, (int) len, file) != NULL) || (errno == 0) ); // <<< last fgets for empty line in windows edited fileliste file produces a NULL and errno==0
static int
readLinesFromFile(void* dst, size_t dstCapacity,
const char* inputFileName)
{
**while ( !feof(inputFile) ) {**
It is just an idea, to change util.c to improve robustness of zstd.