Fixed fread test.
This commit is contained in:
parent
beb77d0e2d
commit
4e4d36d833
|
@ -158,6 +158,10 @@ static cmph_uint32 count_nlfile_keys(FILE *fd)
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
ptr = fgets(buf, BUFSIZ, fd);
|
ptr = fgets(buf, BUFSIZ, fd);
|
||||||
if (feof(fd)) break;
|
if (feof(fd)) break;
|
||||||
|
if (ferror(fd) || ptr == NULL) {
|
||||||
|
perror("Error reading input file");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (buf[strlen(buf) - 1] != '\n') continue;
|
if (buf[strlen(buf) - 1] != '\n') continue;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue