When checking for binary file, check if ch is not EOF only ch actually got

a value assigned

Reported by:	pfg
This commit is contained in:
bapt 2016-04-30 14:48:30 +00:00
parent 24be79982e
commit 47bc90320f

View File

@ -514,12 +514,14 @@ istextfile(FILE *f)
if (f == NULL)
return (1);
rewind(f);
for (i = 0; i <= MAX_CHECK || ch != EOF; i++) {
for (i = 0; i <= MAX_CHECK; i++) {
ch = fgetc(f);
if (ch == '\0') {
rewind(f);
return (0);
}
if (ch == EOF)
break;
}
rewind(f);
return (1);