void IFDone (CharSource* S) /* Close the current input file */ { /* We're at the end of an include file. Check if we have any ** open .IFs, or any open token lists in this file. This ** enforcement is artificial, using conditionals that start ** in one file and end in another are uncommon, and don't ** allowing these things will help finding errors. */ CheckOpenIfs (); /* If we've added search paths for this file, remove them */ if (S->V.File.IncSearchPath) { PopSearchPath (IncSearchPath); } if (S->V.File.BinSearchPath) { PopSearchPath (BinSearchPath); } /* Free the line buffer */ SB_Done (&S->V.File.Line); /* Close the input file and decrement the file count. We will ignore ** errors here, since we were just reading from the file. */ (void) fclose (S->V.File.F); --FCount; }
static void CloseIncludeFile (void) /* Close an include file and switch to the higher level file. Set Input to * NULL if this was the main file. */ { AFile* Input; /* Get the number of active input files */ unsigned AFileCount = CollCount (&AFiles); /* Must have an input file when called */ PRECONDITION (AFileCount > 0); /* Get the current active input file */ Input = (AFile*) CollLast (&AFiles); /* Close the current input file (we're just reading so no error check) */ fclose (Input->F); /* Delete the last active file from the active file collection */ CollDelete (&AFiles, AFileCount-1); /* If we had added an extra search path for this AFile, remove it */ if (Input->SearchPath) { PopSearchPath (UsrIncSearchPath); } /* Delete the active file structure */ FreeAFile (Input); }