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 /* Local prototypes */
49 AsCheckAndSkipLiterals (
58 /* Opening signature of the Intel legal header */
60 char *HeaderBegin = "/******************************************************************************\n *\n * 1. Copyright Notice";
63 /******************************************************************************
65 * FUNCTION: AsRemoveExtraLines
67 * DESCRIPTION: Remove all extra lines at the start and end of the file.
69 ******************************************************************************/
80 /* Remove any extra lines at the start of the file */
82 while (*FileBuffer == '\n')
84 printf ("Removing extra line at start of file: %s\n", Filename);
85 AsRemoveData (FileBuffer, FileBuffer + 1);
88 /* Remove any extra lines at the end of the file */
90 Length = strlen (FileBuffer);
91 FileEnd = FileBuffer + (Length - 2);
93 while (*FileEnd == '\n')
95 printf ("Removing extra line at end of file: %s\n", Filename);
96 AsRemoveData (FileEnd, FileEnd + 1);
102 /******************************************************************************
104 * FUNCTION: AsRemoveSpacesAfterPeriod
106 * DESCRIPTION: Remove an extra space after a period.
108 ******************************************************************************/
111 AsRemoveSpacesAfterPeriod (
115 int ReplaceCount = 0;
119 Possible = FileBuffer;
122 Possible = strstr (Possible, ". ");
125 if ((*(Possible -1) == '.') ||
126 (*(Possible -1) == '\"') ||
127 (*(Possible -1) == '\n'))
133 Possible = AsReplaceData (Possible, 3, ". ", 2);
140 printf ("Removed %d extra blanks after a period: %s\n",
141 ReplaceCount, Filename);
146 /******************************************************************************
148 * FUNCTION: AsMatchExactWord
150 * DESCRIPTION: Check previous and next characters for whitespace
152 ******************************************************************************/
163 NextChar = Word[WordLength];
164 PrevChar = * (Word -1);
166 if (isalnum ((int) NextChar) ||
168 isalnum ((int) PrevChar) ||
178 /******************************************************************************
182 * DESCRIPTION: Common formatted print
184 ******************************************************************************/
198 printf ("-- %4u %28.28s : %s\n", Count, Message, Filename);
202 /******************************************************************************
204 * FUNCTION: AsCheckAndSkipLiterals
206 * DESCRIPTION: Generic routine to skip comments and quoted string literals.
207 * Keeps a line count.
209 ******************************************************************************/
212 AsCheckAndSkipLiterals (
217 char *SubBuffer = Buffer;
221 /* Ignore comments */
223 if ((SubBuffer[0] == '/') &&
224 (SubBuffer[1] == '*'))
226 LiteralEnd = strstr (SubBuffer, "*/");
227 SubBuffer += 2; /* Get past comment opening */
234 while (SubBuffer < LiteralEnd)
236 if (*SubBuffer == '\n')
244 SubBuffer += 2; /* Get past comment close */
247 /* Ignore quoted strings */
249 else if (*SubBuffer == '\"')
252 LiteralEnd = AsSkipPastChar (SubBuffer, '\"');
261 (*TotalLines) += NewLines;
267 /******************************************************************************
269 * FUNCTION: AsAsCheckForBraces
271 * DESCRIPTION: Check for an open brace after each if/else statement
273 ******************************************************************************/
280 char *SubBuffer = Buffer;
283 UINT32 TotalLines = 1;
287 EndBuffer = SubBuffer + strlen (SubBuffer);
289 while (SubBuffer <= EndBuffer)
291 /* TBD: Update this function to work properly, as per code below */
292 /* SubBuffer = AsCheckAndSkipLiterals (SubBuffer, &TotalLines); */
294 /* Skip normal comments */
296 if ((*SubBuffer == '/') &&
297 (*(SubBuffer + 1) == '*'))
299 /* Must maintain line count */
302 while (strncmp ("*/", SubBuffer, 2))
304 if (*SubBuffer == '\n')
314 /* Skip single quoted chars */
316 if (*SubBuffer == '\'')
319 if (*SubBuffer == '\\')
327 /* Skip quoted strings */
329 if (*SubBuffer == '"')
332 while (*SubBuffer != '"')
334 /* Handle escapes within the string */
336 if (*SubBuffer == '\\')
347 if (*SubBuffer == '\n')
351 else if (!(strncmp (" if", SubBuffer, 3)))
355 NextBrace = strstr (SubBuffer, "{");
356 NextSemicolon = strstr (SubBuffer, ";");
359 (NextSemicolon && (NextBrace > NextSemicolon)))
365 printf ("Missing braces for <if>, line %u: %s\n", TotalLines, Filename);
369 else if (!(strncmp (" else if", SubBuffer, 8)))
373 NextBrace = strstr (SubBuffer, "{");
374 NextSemicolon = strstr (SubBuffer, ";");
377 (NextSemicolon && (NextBrace > NextSemicolon)))
383 printf ("Missing braces for <else if>, line %u: %s\n", TotalLines, Filename);
387 else if (!(strncmp (" else", SubBuffer, 5)))
390 NextBrace = strstr (SubBuffer, "{");
391 NextSemicolon = strstr (SubBuffer, ";");
394 (NextSemicolon && (NextBrace > NextSemicolon)))
400 printf ("Missing braces for <else>, line %u: %s\n", TotalLines, Filename);
410 /******************************************************************************
412 * FUNCTION: AsTrimLines
414 * DESCRIPTION: Remove extra blanks from the end of source lines. Does not
417 ******************************************************************************/
424 char *SubBuffer = Buffer;
425 char *StartWhiteSpace = NULL;
426 UINT32 SpaceCount = 0;
431 while (*SubBuffer != '\n')
438 if (*SubBuffer == ' ')
440 if (!StartWhiteSpace)
442 StartWhiteSpace = SubBuffer;
447 StartWhiteSpace = NULL;
455 SpaceCount += (SubBuffer - StartWhiteSpace);
457 /* Remove the spaces */
459 SubBuffer = AsRemoveData (StartWhiteSpace, SubBuffer);
460 StartWhiteSpace = NULL;
470 Gbl_MadeChanges = TRUE;
471 AsPrint ("Extraneous spaces removed", SpaceCount, Filename);
476 /******************************************************************************
478 * FUNCTION: AsTrimWhitespace
480 * DESCRIPTION: Remove "excess" blank lines - any more than 2 blank lines.
481 * this can happen during the translation when lines are removed.
483 ******************************************************************************/
489 int ReplaceCount = 1;
494 ReplaceCount = AsReplaceString ("\n\n\n\n", "\n\n\n", REPLACE_SUBSTRINGS, Buffer);
499 /******************************************************************************
501 * FUNCTION: AsReplaceHeader
503 * DESCRIPTION: Replace the default Intel legal header with a new header
505 ******************************************************************************/
516 /* Find the original header */
518 SubBuffer = strstr (Buffer, HeaderBegin);
524 /* Find the end of the original header */
526 TokenEnd = strstr (SubBuffer, "*/");
527 TokenEnd = AsSkipPastChar (TokenEnd, '\n');
529 /* Delete old header, insert new one */
531 AsReplaceData (SubBuffer, TokenEnd - SubBuffer, NewHeader, strlen (NewHeader));
535 /******************************************************************************
537 * FUNCTION: AsReplaceString
539 * DESCRIPTION: Replace all instances of a target string with a replacement
540 * string. Returns count of the strings replaced.
542 ******************************************************************************/
555 int ReplacementLength;
556 int ReplaceCount = 0;
559 TargetLength = strlen (Target);
560 ReplacementLength = strlen (Replacement);
567 /* Find the target string */
569 SubString1 = strstr (SubBuffer, Target);
572 return (ReplaceCount);
576 * Check for translation escape string -- means to ignore
577 * blocks of code while replacing
579 if (Gbl_IgnoreTranslationEscapes)
585 SubString2 = strstr (SubBuffer, AS_START_IGNORE);
589 (SubString2 < SubString1))
591 /* Find end of the escape block starting at "Substring2" */
593 SubString2 = strstr (SubString2, AS_STOP_IGNORE);
596 /* Didn't find terminator */
598 return (ReplaceCount);
601 /* Move buffer to end of escape block and continue */
603 SubBuffer = SubString2;
606 /* Do the actual replace if the target was found */
610 if ((Type & REPLACE_MASK) == REPLACE_WHOLE_WORD)
612 if (!AsMatchExactWord (SubString1, TargetLength))
614 SubBuffer = SubString1 + 1;
619 SubBuffer = AsReplaceData (SubString1, TargetLength, Replacement, ReplacementLength);
621 if ((Type & EXTRA_INDENT_C) &&
624 SubBuffer = AsInsertData (SubBuffer, " ", 8);
631 return (ReplaceCount);
635 /******************************************************************************
637 * FUNCTION: AsConvertToLineFeeds
641 ******************************************************************************/
644 AsConvertToLineFeeds (
656 /* Find the target string */
658 SubString = strstr (SubBuffer, "\r\n");
664 SubBuffer = AsReplaceData (SubString, 1, NULL, 0);
670 /******************************************************************************
672 * FUNCTION: AsInsertCarriageReturns
676 ******************************************************************************/
679 AsInsertCarriageReturns (
691 /* Find the target string */
693 SubString = strstr (SubBuffer, "\n");
699 SubBuffer = AsInsertData (SubString, "\r", 1);
706 /******************************************************************************
708 * FUNCTION: AsBracesOnSameLine
710 * DESCRIPTION: Move opening braces up to the same line as an if, for, else,
711 * or while statement (leave function opening brace on separate
714 ******************************************************************************/
720 char *SubBuffer = Buffer;
722 char *StartOfThisLine;
724 BOOLEAN BlockBegin = TRUE;
729 /* Ignore comments */
731 if ((SubBuffer[0] == '/') &&
732 (SubBuffer[1] == '*'))
734 SubBuffer = strstr (SubBuffer, "*/");
744 /* Ignore quoted strings */
746 if (*SubBuffer == '\"')
749 SubBuffer = AsSkipPastChar (SubBuffer, '\"');
756 if (!strncmp ("\n}", SubBuffer, 2))
759 * A newline followed by a closing brace closes a function
760 * or struct or initializer block
766 * Move every standalone brace up to the previous line
767 * Check for digit will ignore initializer lists surrounded by braces.
768 * This will work until we we need more complex detection.
770 if ((*SubBuffer == '{') && !isdigit ((int) SubBuffer[1]))
779 * Backup to previous non-whitespace
781 Beginning = SubBuffer - 1;
782 while ((*Beginning == ' ') ||
783 (*Beginning == '\n'))
788 StartOfThisLine = Beginning;
789 while (*StartOfThisLine != '\n')
795 * Move the brace up to the previous line, UNLESS:
797 * 1) There is a conditional compile on the line (starts with '#')
798 * 2) Previous line ends with an '=' (Start of initializer block)
799 * 3) Previous line ends with a comma (part of an init list)
800 * 4) Previous line ends with a backslash (part of a macro)
802 if ((StartOfThisLine[1] != '#') &&
803 (*Beginning != '\\') &&
804 (*Beginning != '/') &&
805 (*Beginning != '{') &&
806 (*Beginning != '=') &&
812 Gbl_MadeChanges = TRUE;
814 #ifdef ADD_EXTRA_WHITESPACE
815 AsReplaceData (Beginning, SubBuffer - Beginning, " {\n", 3);
817 /* Find non-whitespace start of next line */
819 Next = SubBuffer + 1;
820 while ((*Next == ' ') ||
826 /* Find non-whitespace start of this line */
829 while ((*StartOfThisLine == ' ') ||
830 (*StartOfThisLine == '\t'))
836 * Must be a single-line comment to need more whitespace
837 * Even then, we don't need more if the previous statement
840 if ((Next[0] == '/') &&
844 (!strncmp (StartOfThisLine, "else if", 7) ||
845 !strncmp (StartOfThisLine, "else while", 10) ||
846 strncmp (StartOfThisLine, "else", 4)))
848 AsReplaceData (Beginning, SubBuffer - Beginning, " {\n", 3);
852 AsReplaceData (Beginning, SubBuffer - Beginning, " {", 2);
864 /******************************************************************************
866 * FUNCTION: AsTabify4
868 * DESCRIPTION: Convert the text to tabbed text. Alignment of text is
871 ******************************************************************************/
877 char *SubBuffer = Buffer;
879 UINT32 SpaceCount = 0;
885 if (*SubBuffer == '\n')
894 /* Ignore comments */
896 if ((SubBuffer[0] == '/') &&
897 (SubBuffer[1] == '*'))
899 SubBuffer = strstr (SubBuffer, "*/");
909 /* Ignore quoted strings */
911 if (*SubBuffer == '\"')
914 SubBuffer = AsSkipPastChar (SubBuffer, '\"');
922 if (*SubBuffer == ' ')
930 NewSubBuffer = (SubBuffer + 1) - 4;
931 *NewSubBuffer = '\t';
934 /* Remove the spaces */
936 SubBuffer = AsRemoveData (NewSubBuffer, SubBuffer + 1);
939 if ((Column % 4) == 0)
954 /******************************************************************************
956 * FUNCTION: AsTabify8
958 * DESCRIPTION: Convert the text to tabbed text. Alignment of text is
961 ******************************************************************************/
967 char *SubBuffer = Buffer;
969 char *CommentEnd = NULL;
970 UINT32 SpaceCount = 0;
973 UINT32 LastLineTabCount = 0;
974 UINT32 LastLineColumnStart = 0;
975 UINT32 ThisColumnStart = 0;
976 UINT32 ThisTabCount = 0;
977 char *FirstNonBlank = NULL;
982 if (*SubBuffer == '\n')
984 /* This is a standalone blank line */
986 FirstNonBlank = NULL;
996 /* Find the first non-blank character on this line */
998 FirstNonBlank = SubBuffer;
999 while (*FirstNonBlank == ' ')
1005 * This mechanism limits the difference in tab counts from
1006 * line to line. It helps avoid the situation where a second
1007 * continuation line (which was indented correctly for tabs=4) would
1008 * get indented off the screen if we just blindly converted to tabs.
1010 ThisColumnStart = FirstNonBlank - SubBuffer;
1012 if (LastLineTabCount == 0)
1016 else if (ThisColumnStart == LastLineColumnStart)
1018 ThisTabCount = LastLineTabCount -1;
1022 ThisTabCount = LastLineTabCount + 1;
1028 /* Check if we are in a comment */
1030 if ((SubBuffer[0] == '*') &&
1031 (SubBuffer[1] == '/'))
1036 if (*SubBuffer == '\n')
1040 LastLineTabCount = TabCount;
1043 FirstNonBlank = NULL;
1044 LastLineColumnStart = ThisColumnStart;
1051 /* Check for comment open */
1053 if ((SubBuffer[0] == '/') &&
1054 (SubBuffer[1] == '*'))
1056 /* Find the end of the comment, it must exist */
1058 CommentEnd = strstr (SubBuffer, "*/");
1064 /* Toss the rest of this line or single-line comment */
1066 while ((SubBuffer < CommentEnd) &&
1067 (*SubBuffer != '\n'))
1072 if (*SubBuffer == '\n')
1076 LastLineTabCount = TabCount;
1079 FirstNonBlank = NULL;
1080 LastLineColumnStart = ThisColumnStart;
1087 /* Ignore quoted strings */
1089 if ((!CommentEnd) && (*SubBuffer == '\"'))
1092 SubBuffer = AsSkipPastChar (SubBuffer, '\"');
1100 if (*SubBuffer != ' ')
1102 /* Not a space, skip to end of line */
1104 SubBuffer = AsSkipUntilChar (SubBuffer, '\n');
1111 LastLineTabCount = TabCount;
1115 FirstNonBlank = NULL;
1116 LastLineColumnStart = ThisColumnStart;
1126 if (SpaceCount >= 4)
1128 /* Replace this group of spaces with a tab character */
1132 NewSubBuffer = SubBuffer - 3;
1134 if (TabCount <= ThisTabCount ? (ThisTabCount +1) : 0)
1136 *NewSubBuffer = '\t';
1142 /* Remove the spaces */
1144 SubBuffer = AsRemoveData (NewSubBuffer, SubBuffer);
1154 /******************************************************************************
1156 * FUNCTION: AsCountLines
1158 * DESCRIPTION: Count the number of lines in the input buffer. Also count
1159 * the number of long lines (lines longer than 80 chars).
1161 ******************************************************************************/
1168 char *SubBuffer = Buffer;
1170 UINT32 LineCount = 0;
1171 UINT32 LongLineCount = 0;
1176 EndOfLine = AsSkipUntilChar (SubBuffer, '\n');
1179 Gbl_TotalLines += LineCount;
1183 if ((EndOfLine - SubBuffer) > 80)
1186 VERBOSE_PRINT (("long: %.80s\n", SubBuffer));
1190 SubBuffer = EndOfLine + 1;
1195 VERBOSE_PRINT (("%u Lines longer than 80 found in %s\n", LongLineCount, Filename));
1196 Gbl_LongLines += LongLineCount;
1199 Gbl_TotalLines += LineCount;
1204 /******************************************************************************
1206 * FUNCTION: AsCountTabs
1208 * DESCRIPTION: Simply count the number of tabs in the input file buffer
1210 ******************************************************************************/
1218 UINT32 TabCount = 0;
1221 for (i = 0; Buffer[i]; i++)
1223 if (Buffer[i] == '\t')
1231 AsPrint ("Tabs found", TabCount, Filename);
1232 Gbl_Tabs += TabCount;
1235 AsCountLines (Buffer, Filename);
1239 /******************************************************************************
1241 * FUNCTION: AsCountNonAnsiComments
1243 * DESCRIPTION: Count the number of "//" comments. This type of comment is
1246 * NOTE: July 2014: Allows // within quoted strings and within normal
1247 * comments. Eliminates extraneous warnings from this utility.
1249 ******************************************************************************/
1252 AsCountNonAnsiComments (
1256 char *SubBuffer = Buffer;
1258 UINT32 CommentCount = 0;
1262 EndBuffer = SubBuffer + strlen (SubBuffer);
1264 while (SubBuffer <= EndBuffer)
1266 /* Skip normal comments */
1268 if ((*SubBuffer == '/') &&
1269 (*(SubBuffer + 1) == '*'))
1271 SubBuffer = strstr (SubBuffer + 2, "*/");
1281 /* Skip single quoted chars */
1283 if (*SubBuffer == '\'')
1286 if (*SubBuffer == '\\')
1294 /* Skip quoted strings */
1296 if (*SubBuffer == '"')
1298 StartBuffer = SubBuffer;
1299 AcpiOsPrintf ("START STRING: %.64s\n", StartBuffer);
1301 while (*SubBuffer != '"')
1303 /* Handle escapes within the string */
1305 if (*SubBuffer == '\\')
1316 /* Finally: check for slash-slash comment */
1318 if ((*SubBuffer == '/') &&
1319 (*(SubBuffer + 1) == '/'))
1328 /* Error if any slash-slash comments found */
1332 AsPrint ("Non-ANSI // Comments Found", CommentCount, Filename);
1333 Gbl_NonAnsiComments += CommentCount;
1338 /******************************************************************************
1340 * FUNCTION: AsCountSourceLines
1342 * DESCRIPTION: Count the number of C source lines. Defined by 1) not a
1343 * comment, and 2) not a blank line.
1345 ******************************************************************************/
1348 AsCountSourceLines (
1352 char *SubBuffer = Buffer;
1353 UINT32 LineCount = 0;
1354 UINT32 WhiteCount = 0;
1355 UINT32 CommentCount = 0;
1360 /* Detect comments (// comments are not used, non-ansii) */
1362 if ((SubBuffer[0] == '/') &&
1363 (SubBuffer[1] == '*'))
1367 /* First line of multi-line comment is often just whitespace */
1369 if (SubBuffer[0] == '\n')
1379 /* Find end of comment */
1381 while (SubBuffer[0] && SubBuffer[1] &&
1382 !(((SubBuffer[0] == '*') &&
1383 (SubBuffer[1] == '/'))))
1385 if (SubBuffer[0] == '\n')
1394 /* A linefeed followed by a non-linefeed is a valid source line */
1396 else if ((SubBuffer[0] == '\n') &&
1397 (SubBuffer[1] != '\n'))
1402 /* Two back-to-back linefeeds indicate a whitespace line */
1404 else if ((SubBuffer[0] == '\n') &&
1405 (SubBuffer[1] == '\n'))
1413 /* Adjust comment count for legal header */
1415 if (Gbl_HeaderSize < CommentCount)
1417 CommentCount -= Gbl_HeaderSize;
1418 Gbl_HeaderLines += Gbl_HeaderSize;
1421 Gbl_SourceLines += LineCount;
1422 Gbl_WhiteLines += WhiteCount;
1423 Gbl_CommentLines += CommentCount;
1425 VERBOSE_PRINT (("%u Comment %u White %u Code %u Lines in %s\n",
1426 CommentCount, WhiteCount, LineCount, LineCount+WhiteCount+CommentCount, Filename));
1430 /******************************************************************************
1432 * FUNCTION: AsInsertPrefix
1434 * DESCRIPTION: Insert struct or union prefixes
1436 ******************************************************************************/
1450 char LowerKeyword[128];
1456 case SRC_TYPE_STRUCT:
1458 InsertString = "struct ";
1461 case SRC_TYPE_UNION:
1463 InsertString = "union ";
1471 strcpy (LowerKeyword, Keyword);
1472 AsStrlwr (LowerKeyword);
1476 InsertLength = strlen (InsertString);
1477 KeywordLength = strlen (Keyword);
1482 /* Find an instance of the keyword */
1484 SubString = strstr (SubBuffer, LowerKeyword);
1490 SubBuffer = SubString;
1492 /* Must be standalone word, not a substring */
1494 if (AsMatchExactWord (SubString, KeywordLength))
1496 /* Make sure the keyword isn't already prefixed with the insert */
1498 if (!strncmp (SubString - InsertLength, InsertString, InsertLength))
1500 /* Add spaces if not already at the end-of-line */
1502 if (*(SubBuffer + KeywordLength) != '\n')
1504 /* Already present, add spaces after to align structure members */
1507 /* ONLY FOR C FILES */
1508 AsInsertData (SubBuffer + KeywordLength, " ", 8);
1514 /* Make sure the keyword isn't at the end of a struct/union */
1515 /* Note: This code depends on a single space after the brace */
1517 if (*(SubString - 2) == '}')
1522 /* Prefix the keyword with the insert string */
1524 Gbl_MadeChanges = TRUE;
1526 /* Is there room for insertion */
1528 EndKeyword = SubString + strlen (LowerKeyword);
1531 while (EndKeyword[TrailingSpaces] == ' ')
1537 * Use "if (TrailingSpaces > 1)" if we want to ignore casts
1539 SubBuffer = SubString + InsertLength;
1541 if (TrailingSpaces > InsertLength)
1543 /* Insert the keyword */
1545 memmove (SubBuffer, SubString, KeywordLength);
1547 /* Insert the keyword */
1549 memmove (SubString, InsertString, InsertLength);
1553 AsInsertData (SubString, InsertString, InsertLength);
1558 SubBuffer += KeywordLength;
1562 #ifdef ACPI_FUTURE_IMPLEMENTATION
1563 /******************************************************************************
1565 * FUNCTION: AsTrimComments
1567 * DESCRIPTION: Finds 3-line comments with only a single line of text
1569 ******************************************************************************/
1576 char *SubBuffer = Buffer;
1580 UINT32 ShortCommentCount = 0;
1585 /* Find comment open, within procedure level */
1587 SubBuffer = strstr (SubBuffer, " /*");
1593 /* Find comment terminator */
1595 Ptr1 = strstr (SubBuffer, "*/");
1601 /* Find next EOL (from original buffer) */
1603 Ptr2 = strstr (SubBuffer, "\n");
1609 /* Ignore one-line comments */
1613 /* Normal comment, ignore and continue; */
1619 /* Examine multi-line comment */
1627 Ptr2 = strstr (Ptr2, "\n");
1640 ShortCommentCount++;
1647 if (ShortCommentCount)
1649 AsPrint ("Short Comments found", ShortCommentCount, Filename);