diff --git a/source/tools/acpisrc/acpisrc.h b/source/tools/acpisrc/acpisrc.h index 88f4a3ebe..3e56a2630 100644 --- a/source/tools/acpisrc/acpisrc.h +++ b/source/tools/acpisrc/acpisrc.h @@ -115,8 +115,12 @@ * *****************************************************************************/ -#define LINES_IN_LEGAL_HEADER 105 /* See above */ +#define LINES_IN_LEGAL_HEADER 105 /* See above */ +#define LEGAL_HEADER_SIGNATURE " * 2.1. This is your license from Intel Corp. under its intellectual property" +#define LINES_IN_LINUX_HEADER 34 +#define LINUX_HEADER_SIGNATURE " * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS" +#define LINES_IN_ASL_HEADER 29 /* Header as output from disassembler */ #include #include @@ -201,6 +205,7 @@ extern UINT32 Gbl_CommentLines; extern UINT32 Gbl_LongLines; extern UINT32 Gbl_TotalLines; extern UINT32 Gbl_HeaderSize; +extern UINT32 Gbl_HeaderLines; extern struct stat Gbl_StatBuf; extern char *Gbl_FileBuffer; extern UINT32 Gbl_FileSize; diff --git a/source/tools/acpisrc/asconvrt.c b/source/tools/acpisrc/asconvrt.c index bb43ff96c..a4db4728f 100644 --- a/source/tools/acpisrc/asconvrt.c +++ b/source/tools/acpisrc/asconvrt.c @@ -1216,14 +1216,27 @@ AsCountSourceLines ( while (*SubBuffer) { - /* Ignore comments */ + /* Detect comments (// comments are not used, non-ansii) */ if ((SubBuffer[0] == '/') && (SubBuffer[1] == '*')) { - CommentCount++; SubBuffer += 2; + /* First line of multi-line comment is often just whitespace */ + + if (SubBuffer[0] == '\n') + { + WhiteCount++; + SubBuffer++; + } + else + { + CommentCount++; + } + + /* Find end of comment */ + while (SubBuffer[0] && SubBuffer[1] && !(((SubBuffer[0] == '*') && (SubBuffer[1] == '/')))) @@ -1258,7 +1271,11 @@ AsCountSourceLines ( /* Adjust comment count for legal header */ - CommentCount -= Gbl_HeaderSize; + if (Gbl_HeaderSize < CommentCount) + { + CommentCount -= Gbl_HeaderSize; + Gbl_HeaderLines += Gbl_HeaderSize; + } Gbl_SourceLines += LineCount; Gbl_WhiteLines += WhiteCount; diff --git a/source/tools/acpisrc/asfile.c b/source/tools/acpisrc/asfile.c index 8e8e6bb34..15cc92941 100644 --- a/source/tools/acpisrc/asfile.c +++ b/source/tools/acpisrc/asfile.c @@ -317,13 +317,13 @@ AsDetectLoneLineFeeds ( { if (!Gbl_IgnoreLoneLineFeeds) { - printf ("****File has UNIX format**** (LF only, not CR/LF) %d lines, %s\n", - LfCount, Filename); + printf ("%s: ****File has UNIX format**** (LF only, not CR/LF) %d lines\n", + Filename, LfCount); } } else { - printf ("%d lone linefeeds in file %s\n", LfCount, Filename); + printf ("%s: %d lone linefeeds in file\n", Filename, LfCount); } return TRUE; } @@ -579,12 +579,6 @@ AsProcessOneFile ( char *OutPathname = NULL; - Gbl_HeaderSize = LINES_IN_LEGAL_HEADER; /* Normal C file and H header */ - if (strstr (Filename, ".asl")) - { - Gbl_HeaderSize = 29; /* Lines in default ASL header */ - } - /* Allocate a file pathname buffer for both source and target */ Pathname = calloc (MaxPathLength + strlen (Filename) + 2, 1); @@ -611,6 +605,20 @@ AsProcessOneFile ( return -1; } + Gbl_HeaderSize = 0; + if (strstr (Filename, ".asl")) + { + Gbl_HeaderSize = LINES_IN_ASL_HEADER; /* Lines in default ASL header */ + } + else if (strstr (Gbl_FileBuffer, LEGAL_HEADER_SIGNATURE)) + { + Gbl_HeaderSize = LINES_IN_LEGAL_HEADER; /* Normal C file and H header */ + } + else if (strstr (Gbl_FileBuffer, LINUX_HEADER_SIGNATURE)) + { + Gbl_HeaderSize = LINES_IN_LINUX_HEADER; /* Linuxized C file and H header */ + } + /* Process the file in the buffer */ Gbl_MadeChanges = FALSE; diff --git a/source/tools/acpisrc/asmain.c b/source/tools/acpisrc/asmain.c index 69554111a..578dd9149 100644 --- a/source/tools/acpisrc/asmain.c +++ b/source/tools/acpisrc/asmain.c @@ -131,6 +131,7 @@ UINT32 Gbl_CommentLines = 0; UINT32 Gbl_SourceLines = 0; UINT32 Gbl_LongLines = 0; UINT32 Gbl_TotalLines = 0; +UINT32 Gbl_HeaderLines = 0; UINT32 Gbl_HeaderSize = 0; void *Gbl_StructDefs = NULL; @@ -254,10 +255,15 @@ AsDisplayStats (void) printf ("%8u Lines of non-comment whitespace\n", Gbl_WhiteLines); printf ("%8u Lines of comments\n", Gbl_CommentLines); printf ("%8u Long lines found\n", Gbl_LongLines); - printf ("%6.1f Ratio of code to whitespace\n", + printf ("%8.1f Ratio of code to whitespace\n", ((float) Gbl_SourceLines / (float) Gbl_WhiteLines)); - printf ("%6.1f Ratio of code to comments\n", + printf ("%8.1f Ratio of code to comments\n", ((float) Gbl_SourceLines / (float) (Gbl_CommentLines + Gbl_NonAnsiComments))); + printf (" %u%% code, %u%% comments, %u%% whitespace, %u%% headers\n", + (Gbl_SourceLines * 100) / Gbl_TotalLines, + (Gbl_CommentLines * 100) / Gbl_TotalLines, + (Gbl_WhiteLines * 100) / Gbl_TotalLines, + (Gbl_HeaderLines * 100) / Gbl_TotalLines); return; }