1
Fork 0

Fixed fread test.

This commit is contained in:
Davi de Castro Reis 2011-12-26 19:12:24 -02:00
parent beb77d0e2d
commit 4e4d36d833
1 changed files with 11 additions and 7 deletions

View File

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