📄 asremove.c
字号:
SubString = EndifPtr; } /* Remove the ... #endif part */ /* Find end of this line */ SubBuffer = AsSkipPastChar (EndifPtr, '\n'); if (!SubBuffer) { return; } /* Remove the lines */ SubBuffer = AsRemoveData (SubString, SubBuffer); }}/****************************************************************************** * * FUNCTION: AsRemoveMacro * * DESCRIPTION: Remove every line that contains the keyword. Does not * skip comments. * ******************************************************************************/voidAsRemoveMacro ( char *Buffer, char *Keyword){ char *SubString; char *SubBuffer; int NestLevel; SubBuffer = Buffer; SubString = Buffer; while (SubString) { SubString = strstr (SubBuffer, Keyword); if (SubString) { SubBuffer = SubString; /* Find start of the macro parameters */ while (*SubString != '(') { SubString++; } SubString++; /* Remove the macro name and opening paren */ SubString = AsRemoveData (SubBuffer, SubString); NestLevel = 1; while (*SubString) { if (*SubString == '(') { NestLevel++; } else if (*SubString == ')') { NestLevel--; } SubString++; if (NestLevel == 0) { break; } } /* Remove the closing paren */ SubBuffer = AsRemoveData (SubString-1, SubString); } }}/****************************************************************************** * * FUNCTION: AsRemoveLine * * DESCRIPTION: Remove every line that contains the keyword. Does not * skip comments. * ******************************************************************************/voidAsRemoveLine ( char *Buffer, char *Keyword){ char *SubString; char *SubBuffer; SubBuffer = Buffer; SubString = Buffer; while (SubString) { SubString = strstr (SubBuffer, Keyword); if (SubString) { SubBuffer = SubString; /* Find start of this line */ while (*SubString != '\n') { SubString--; } SubString++; /* Find end of this line */ SubBuffer = AsSkipPastChar (SubBuffer, '\n'); if (!SubBuffer) { return; } /* Remove the line */ SubBuffer = AsRemoveData (SubString, SubBuffer); } }}/****************************************************************************** * * FUNCTION: AsReduceTypedefs * * DESCRIPTION: Eliminate certain typedefs * ******************************************************************************/voidAsReduceTypedefs ( char *Buffer, char *Keyword){ char *SubString; char *SubBuffer; int NestLevel; SubBuffer = Buffer; SubString = Buffer; while (SubString) { SubString = strstr (SubBuffer, Keyword); 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 != '{') { SubString++; } SubString++; /* Find the closing brace. Handles nested braces */ NestLevel = 1; while (*SubString) { if (*SubString == '{') { NestLevel++; } else if (*SubString == '}') { NestLevel--; } SubString++; if (NestLevel == 0) { break; } } /* Remove an extra line feed if present */ if (!strncmp (SubString - 3, "\n\n", 2)) { *(SubString -2) = '}'; SubString--; } /* Find the end of the typedef name */ SubBuffer = AsSkipUntilChar (SubString, ';'); /* And remove the typedef name */ SubBuffer = AsRemoveData (SubString, SubBuffer); } }}/****************************************************************************** * * FUNCTION: AsRemoveEmptyBlocks * * DESCRIPTION: Remove any C blocks (e.g., if {}) that contain no code. This * can happen as a result of removing lines such as DEBUG_PRINT. * ******************************************************************************/voidAsRemoveEmptyBlocks ( char *Buffer, char *Filename){ char *SubBuffer; char *BlockStart; BOOLEAN EmptyBlock = TRUE; BOOLEAN AnotherPassRequired = TRUE; UINT32 BlockCount = 0; while (AnotherPassRequired) { SubBuffer = Buffer; AnotherPassRequired = FALSE; while (*SubBuffer) { if (*SubBuffer == '{') { BlockStart = SubBuffer; EmptyBlock = TRUE; SubBuffer++; while (*SubBuffer != '}') { if ((*SubBuffer != ' ') && (*SubBuffer != '\n')) { EmptyBlock = FALSE; break; } SubBuffer++; } if (EmptyBlock) { /* Find start of the first line of the block */ while (*BlockStart != '\n') { BlockStart--; } /* Find end of the last line of the block */ SubBuffer = AsSkipUntilChar (SubBuffer, '\n'); if (!SubBuffer) { break; } /* Remove the block */ SubBuffer = AsRemoveData (BlockStart, SubBuffer); BlockCount++; AnotherPassRequired = TRUE; continue; } } SubBuffer++; } } if (BlockCount) { Gbl_MadeChanges = TRUE; AsPrint ("Code blocks deleted", BlockCount, Filename); }}/****************************************************************************** * * FUNCTION: AsRemoveDebugMacros * * DESCRIPTION: Remove all "Debug" macros -- macros that produce debug output. * ******************************************************************************/voidAsRemoveDebugMacros ( char *Buffer){ AsRemoveConditionalCompile (Buffer, "ACPI_DEBUG_OUTPUT"); AsRemoveStatement (Buffer, "ACPI_DEBUG_PRINT", REPLACE_WHOLE_WORD); AsRemoveStatement (Buffer, "ACPI_DEBUG_PRINT_RAW", REPLACE_WHOLE_WORD); AsRemoveStatement (Buffer, "DEBUG_EXEC", REPLACE_WHOLE_WORD); AsRemoveStatement (Buffer, "FUNCTION_ENTRY", REPLACE_WHOLE_WORD); AsRemoveStatement (Buffer, "PROC_NAME", REPLACE_WHOLE_WORD); AsRemoveStatement (Buffer, "FUNCTION_TRACE", REPLACE_SUBSTRINGS); AsRemoveStatement (Buffer, "DUMP_", REPLACE_SUBSTRINGS); AsReplaceString ("return_VOID", "return", REPLACE_WHOLE_WORD, Buffer); AsReplaceString ("return_PTR", "return", REPLACE_WHOLE_WORD, Buffer); AsReplaceString ("return_ACPI_STATUS", "return", REPLACE_WHOLE_WORD, Buffer); AsReplaceString ("return_acpi_status", "return", REPLACE_WHOLE_WORD, Buffer); AsReplaceString ("return_VALUE", "return", REPLACE_WHOLE_WORD, Buffer);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -