diff options
| author | Jung-uk Kim <jkim@FreeBSD.org> | 2015-05-18 23:17:05 +0000 |
|---|---|---|
| committer | Jung-uk Kim <jkim@FreeBSD.org> | 2015-05-18 23:17:05 +0000 |
| commit | 615eb2945402758f050f1cb469181d3d22a22aa3 (patch) | |
| tree | 0f95f8242a48aa24d8a795f626766746819b5227 /source/compiler/aslascii.c | |
| parent | 2a91972d59fb9df39eae760a853d6f5bc4065cf0 (diff) | |
Notes
Diffstat (limited to 'source/compiler/aslascii.c')
| -rw-r--r-- | source/compiler/aslascii.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/source/compiler/aslascii.c b/source/compiler/aslascii.c index dfb28f2f91e1..90abef24736d 100644 --- a/source/compiler/aslascii.c +++ b/source/compiler/aslascii.c @@ -148,8 +148,7 @@ FlCheckForAcpiTable ( * * FUNCTION: FlCheckForAscii * - * PARAMETERS: Handle - Open input file - * Filename - Input filename + * PARAMETERS: Filename - Full input filename * DisplayErrors - TRUE if error messages desired * * RETURN: Status @@ -165,7 +164,6 @@ FlCheckForAcpiTable ( ACPI_STATUS FlCheckForAscii ( - FILE *Handle, char *Filename, BOOLEAN DisplayErrors) { @@ -173,7 +171,12 @@ FlCheckForAscii ( ACPI_SIZE BadBytes = 0; BOOLEAN OpeningComment = FALSE; ASL_FILE_STATUS Status; + FILE *Handle; + + + /* Open file in text mode so file offset is always accurate */ + Handle = fopen (Filename, "rb"); Status.Line = 1; Status.Offset = 0; @@ -214,16 +217,30 @@ FlCheckForAscii ( if ((BadBytes < 10) && (DisplayErrors)) { AcpiOsPrintf ( - "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n", + "Found non-ASCII character in source text: " + "0x%2.2X in line %u, file offset 0x%2.2X\n", Byte, Status.Line, Status.Offset); } + BadBytes++; + } + /* Ensure character is either printable or a "space" char */ + + else if (!ACPI_IS_PRINT (Byte) && !ACPI_IS_SPACE (Byte)) + { + if ((BadBytes < 10) && (DisplayErrors)) + { + AcpiOsPrintf ( + "Found invalid character in source text: " + "0x%2.2X in line %u, file offset 0x%2.2X\n", + Byte, Status.Line, Status.Offset); + } BadBytes++; } - /* Update line counter */ + /* Update line counter as necessary */ - else if (Byte == 0x0A) + if (Byte == 0x0A) { Status.Line++; } @@ -231,9 +248,7 @@ FlCheckForAscii ( Status.Offset++; } - /* Seek back to the beginning of the source file */ - - fseek (Handle, 0, SEEK_SET); + fclose (Handle); /* Were there any non-ASCII characters in the file? */ @@ -242,8 +257,8 @@ FlCheckForAscii ( if (DisplayErrors) { AcpiOsPrintf ( - "%u non-ASCII characters found in input source text, could be a binary file\n", - BadBytes); + "Total %u invalid characters found in input source text, " + "could be a binary file\n", BadBytes); AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename); } @@ -286,6 +301,7 @@ FlConsumeAnsiComment ( { if (Byte == '/') { + Status->Offset++; return; } |
