diff options
Diffstat (limited to 'compiler/aslerror.c')
| -rw-r--r-- | compiler/aslerror.c | 65 | 
1 files changed, 47 insertions, 18 deletions
diff --git a/compiler/aslerror.c b/compiler/aslerror.c index 59d3d20b6fb7..af20368c2aa0 100644 --- a/compiler/aslerror.c +++ b/compiler/aslerror.c @@ -241,6 +241,8 @@ AePrintException (      UINT32                  ErrorColumn;      FILE                    *OutputFile;      FILE                    *SourceFile; +    long                    FileSize; +    BOOLEAN                 PrematureEOF = FALSE;      if (Gbl_NoErrors) @@ -289,6 +291,19 @@ AePrintException (          SourceFile = Gbl_Files[ASL_FILE_INPUT].Handle;      } +    if (SourceFile) +    { +        /* Determine if the error occurred at source file EOF */ + +        fseek (SourceFile, 0, SEEK_END); +        FileSize = ftell (SourceFile); + +        if ((long) Enode->LogicalByteOffset >= FileSize) +        { +            PrematureEOF = TRUE; +        } +    } +      if (Header)      {          fprintf (OutputFile, "%s", Header); @@ -307,33 +322,42 @@ AePrintException (                  fprintf (OutputFile, " %6u: ", Enode->LineNumber);                  /* -                 * Seek to the offset in the combined source file, read the source -                 * line, and write it to the output. +                 * If not at EOF, get the corresponding source code line and +                 * display it. Don't attempt this if we have a premature EOF +                 * condition.                   */ -                Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, -                            (int) SEEK_SET); -                if (Actual) -                { -                    fprintf (OutputFile, -                        "[*** iASL: Seek error on source code temp file %s ***]", -                        Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); -                } -                else +                if (!PrematureEOF)                  { -                    RActual = fread (&SourceByte, 1, 1, SourceFile); -                    if (!RActual) +                    /* +                     * Seek to the offset in the combined source file, read +                     * the source line, and write it to the output. +                     */ +                    Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, +                                (int) SEEK_SET); +                    if (Actual)                      {                          fprintf (OutputFile, -                            "[*** iASL: Read error on source code temp file %s ***]", +                            "[*** iASL: Seek error on source code temp file %s ***]",                              Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename);                      } - -                    else while (RActual && SourceByte && (SourceByte != '\n')) +                    else                      { -                        fwrite (&SourceByte, 1, 1, OutputFile);                          RActual = fread (&SourceByte, 1, 1, SourceFile); +                        if (!RActual) +                        { +                            fprintf (OutputFile, +                                "[*** iASL: Read error on source code temp file %s ***]", +                                Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); +                        } + +                        else while (RActual && SourceByte && (SourceByte != '\n')) +                        { +                            fwrite (&SourceByte, 1, 1, OutputFile); +                            RActual = fread (&SourceByte, 1, 1, SourceFile); +                        }                      }                  } +                  fprintf (OutputFile, "\n");              }          } @@ -376,7 +400,7 @@ AePrintException (                  ExtraMessage = NULL;              } -            if (Gbl_VerboseErrors) +            if (Gbl_VerboseErrors && !PrematureEOF)              {                  SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2;                  ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; @@ -406,6 +430,11 @@ AePrintException (                  fprintf (OutputFile, " (%s)", ExtraMessage);              } +            if (PrematureEOF) +            { +                fprintf (OutputFile, " and premature End-Of-File"); +            } +              fprintf (OutputFile, "\n");              if (Gbl_VerboseErrors)              {  | 
