diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2017-08-31 22:47:04 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2017-08-31 22:47:04 +0000 |
commit | 2f6a1a81bb01192c179cf8400174c4173faa6511 (patch) | |
tree | 86fa336b67d02fb8ad6168ec00e88e0be80088f7 /sys/contrib/dev/acpica/compiler/asldebug.c | |
parent | 84f8cfec2f79281e95e9eff136758a9e4e87a42f (diff) | |
parent | 0810e26699e1b40b9384eca2137be6155de0a5ba (diff) |
Notes
Diffstat (limited to 'sys/contrib/dev/acpica/compiler/asldebug.c')
-rw-r--r-- | sys/contrib/dev/acpica/compiler/asldebug.c | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/sys/contrib/dev/acpica/compiler/asldebug.c b/sys/contrib/dev/acpica/compiler/asldebug.c index 3824a4534c0f..780d584fca2b 100644 --- a/sys/contrib/dev/acpica/compiler/asldebug.c +++ b/sys/contrib/dev/acpica/compiler/asldebug.c @@ -165,6 +165,10 @@ UtDumpParseOpName ( UINT32 Level, UINT32 DataLength); +static char * +UtCreateEscapeSequences ( + char *InString); + /******************************************************************************* * @@ -272,7 +276,6 @@ UtDumpStringOp ( String = Op->Asl.Value.String; - if (Op->Asl.ParseOpcode != PARSEOP_STRING_LITERAL) { /* @@ -294,6 +297,8 @@ UtDumpStringOp ( return; } + String = UtCreateEscapeSequences (String); + /* Emit the ParseOp name, leaving room for the string */ UtDumpParseOpName (Op, Level, strlen (String)); @@ -303,6 +308,86 @@ UtDumpStringOp ( /******************************************************************************* * + * FUNCTION: UtCreateEscapeSequences + * + * PARAMETERS: InString - ASCII string to be expanded + * + * RETURN: Expanded string + * + * DESCRIPTION: Expand all non-printable ASCII bytes (0-0x1F) to escape + * sequences. For example, hex 14 becomes \x14 + * + * NOTE: Since this function is used for debug output only, it does + * not attempt to translate into the "known" escape sequences + * such as \a, \f, \t, etc. + * + ******************************************************************************/ + +static char * +UtCreateEscapeSequences ( + char *InString) +{ + char *String = InString; + char *OutString; + char *OutStringPtr; + UINT32 InStringLength = 0; + UINT32 EscapeCount = 0; + + + /* + * Determine up front how many escapes are within the string. + * Obtain the input string length while doing so. + */ + while (*String) + { + if ((*String <= 0x1F) || (*String >= 0x7F)) + { + EscapeCount++; + } + + InStringLength++; + String++; + } + + if (!EscapeCount) + { + return (InString); /* No escapes, nothing to do */ + } + + /* New string buffer, 3 extra chars per escape (4 total) */ + + OutString = UtLocalCalloc (InStringLength + (EscapeCount * 3)); + OutStringPtr = OutString; + + /* Convert non-ascii or non-printable chars to escape sequences */ + + while (*InString) + { + if ((*InString <= 0x1F) || (*InString >= 0x7F)) + { + /* Insert a \x hex escape sequence */ + + OutStringPtr[0] = '\\'; + OutStringPtr[1] = 'x'; + OutStringPtr[2] = AcpiUtHexToAsciiChar (*InString, 4); + OutStringPtr[3] = AcpiUtHexToAsciiChar (*InString, 0); + OutStringPtr += 4; + } + else /* Normal ASCII character */ + { + *OutStringPtr = *InString; + OutStringPtr++; + } + + InString++; + } + + return (OutString); +} + + +/******************************************************************************* + * * FUNCTION: UtDumpBasicOp * * PARAMETERS: Op - Current parse op |