Compute value earlier and reuse it

This commit is contained in:
Dmitry-Me 2017-09-28 23:41:29 +03:00
parent 7308901add
commit 9fdfada4b5
1 changed files with 7 additions and 11 deletions

View File

@ -202,20 +202,16 @@ void CheckIO::checkFileUsage()
operation = Filepointer::OPEN; operation = Filepointer::OPEN;
} else if ((tok->str() == "rewind" || tok->str() == "fseek" || tok->str() == "fsetpos" || tok->str() == "fflush") || } else if ((tok->str() == "rewind" || tok->str() == "fseek" || tok->str() == "fsetpos" || tok->str() == "fflush") ||
(windows && tok->str() == "_fseeki64")) { (windows && tok->str() == "_fseeki64")) {
if (printPortability && tok->str() == "fflush") { fileTok = tok->tokAt(2);
fileTok = tok->tokAt(2); if (printPortability && fileTok && tok->str() == "fflush") {
if (fileTok) { if (fileTok->str() == "stdin")
if (fileTok->str() == "stdin") fflushOnInputStreamError(tok, fileTok->str());
else {
Filepointer& f = filepointers[fileTok->varId()];
if (f.mode == READ_MODE)
fflushOnInputStreamError(tok, fileTok->str()); fflushOnInputStreamError(tok, fileTok->str());
else {
Filepointer& f = filepointers[fileTok->varId()];
if (f.mode == READ_MODE)
fflushOnInputStreamError(tok, fileTok->str());
}
} }
} }
fileTok = tok->tokAt(2);
operation = Filepointer::POSITIONING; operation = Filepointer::POSITIONING;
} else if (tok->str() == "fgetc" || tok->str() == "fgetwc" || } else if (tok->str() == "fgetc" || tok->str() == "fgetwc" ||
tok->str() == "fgets" || tok->str() == "fgetws" || tok->str() == "fread" || tok->str() == "fgets" || tok->str() == "fgetws" || tok->str() == "fread" ||