+ if (CurTok.Tok != TOK_STRCON) {
+ ErrorSkip ("String constant expected");
+ return;
+ }
+ SB_Copy (&Name, &CurTok.SVal);
+ SB_Terminate (&Name);
+ NextTok ();
+
+ /* A starting offset may follow */
+ if (CurTok.Tok == TOK_COMMA) {
+ NextTok ();
+ Start = ConstExpression ();
+
+ /* And a length may follow */
+ if (CurTok.Tok == TOK_COMMA) {
+ NextTok ();
+ Count = ConstExpression ();
+ }
+
+ }
+
+ /* Try to open the file */
+ F = fopen (SB_GetConstBuf (&Name), "rb");
+ if (F == 0) {
+
+ /* Search for the file in the binary include directory */
+ char* PathName = SearchFile (BinSearchPath, SB_GetConstBuf (&Name));
+ if (PathName == 0 || (F = fopen (PathName, "rb")) == 0) {
+ /* Not found or cannot open, print an error and bail out */
+ ErrorSkip ("Cannot open include file `%m%p': %s", &Name, strerror (errno));
+ xfree (PathName);
+ goto ExitPoint;
+ }
+
+ /* Remember the new file name */
+ SB_CopyStr (&Name, PathName);
+
+ /* Free the allocated memory */
+ xfree (PathName);
+ }
+
+ /* Get the size of the file */
+ fseek (F, 0, SEEK_END);
+ Size = ftell (F);
+
+ /* Stat the file and remember the values. There a race condition here,
+ * since we cannot use fileno() (non standard identifier in standard
+ * header file), and therefore not fstat. When using stat with the
+ * file name, there's a risk that the file was deleted and recreated
+ * while it was open. Since mtime and size are only used to check
+ * if a file has changed in the debugger, we will ignore this problem
+ * here.
+ */
+ SB_Terminate (&Name);
+ if (stat (SB_GetConstBuf (&Name), &StatBuf) != 0) {
+ Fatal ("Cannot stat input file `%m%p': %s", &Name, strerror (errno));
+ }
+
+ /* Add the file to the input file table */
+ AddFile (&Name, FT_BINARY, Size, StatBuf.st_mtime);
+
+ /* If a count was not given, calculate it now */
+ if (Count < 0) {
+ Count = Size - Start;
+ if (Count < 0) {
+ /* Nothing to read - flag this as a range error */
+ ErrorSkip ("Range error");
+ goto Done;
+ }