From c0ae8b10088038d9df636ee531591817a75c58af Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 20:43:26 +0000 Subject: [PATCH] Support for union/structs in header files date 2002.12.19.22.03.00; author rmoore1; state Exp; --- source/tools/acpisrc/acpisrc.h | 4 +-- source/tools/acpisrc/asconvrt.c | 48 ++++++++++++++++++++++++++++----- source/tools/acpisrc/asfile.c | 4 +-- source/tools/acpisrc/asmain.c | 10 +++---- 4 files changed, 50 insertions(+), 16 deletions(-) diff --git a/source/tools/acpisrc/acpisrc.h b/source/tools/acpisrc/acpisrc.h index b038d75ff..e3731a36d 100644 --- a/source/tools/acpisrc/acpisrc.h +++ b/source/tools/acpisrc/acpisrc.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: acpisrc.h - Include file for AcpiSrc utility - * $Revision: 1.19 $ + * $Revision: 1.20 $ * *****************************************************************************/ @@ -407,7 +407,7 @@ AsPrint ( char *Filename); void -AsInsertStruct ( +AsInsertPrefix ( char *Buffer, char *Keyword, UINT8 Type); diff --git a/source/tools/acpisrc/asconvrt.c b/source/tools/acpisrc/asconvrt.c index 7a645aa56..b6661e425 100644 --- a/source/tools/acpisrc/asconvrt.c +++ b/source/tools/acpisrc/asconvrt.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asconvrt - Source conversion code - * $Revision: 1.38 $ + * $Revision: 1.39 $ * *****************************************************************************/ @@ -645,8 +645,14 @@ AsBracesOnSameLine ( Length = strlen (SubBuffer); Gbl_MadeChanges = TRUE; + +#ifdef ADD_EXTRA_WHITESPACE + memmove (Beginning + 3, SubBuffer, Length+4); + memmove (Beginning, " {\n", 3); +#else memmove (Beginning + 2, SubBuffer, Length+3); memmove (Beginning, " {", 2); +#endif } } } @@ -814,7 +820,6 @@ AsTabify8 ( } else { - ThisTabCount = LastLineTabCount + 1; } } @@ -1144,15 +1149,14 @@ AsCountSourceLines ( /****************************************************************************** * - * FUNCTION: AsRemoveMacro + * FUNCTION: AsInsertPrefix * - * DESCRIPTION: Remove every line that contains the keyword. Does not - * skip comments. + * DESCRIPTION: Insert struct or union prefixes * ******************************************************************************/ void -AsInsertStruct ( +AsInsertPrefix ( char *Buffer, char *Keyword, UINT8 Type) @@ -1193,6 +1197,8 @@ AsInsertStruct ( while (SubString) { + /* Find an instance of the keyword */ + SubString = strstr (SubBuffer, LowerKeyword); if (!SubString) @@ -1200,10 +1206,37 @@ AsInsertStruct ( return; } + SubBuffer = SubString; + + /* Must be standalone word, not a substring */ + if (AsMatchExactWord (SubString, KeywordLength)) { + /* Make sure the keyword isn't already prefixed with the insert */ - SubBuffer = SubString; + if (!strncmp (SubString - InsertLength, InsertString, InsertLength)) + { + /* Already present, add spaces after to align structure members */ + + Gbl_MadeChanges = TRUE; + SubString = SubBuffer + KeywordLength; + StrLength = strlen (SubString); + + memmove (SubString + 8, SubString, StrLength + 1); + memmove (SubString, " ", 8); + + goto Next; + } + + /* Make sure the keyword isn't at the end of a struct/union */ + /* Note: This code depends on a single space after the brace */ + + if (*(SubString - 2) == '}') + { + goto Next; + } + + /* Prefix the keyword with the insert string */ Gbl_MadeChanges = TRUE; StrLength = strlen (SubString); @@ -1246,6 +1279,7 @@ AsInsertStruct ( } } +Next: SubBuffer += KeywordLength; } } diff --git a/source/tools/acpisrc/asfile.c b/source/tools/acpisrc/asfile.c index 4110a686f..f67f46cea 100644 --- a/source/tools/acpisrc/asfile.c +++ b/source/tools/acpisrc/asfile.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asfile - Main module for the acpi source processor utility - * $Revision: 1.21 $ + * $Revision: 1.22 $ * *****************************************************************************/ @@ -442,7 +442,7 @@ AsConvertFile ( { for (i = 0; StructTable[i].Identifier; i++) { - AsInsertStruct (FileBuffer, StructTable[i].Identifier, StructTable[i].Type); + AsInsertPrefix (FileBuffer, StructTable[i].Identifier, StructTable[i].Type); } } diff --git a/source/tools/acpisrc/asmain.c b/source/tools/acpisrc/asmain.c index 59ff959cd..fecf55cc2 100644 --- a/source/tools/acpisrc/asmain.c +++ b/source/tools/acpisrc/asmain.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asmain - Main module for the acpi source processor utility - * $Revision: 1.48 $ + * $Revision: 1.49 $ * *****************************************************************************/ @@ -251,7 +251,7 @@ ACPI_STRING_TABLE LinuxDataTypes[] = { NULL, NULL, 0}; -ACPI_TYPED_IDENTIFIER_TABLE LinuxLowerCase[] = { +ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { "ACPI_ADR_SPACE_HANDLER", SRC_TYPE_SIMPLE, "ACPI_ADR_SPACE_SETUP", SRC_TYPE_SIMPLE, @@ -487,7 +487,7 @@ ACPI_CONVERSION_TABLE LinuxConversionTable = { LinuxHeader, FLG_NO_CARRIAGE_RETURNS | FLG_LOWERCASE_DIRNAMES, - LinuxLowerCase, + AcpiIdentifiers, /* C source files */ @@ -495,7 +495,7 @@ ACPI_CONVERSION_TABLE LinuxConversionTable = { LinuxEliminateLines_C, NULL, LinuxEliminateMacros, - LinuxLowerCase, + AcpiIdentifiers, (CVT_COUNT_TABS | CVT_COUNT_NON_ANSI_COMMENTS | CVT_COUNT_LINES | CVT_CHECK_BRACES | CVT_TRIM_LINES | CVT_BRACES_ON_SAME_LINE | CVT_MIXED_CASE_TO_UNDERSCORES | CVT_LOWER_CASE_IDENTIFIERS | CVT_REMOVE_DEBUG_MACROS | CVT_TRIM_WHITESPACE | CVT_REMOVE_EMPTY_BLOCKS | CVT_SPACES_TO_TABS8), @@ -506,7 +506,7 @@ ACPI_CONVERSION_TABLE LinuxConversionTable = { LinuxEliminateLines_H, LinuxConditionalIdentifiers, NULL, - NULL, + AcpiIdentifiers, (CVT_COUNT_TABS | CVT_COUNT_NON_ANSI_COMMENTS | CVT_COUNT_LINES | CVT_TRIM_LINES | CVT_MIXED_CASE_TO_UNDERSCORES | CVT_LOWER_CASE_IDENTIFIERS | CVT_TRIM_WHITESPACE | CVT_REMOVE_EMPTY_BLOCKS| CVT_SPACES_TO_TABS8),