Restructed fgetc usage.

This commit is contained in:
Robert Osfield
2016-06-10 14:02:55 +01:00
parent fc1b963107
commit bdf3600011

View File

@@ -957,11 +957,12 @@ int dwfgets(char *clin, int max, FILE *fin)
// Macintosh produced files (such as those obtainable
//from the great buildings site at www.Artifice.com) use 13 format, PC models use 10.
int nread=0;
char c1=1;
int c1=1;
do {
if (!feof( fin )) {
clin[nread]=c1=fgetc(fin);
nread++;
if (!feof( fin ))
{
c1=fgetc(fin);
clin[nread++]=static_cast<char>(c1);
}
} while (nread<max && c1!= 13 && c1!= 10 && feof( fin )== 0 );
if (nread>0) clin[nread-1]='\0'; // null terminate and remove training blank