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:
Baptiste Daroussin 2016-04-30 14:48:30 +00:00
parent eacd600ea9
commit da5c2c4230
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298851

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);