summaryrefslogtreecommitdiff
path: root/source/tools/acpisrc/asremove.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/tools/acpisrc/asremove.c')
-rw-r--r--source/tools/acpisrc/asremove.c92
1 files changed, 63 insertions, 29 deletions
diff --git a/source/tools/acpisrc/asremove.c b/source/tools/acpisrc/asremove.c
index 0ee4b3a10417..a728d9067711 100644
--- a/source/tools/acpisrc/asremove.c
+++ b/source/tools/acpisrc/asremove.c
@@ -550,6 +550,7 @@ AsReduceTypedefs (
{
char *SubString;
char *SubBuffer;
+ char *SubSubString;
int NestLevel;
@@ -562,56 +563,89 @@ AsReduceTypedefs (
if (SubString)
{
- /* Remove the typedef itself */
+ SubSubString = SubString + strlen (Keyword);
- SubBuffer = SubString + strlen ("typedef") + 1;
- SubBuffer = AsRemoveData (SubString, SubBuffer);
+ /* skip spaces */
- /* Find the opening brace of the struct or union */
+ while (strchr(" \t\r\n", *SubSubString))
+ {
+ SubSubString++;
+ }
- while (*SubString != '{')
+ /* skip type name */
+
+ while (!strchr(" \t\r\n", *SubSubString))
{
- SubString++;
+ SubSubString++;
}
- SubString++;
- /* Find the closing brace. Handles nested braces */
+ /* skip spaces */
- NestLevel = 1;
- while (*SubString)
+ while (strchr(" \t\r\n", *SubSubString))
+ {
+ SubSubString++;
+ }
+
+ if (*SubSubString == '{')
{
- if (*SubString == '{')
+ /* Remove the typedef itself */
+
+ SubBuffer = SubString + strlen ("typedef") + 1;
+ SubBuffer = AsRemoveData (SubString, SubBuffer);
+
+ /* Find the opening brace of the struct or union */
+
+ while (*SubString != '{')
{
- NestLevel++;
+ SubString++;
}
- else if (*SubString == '}')
+ SubString++;
+
+ /* Find the closing brace. Handles nested braces */
+
+ NestLevel = 1;
+ while (*SubString)
{
- NestLevel--;
+ if (*SubString == '{')
+ {
+ NestLevel++;
+ }
+ else if (*SubString == '}')
+ {
+ NestLevel--;
+ }
+
+ SubString++;
+
+ if (NestLevel == 0)
+ {
+ break;
+ }
}
- SubString++;
+ /* Remove an extra line feed if present */
- if (NestLevel == 0)
+ if (!strncmp (SubString - 3, "\n\n", 2))
{
- break;
+ *(SubString -2) = '}';
+ SubString--;
}
- }
-
- /* Remove an extra line feed if present */
- if (!strncmp (SubString - 3, "\n\n", 2))
- {
- *(SubString -2) = '}';
- SubString--;
- }
+ /* Find the end of the typedef name */
- /* Find the end of the typedef name */
+ SubBuffer = AsSkipUntilChar (SubString, ';');
- SubBuffer = AsSkipUntilChar (SubString, ';');
+ /* And remove the typedef name */
- /* And remove the typedef name */
+ SubBuffer = AsRemoveData (SubString, SubBuffer);
+ }
+ else
+ {
+ /* Skip the entire definition */
- SubBuffer = AsRemoveData (SubString, SubBuffer);
+ SubString = strchr (SubString, ';') + 1;
+ SubBuffer = SubString;
+ }
}
}
}