1 /******************************************************************************
3 * Module Name: asconvrt - Source conversion code
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2014, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
46 AS_BRACE_INFO Gbl_BraceInfo[] =
57 /* Local prototypes */
64 AS_SCAN_CALLBACK Callback);
67 AsCheckBracesCallback (
78 /* Opening signature of the Intel legal header */
80 char *HeaderBegin = "/******************************************************************************\n *\n * 1. Copyright Notice";
82 UINT32 NonAnsiCommentCount;
85 /******************************************************************************
87 * FUNCTION: AsCountNonAnsiComments
89 * DESCRIPTION: Count the number of "//" comments. This type of comment is
92 * NOTE: July 2014: Allows // within quoted strings and within normal
93 * comments. Eliminates extraneous warnings from this utility.
95 ******************************************************************************/
98 AsCountNonAnsiComments (
103 AsMatchValidToken (Buffer, Filename, 0, NULL);
105 /* Error if any slash-slash comments found */
107 if (NonAnsiCommentCount)
109 AsPrint ("Non-ANSI // Comments Found", NonAnsiCommentCount, Filename);
110 Gbl_NonAnsiComments += NonAnsiCommentCount;
115 /******************************************************************************
117 * FUNCTION: AsCheckForBraces
119 * DESCRIPTION: Check for an open brace after each if/else/do (etc.)
122 ******************************************************************************/
130 AsMatchValidToken (Buffer, Filename, 0, AsCheckBracesCallback);
134 /******************************************************************************
136 * FUNCTION: AsCheckBracesCallback
138 * DESCRIPTION: Check if/else/do statements. Ensure that braces
141 * TBD: Currently, don't check while() statements. The problem is that there
142 * are two forms: do {} while (); and while () {}.
144 ******************************************************************************/
147 AsCheckBracesCallback (
152 char *SubBuffer = Buffer;
155 AS_BRACE_INFO *BraceInfo;
158 for (BraceInfo = Gbl_BraceInfo; BraceInfo->Operator; BraceInfo++)
160 if (!(strncmp (BraceInfo->Operator, SubBuffer, BraceInfo->Length)))
162 SubBuffer += (BraceInfo->Length - 1);
164 /* Find next brace and the next semicolon */
166 NextBrace = AsMatchValidToken (SubBuffer, Filename, '{', NULL);
167 NextSemicolon = AsMatchValidToken (SubBuffer, Filename, ';', NULL);
169 /* Next brace should appear before next semicolon */
172 (NextSemicolon && (NextBrace > NextSemicolon)))
178 printf ("Missing braces for <%s>, line %u: %s\n",
179 BraceInfo->Operator + 1, LineNumber, Filename);
187 /* No match, just return original buffer */
193 /******************************************************************************
195 * FUNCTION: AsMatchValidToken
197 * DESCRIPTION: Find the next matching token in the input buffer.
199 ******************************************************************************/
206 AS_SCAN_CALLBACK Callback)
208 char *SubBuffer = Buffer;
214 NonAnsiCommentCount = 0;
216 /* Scan from current position up to the end if necessary */
220 /* Skip normal comments */
222 if ((*SubBuffer == '/') &&
223 (*(SubBuffer + 1) == '*'))
225 /* Must maintain line count */
228 while (strncmp ("*/", SubBuffer, 2))
230 if (*SubBuffer == '\n')
241 /* Skip single quoted chars */
243 if (*SubBuffer == '\'')
251 if (*SubBuffer == '\\')
259 /* Skip quoted strings */
261 if (*SubBuffer == '"')
263 StringStart = SubBuffer;
270 while (*SubBuffer != '"')
272 if ((*SubBuffer == '\n') ||
275 AsPrint ("Unbalanced quoted string", 1, Filename);
276 printf (" %.32s\n", StringStart);
280 /* Handle escapes within the string */
282 if (*SubBuffer == '\\')
293 /* Now we can check for a slash-slash comment */
295 if ((*SubBuffer == '/') &&
296 (*(SubBuffer + 1) == '/'))
298 NonAnsiCommentCount++;
300 /* Skip to end-of-line */
302 while ((*SubBuffer != '\n') &&
313 if (*SubBuffer == '\n')
322 /* Finally, check for a newline */
324 if (*SubBuffer == '\n')
331 /* Normal character, do the user actions */
335 SubBuffer = Callback (SubBuffer, Filename, TotalLines);
338 if (TargetChar && (*SubBuffer == TargetChar))
350 /******************************************************************************
352 * FUNCTION: AsRemoveExtraLines
354 * DESCRIPTION: Remove all extra lines at the start and end of the file.
356 ******************************************************************************/
367 /* Remove any extra lines at the start of the file */
369 while (*FileBuffer == '\n')
371 printf ("Removing extra line at start of file: %s\n", Filename);
372 AsRemoveData (FileBuffer, FileBuffer + 1);
375 /* Remove any extra lines at the end of the file */
377 Length = strlen (FileBuffer);
378 FileEnd = FileBuffer + (Length - 2);
380 while (*FileEnd == '\n')
382 printf ("Removing extra line at end of file: %s\n", Filename);
383 AsRemoveData (FileEnd, FileEnd + 1);
389 /******************************************************************************
391 * FUNCTION: AsRemoveSpacesAfterPeriod
393 * DESCRIPTION: Remove an extra space after a period.
395 ******************************************************************************/
398 AsRemoveSpacesAfterPeriod (
402 int ReplaceCount = 0;
406 Possible = FileBuffer;
409 Possible = strstr (Possible, ". ");
412 if ((*(Possible -1) == '.') ||
413 (*(Possible -1) == '\"') ||
414 (*(Possible -1) == '\n'))
420 Possible = AsReplaceData (Possible, 3, ". ", 2);
427 printf ("Removed %d extra blanks after a period: %s\n",
428 ReplaceCount, Filename);
433 /******************************************************************************
435 * FUNCTION: AsMatchExactWord
437 * DESCRIPTION: Check previous and next characters for whitespace
439 ******************************************************************************/
450 NextChar = Word[WordLength];
451 PrevChar = * (Word -1);
453 if (isalnum ((int) NextChar) ||
455 isalnum ((int) PrevChar) ||
465 /******************************************************************************
469 * DESCRIPTION: Common formatted print
471 ******************************************************************************/
485 printf ("-- %4u %28.28s : %s\n", Count, Message, Filename);
489 /******************************************************************************
491 * FUNCTION: AsTrimLines
493 * DESCRIPTION: Remove extra blanks from the end of source lines. Does not
496 ******************************************************************************/
503 char *SubBuffer = Buffer;
504 char *StartWhiteSpace = NULL;
505 UINT32 SpaceCount = 0;
510 while (*SubBuffer != '\n')
517 if (*SubBuffer == ' ')
519 if (!StartWhiteSpace)
521 StartWhiteSpace = SubBuffer;
526 StartWhiteSpace = NULL;
534 SpaceCount += (SubBuffer - StartWhiteSpace);
536 /* Remove the spaces */
538 SubBuffer = AsRemoveData (StartWhiteSpace, SubBuffer);
539 StartWhiteSpace = NULL;
549 Gbl_MadeChanges = TRUE;
550 AsPrint ("Extraneous spaces removed", SpaceCount, Filename);
555 /******************************************************************************
557 * FUNCTION: AsTrimWhitespace
559 * DESCRIPTION: Remove "excess" blank lines - any more than 2 blank lines.
560 * this can happen during the translation when lines are removed.
562 ******************************************************************************/
569 int ReplaceCount = 1;
574 ReplaceCount = AsReplaceString ("\n\n\n\n", "\n\n\n",
575 REPLACE_SUBSTRINGS, Buffer);
579 * Check for exactly one blank line after the copyright header
582 /* Find the header */
584 SubBuffer = strstr (Buffer, HeaderBegin);
590 /* Find the end of the header */
592 SubBuffer = strstr (SubBuffer, "*/");
593 SubBuffer = AsSkipPastChar (SubBuffer, '\n');
595 /* Replace a double blank line with a single */
597 if (!strncmp (SubBuffer, "\n\n", 2))
599 SubBuffer = AsReplaceData (SubBuffer, 2, "\n", 1);
600 AcpiOsPrintf ("Found multiple blank lines after copyright\n");
603 /* If no blank line after header, insert one */
605 else if (*SubBuffer != '\n')
607 AsInsertData (SubBuffer, "\n", 1);
608 AcpiOsPrintf ("Inserted blank line after copyright\n");
613 /******************************************************************************
615 * FUNCTION: AsReplaceHeader
617 * DESCRIPTION: Replace the default Intel legal header with a new header
619 ******************************************************************************/
630 /* Find the original header */
632 SubBuffer = strstr (Buffer, HeaderBegin);
638 /* Find the end of the original header */
640 TokenEnd = strstr (SubBuffer, "*/");
641 TokenEnd = AsSkipPastChar (TokenEnd, '\n');
643 /* Delete old header, insert new one */
645 AsReplaceData (SubBuffer, TokenEnd - SubBuffer,
646 NewHeader, strlen (NewHeader));
650 /******************************************************************************
652 * FUNCTION: AsReplaceString
654 * DESCRIPTION: Replace all instances of a target string with a replacement
655 * string. Returns count of the strings replaced.
657 ******************************************************************************/
670 int ReplacementLength;
671 int ReplaceCount = 0;
674 TargetLength = strlen (Target);
675 ReplacementLength = strlen (Replacement);
682 /* Find the target string */
684 SubString1 = strstr (SubBuffer, Target);
687 return (ReplaceCount);
691 * Check for translation escape string -- means to ignore
692 * blocks of code while replacing
694 if (Gbl_IgnoreTranslationEscapes)
700 SubString2 = strstr (SubBuffer, AS_START_IGNORE);
704 (SubString2 < SubString1))
706 /* Find end of the escape block starting at "Substring2" */
708 SubString2 = strstr (SubString2, AS_STOP_IGNORE);
711 /* Didn't find terminator */
713 return (ReplaceCount);
716 /* Move buffer to end of escape block and continue */
718 SubBuffer = SubString2;
721 /* Do the actual replace if the target was found */
725 if ((Type & REPLACE_MASK) == REPLACE_WHOLE_WORD)
727 if (!AsMatchExactWord (SubString1, TargetLength))
729 SubBuffer = SubString1 + 1;
734 SubBuffer = AsReplaceData (SubString1, TargetLength,
735 Replacement, ReplacementLength);
737 if ((Type & EXTRA_INDENT_C) &&
740 SubBuffer = AsInsertData (SubBuffer, " ", 8);
747 return (ReplaceCount);
751 /******************************************************************************
753 * FUNCTION: AsConvertToLineFeeds
755 * DESCRIPTION: Convert all CR/LF pairs to LF only.
757 ******************************************************************************/
760 AsConvertToLineFeeds (
772 /* Find the target string */
774 SubString = strstr (SubBuffer, "\r\n");
780 SubBuffer = AsReplaceData (SubString, 1, NULL, 0);
785 /******************************************************************************
787 * FUNCTION: AsInsertCarriageReturns
789 * DESCRIPTION: Convert lone LFs to CR/LF pairs.
791 ******************************************************************************/
794 AsInsertCarriageReturns (
806 /* Find the target string */
808 SubString = strstr (SubBuffer, "\n");
814 SubBuffer = AsInsertData (SubString, "\r", 1);
820 /******************************************************************************
822 * FUNCTION: AsBracesOnSameLine
824 * DESCRIPTION: Move opening braces up to the same line as an if, for, else,
825 * or while statement (leave function opening brace on separate
828 ******************************************************************************/
834 char *SubBuffer = Buffer;
836 char *StartOfThisLine;
838 BOOLEAN BlockBegin = TRUE;
843 /* Ignore comments */
845 if ((SubBuffer[0] == '/') &&
846 (SubBuffer[1] == '*'))
848 SubBuffer = strstr (SubBuffer, "*/");
858 /* Ignore quoted strings */
860 if (*SubBuffer == '\"')
863 SubBuffer = AsSkipPastChar (SubBuffer, '\"');
870 if (!strncmp ("\n}", SubBuffer, 2))
873 * A newline followed by a closing brace closes a function
874 * or struct or initializer block
880 * Move every standalone brace up to the previous line
881 * Check for digit will ignore initializer lists surrounded by braces.
882 * This will work until we we need more complex detection.
884 if ((*SubBuffer == '{') && !isdigit ((int) SubBuffer[1]))
893 * Backup to previous non-whitespace
895 Beginning = SubBuffer - 1;
896 while ((*Beginning == ' ') ||
897 (*Beginning == '\n'))
902 StartOfThisLine = Beginning;
903 while (*StartOfThisLine != '\n')
909 * Move the brace up to the previous line, UNLESS:
911 * 1) There is a conditional compile on the line (starts with '#')
912 * 2) Previous line ends with an '=' (Start of initializer block)
913 * 3) Previous line ends with a comma (part of an init list)
914 * 4) Previous line ends with a backslash (part of a macro)
916 if ((StartOfThisLine[1] != '#') &&
917 (*Beginning != '\\') &&
918 (*Beginning != '/') &&
919 (*Beginning != '{') &&
920 (*Beginning != '=') &&
926 Gbl_MadeChanges = TRUE;
928 #ifdef ADD_EXTRA_WHITESPACE
929 AsReplaceData (Beginning, SubBuffer - Beginning, " {\n", 3);
931 /* Find non-whitespace start of next line */
933 Next = SubBuffer + 1;
934 while ((*Next == ' ') ||
940 /* Find non-whitespace start of this line */
943 while ((*StartOfThisLine == ' ') ||
944 (*StartOfThisLine == '\t'))
950 * Must be a single-line comment to need more whitespace
951 * Even then, we don't need more if the previous statement
954 if ((Next[0] == '/') &&
958 (!strncmp (StartOfThisLine, "else if", 7) ||
959 !strncmp (StartOfThisLine, "else while", 10) ||
960 strncmp (StartOfThisLine, "else", 4)))
962 AsReplaceData (Beginning, SubBuffer - Beginning, " {\n", 3);
966 AsReplaceData (Beginning, SubBuffer - Beginning, " {", 2);
978 /******************************************************************************
980 * FUNCTION: AsTabify4
982 * DESCRIPTION: Convert the text to tabbed text. Alignment of text is
985 ******************************************************************************/
991 char *SubBuffer = Buffer;
993 UINT32 SpaceCount = 0;
999 if (*SubBuffer == '\n')
1008 /* Ignore comments */
1010 if ((SubBuffer[0] == '/') &&
1011 (SubBuffer[1] == '*'))
1013 SubBuffer = strstr (SubBuffer, "*/");
1023 /* Ignore quoted strings */
1025 if (*SubBuffer == '\"')
1028 SubBuffer = AsSkipPastChar (SubBuffer, '\"');
1036 if (*SubBuffer == ' ')
1040 if (SpaceCount >= 4)
1044 NewSubBuffer = (SubBuffer + 1) - 4;
1045 *NewSubBuffer = '\t';
1048 /* Remove the spaces */
1050 SubBuffer = AsRemoveData (NewSubBuffer, SubBuffer + 1);
1053 if ((Column % 4) == 0)
1068 /******************************************************************************
1070 * FUNCTION: AsTabify8
1072 * DESCRIPTION: Convert the text to tabbed text. Alignment of text is
1075 ******************************************************************************/
1081 char *SubBuffer = Buffer;
1083 char *CommentEnd = NULL;
1084 UINT32 SpaceCount = 0;
1086 UINT32 TabCount = 0;
1087 UINT32 LastLineTabCount = 0;
1088 UINT32 LastLineColumnStart = 0;
1089 UINT32 ThisColumnStart = 0;
1090 UINT32 ThisTabCount = 0;
1091 char *FirstNonBlank = NULL;
1096 if (*SubBuffer == '\n')
1098 /* This is a standalone blank line */
1100 FirstNonBlank = NULL;
1110 /* Find the first non-blank character on this line */
1112 FirstNonBlank = SubBuffer;
1113 while (*FirstNonBlank == ' ')
1119 * This mechanism limits the difference in tab counts from
1120 * line to line. It helps avoid the situation where a second
1121 * continuation line (which was indented correctly for tabs=4) would
1122 * get indented off the screen if we just blindly converted to tabs.
1124 ThisColumnStart = FirstNonBlank - SubBuffer;
1126 if (LastLineTabCount == 0)
1130 else if (ThisColumnStart == LastLineColumnStart)
1132 ThisTabCount = LastLineTabCount -1;
1136 ThisTabCount = LastLineTabCount + 1;
1142 /* Check if we are in a comment */
1144 if ((SubBuffer[0] == '*') &&
1145 (SubBuffer[1] == '/'))
1150 if (*SubBuffer == '\n')
1154 LastLineTabCount = TabCount;
1157 FirstNonBlank = NULL;
1158 LastLineColumnStart = ThisColumnStart;
1165 /* Check for comment open */
1167 if ((SubBuffer[0] == '/') &&
1168 (SubBuffer[1] == '*'))
1170 /* Find the end of the comment, it must exist */
1172 CommentEnd = strstr (SubBuffer, "*/");
1178 /* Toss the rest of this line or single-line comment */
1180 while ((SubBuffer < CommentEnd) &&
1181 (*SubBuffer != '\n'))
1186 if (*SubBuffer == '\n')
1190 LastLineTabCount = TabCount;
1193 FirstNonBlank = NULL;
1194 LastLineColumnStart = ThisColumnStart;
1201 /* Ignore quoted strings */
1203 if ((!CommentEnd) && (*SubBuffer == '\"'))
1206 SubBuffer = AsSkipPastChar (SubBuffer, '\"');
1214 if (*SubBuffer != ' ')
1216 /* Not a space, skip to end of line */
1218 SubBuffer = AsSkipUntilChar (SubBuffer, '\n');
1225 LastLineTabCount = TabCount;
1229 FirstNonBlank = NULL;
1230 LastLineColumnStart = ThisColumnStart;
1240 if (SpaceCount >= 4)
1242 /* Replace this group of spaces with a tab character */
1246 NewSubBuffer = SubBuffer - 3;
1248 if (TabCount <= ThisTabCount ? (ThisTabCount +1) : 0)
1250 *NewSubBuffer = '\t';
1256 /* Remove the spaces */
1258 SubBuffer = AsRemoveData (NewSubBuffer, SubBuffer);
1268 /******************************************************************************
1270 * FUNCTION: AsCountLines
1272 * DESCRIPTION: Count the number of lines in the input buffer. Also count
1273 * the number of long lines (lines longer than 80 chars).
1275 ******************************************************************************/
1282 char *SubBuffer = Buffer;
1284 UINT32 LineCount = 0;
1285 UINT32 LongLineCount = 0;
1290 EndOfLine = AsSkipUntilChar (SubBuffer, '\n');
1293 Gbl_TotalLines += LineCount;
1297 if ((EndOfLine - SubBuffer) > 80)
1300 VERBOSE_PRINT (("long: %.80s\n", SubBuffer));
1304 SubBuffer = EndOfLine + 1;
1309 VERBOSE_PRINT (("%u Lines longer than 80 found in %s\n",
1310 LongLineCount, Filename));
1312 Gbl_LongLines += LongLineCount;
1315 Gbl_TotalLines += LineCount;
1320 /******************************************************************************
1322 * FUNCTION: AsCountTabs
1324 * DESCRIPTION: Simply count the number of tabs in the input file buffer
1326 ******************************************************************************/
1334 UINT32 TabCount = 0;
1337 for (i = 0; Buffer[i]; i++)
1339 if (Buffer[i] == '\t')
1347 AsPrint ("Tabs found", TabCount, Filename);
1348 Gbl_Tabs += TabCount;
1351 AsCountLines (Buffer, Filename);
1355 /******************************************************************************
1357 * FUNCTION: AsCountSourceLines
1359 * DESCRIPTION: Count the number of C source lines. Defined by 1) not a
1360 * comment, and 2) not a blank line.
1362 ******************************************************************************/
1365 AsCountSourceLines (
1369 char *SubBuffer = Buffer;
1370 UINT32 LineCount = 0;
1371 UINT32 WhiteCount = 0;
1372 UINT32 CommentCount = 0;
1377 /* Detect comments (// comments are not used, non-ansii) */
1379 if ((SubBuffer[0] == '/') &&
1380 (SubBuffer[1] == '*'))
1384 /* First line of multi-line comment is often just whitespace */
1386 if (SubBuffer[0] == '\n')
1396 /* Find end of comment */
1398 while (SubBuffer[0] && SubBuffer[1] &&
1399 !(((SubBuffer[0] == '*') &&
1400 (SubBuffer[1] == '/'))))
1402 if (SubBuffer[0] == '\n')
1411 /* A linefeed followed by a non-linefeed is a valid source line */
1413 else if ((SubBuffer[0] == '\n') &&
1414 (SubBuffer[1] != '\n'))
1419 /* Two back-to-back linefeeds indicate a whitespace line */
1421 else if ((SubBuffer[0] == '\n') &&
1422 (SubBuffer[1] == '\n'))
1430 /* Adjust comment count for legal header */
1432 if (Gbl_HeaderSize < CommentCount)
1434 CommentCount -= Gbl_HeaderSize;
1435 Gbl_HeaderLines += Gbl_HeaderSize;
1438 Gbl_SourceLines += LineCount;
1439 Gbl_WhiteLines += WhiteCount;
1440 Gbl_CommentLines += CommentCount;
1442 VERBOSE_PRINT (("%u Comment %u White %u Code %u Lines in %s\n",
1443 CommentCount, WhiteCount, LineCount,
1444 LineCount + WhiteCount + CommentCount, Filename));
1448 /******************************************************************************
1450 * FUNCTION: AsInsertPrefix
1452 * DESCRIPTION: Insert struct or union prefixes
1454 ******************************************************************************/
1468 char LowerKeyword[128];
1474 case SRC_TYPE_STRUCT:
1476 InsertString = "struct ";
1479 case SRC_TYPE_UNION:
1481 InsertString = "union ";
1489 strcpy (LowerKeyword, Keyword);
1490 AsStrlwr (LowerKeyword);
1494 InsertLength = strlen (InsertString);
1495 KeywordLength = strlen (Keyword);
1500 /* Find an instance of the keyword */
1502 SubString = strstr (SubBuffer, LowerKeyword);
1508 SubBuffer = SubString;
1510 /* Must be standalone word, not a substring */
1512 if (AsMatchExactWord (SubString, KeywordLength))
1514 /* Make sure the keyword isn't already prefixed with the insert */
1516 if (!strncmp (SubString - InsertLength, InsertString, InsertLength))
1518 /* Add spaces if not already at the end-of-line */
1520 if (*(SubBuffer + KeywordLength) != '\n')
1522 /* Already present, add spaces after to align structure members */
1525 /* ONLY FOR C FILES */
1526 AsInsertData (SubBuffer + KeywordLength, " ", 8);
1532 /* Make sure the keyword isn't at the end of a struct/union */
1533 /* Note: This code depends on a single space after the brace */
1535 if (*(SubString - 2) == '}')
1540 /* Prefix the keyword with the insert string */
1542 Gbl_MadeChanges = TRUE;
1544 /* Is there room for insertion */
1546 EndKeyword = SubString + strlen (LowerKeyword);
1549 while (EndKeyword[TrailingSpaces] == ' ')
1555 * Use "if (TrailingSpaces > 1)" if we want to ignore casts
1557 SubBuffer = SubString + InsertLength;
1559 if (TrailingSpaces > InsertLength)
1561 /* Insert the keyword */
1563 memmove (SubBuffer, SubString, KeywordLength);
1565 /* Insert the keyword */
1567 memmove (SubString, InsertString, InsertLength);
1571 AsInsertData (SubString, InsertString, InsertLength);
1576 SubBuffer += KeywordLength;
1580 #ifdef ACPI_FUTURE_IMPLEMENTATION
1581 /******************************************************************************
1583 * FUNCTION: AsTrimComments
1585 * DESCRIPTION: Finds 3-line comments with only a single line of text
1587 ******************************************************************************/
1594 char *SubBuffer = Buffer;
1598 UINT32 ShortCommentCount = 0;
1603 /* Find comment open, within procedure level */
1605 SubBuffer = strstr (SubBuffer, " /*");
1611 /* Find comment terminator */
1613 Ptr1 = strstr (SubBuffer, "*/");
1619 /* Find next EOL (from original buffer) */
1621 Ptr2 = strstr (SubBuffer, "\n");
1627 /* Ignore one-line comments */
1631 /* Normal comment, ignore and continue; */
1637 /* Examine multi-line comment */
1645 Ptr2 = strstr (Ptr2, "\n");
1658 ShortCommentCount++;
1665 if (ShortCommentCount)
1667 AsPrint ("Short Comments found", ShortCommentCount, Filename);
1672 #ifdef ACPI_UNUSED_FUNCTIONS
1673 /******************************************************************************
1675 * FUNCTION: AsCheckAndSkipLiterals
1677 * DESCRIPTION: Generic routine to skip comments and quoted string literals.
1678 * Keeps a line count.
1680 ******************************************************************************/
1683 AsCheckAndSkipLiterals (
1685 UINT32 *TotalLines);
1689 AsCheckAndSkipLiterals (
1693 UINT32 NewLines = 0;
1694 char *SubBuffer = Buffer;
1698 /* Ignore comments */
1700 if ((SubBuffer[0] == '/') &&
1701 (SubBuffer[1] == '*'))
1703 LiteralEnd = strstr (SubBuffer, "*/");
1704 SubBuffer += 2; /* Get past comment opening */
1711 while (SubBuffer < LiteralEnd)
1713 if (*SubBuffer == '\n')
1721 SubBuffer += 2; /* Get past comment close */
1724 /* Ignore quoted strings */
1726 else if (*SubBuffer == '\"')
1729 LiteralEnd = AsSkipPastChar (SubBuffer, '\"');
1738 (*TotalLines) += NewLines;