summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRobert Moore <Robert.Moore@intel.com>2013-12-17 13:32:14 -0800
committerRobert Moore <Robert.Moore@intel.com>2013-12-17 13:32:14 -0800
commit3911d320464c487fd92494a23e197171ed873216 (patch)
tree80e0e64ec95a6b4acc7dfe188a19a5c0f2154cb8 /source
parent40bbabbc185bda425dd18308a229ed5bffa80908 (diff)
AcpiSrc: Cleanup spaces after special macro invocations.
There are still spaces in the linuxized ACPICA files after special macro invocations. This patch refines the cleanup code for "acpisrc -i" mode. Note that indent treats comments and pre-processor directives as spaces, thus we need to skip them. Before applying this patch, cleanup code will search from keyword back to end of line and wipe spaces between them. After applying this patch, cleanup code will search to the end of the macro invocations, then skip "empty lines", "comments" and "pre-processor directives", then wipe the spaces between the new line and the first non-spaces characters. Lv Zheng.
Diffstat (limited to 'source')
-rw-r--r--source/tools/acpisrc/asremove.c84
1 files changed, 65 insertions, 19 deletions
diff --git a/source/tools/acpisrc/asremove.c b/source/tools/acpisrc/asremove.c
index 8f435893b..167084a79 100644
--- a/source/tools/acpisrc/asremove.c
+++ b/source/tools/acpisrc/asremove.c
@@ -710,7 +710,9 @@ AsCleanupSpecialMacro (
{
char *SubString;
char *SubBuffer;
- char *LastNonSpace;
+ char *CommentEnd;
+ int NewLine;
+ int NestLevel;
SubBuffer = Buffer;
@@ -722,40 +724,84 @@ AsCleanupSpecialMacro (
if (SubString)
{
- /* Find start of the line */
+ /* Find start of the macro parameters */
- SubBuffer = SubString;
- while (*(SubBuffer - 1) == ' ')
+ while (*SubString != '(')
{
- SubBuffer--;
+ SubString++;
}
+ SubString++;
- if (*(SubBuffer - 1) == '\n')
+ NestLevel = 1;
+ while (*SubString)
{
- /* Find last non-space character */
+ if (*SubString == '(')
+ {
+ NestLevel++;
+ }
+ else if (*SubString == ')')
+ {
+ NestLevel--;
+ }
+
+ SubString++;
- LastNonSpace = SubBuffer - 1;
- while (isspace ((int) *LastNonSpace))
+ if (NestLevel == 0)
{
- LastNonSpace--;
+ break;
}
+ }
+
+SkipLine:
+
+ /* Find end of the line */
- if (*LastNonSpace != '\\')
+ NewLine = FALSE;
+ while (!NewLine && *SubString)
+ {
+ if (*SubString == '\n' && *(SubString - 1) != '\\')
{
- /* Remove the extra spaces */
+ NewLine = TRUE;
+ }
+ SubString++;
+ }
+
+ /* Find end of the line */
+
+ if (*SubString == '#' || *SubString == '\n')
+ {
+ goto SkipLine;
+ }
- SubString = AsRemoveData (SubBuffer, SubString);
+ SubBuffer = SubString;
- /* Enforce an empty line between the invocations */
+ /* Find start of the non-space */
- if (*(SubBuffer - 2) == ')')
- {
- AsInsertData (SubBuffer, "\n", 1);
- }
+ while (*SubString == ' ')
+ {
+ SubString++;
+ }
+
+ /* Find end of the line */
+
+ if (*SubString == '#' || *SubString == '\n')
+ {
+ goto SkipLine;
+ }
+
+ /* Find end of the line */
+
+ if (*SubString == '/' || *SubString == '*')
+ {
+ CommentEnd = strstr (SubString, "*/");
+ if (CommentEnd)
+ {
+ SubString = CommentEnd + 2;
+ goto SkipLine;
}
}
- SubBuffer = SubString + strlen (Keyword);
+ SubString = AsRemoveData (SubBuffer, SubString);
}
}
}