]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Common/SimpleFileParsing.c
BaseTools: Clean up source files
[mirror_edk2.git] / BaseTools / Source / C / Common / SimpleFileParsing.c
index 3978e6ed3c8e1b930e5d235f63c922e1ca3a74c0..e7da04424497ce06729f7a5f3df9fd8a00d2ec40 100644 (file)
@@ -1,21 +1,14 @@
 /** @file\r
+Generic but simple file parsing routines.\r
 \r
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials                          \r
-are licensed and made available under the terms and conditions of the BSD License         \r
-which accompanies this distribution.  The full text of the license may be found at        \r
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
 \r
-Module Name:\r
-\r
-  SimpleFileParsing.c  \r
-\r
-Abstract:\r
-\r
-  Generic but simple file parsing routines.\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 --*/\r
 \r
@@ -245,7 +238,7 @@ Arguments:
   FileName  - name of the file to parse\r
 \r
 Returns:\r
-  \r
+\r
 \r
 --*/\r
 {\r
@@ -352,7 +345,7 @@ SFPGetNextToken (
 /*++\r
 \r
 Routine Description:\r
-  Get the next token from the input stream. \r
+  Get the next token from the input stream.\r
 \r
 Arguments:\r
   Str - pointer to a copy of the next token\r
@@ -363,7 +356,7 @@ Returns:
   FALSE - otherwise\r
 \r
 Notes:\r
-  Preceeding white space is ignored. \r
+  Preceeding white space is ignored.\r
   The parser's buffer pointer is advanced past the end of the\r
   token.\r
 \r
@@ -537,7 +530,7 @@ Returns:
 \r
 --*/\r
 {\r
-  unsigned Val;\r
+  int Val;\r
 \r
   SkipWhiteSpace (&mGlobals.SourceFile);\r
   if (EndOfFile (&mGlobals.SourceFile)) {\r
@@ -587,7 +580,7 @@ Arguments:
   None.\r
 \r
 Returns:\r
-  STATUS_SUCCESS - the file was closed \r
+  STATUS_SUCCESS - the file was closed\r
   STATUS_ERROR   - no file is currently open\r
 \r
 --*/\r
@@ -612,7 +605,7 @@ ProcessIncludeFile (
 Routine Description:\r
 \r
   Given a source file, open the file and parse it\r
-  \r
+\r
 Arguments:\r
 \r
   SourceFile        - name of file to parse\r
@@ -621,7 +614,7 @@ Arguments:
 Returns:\r
 \r
   Standard status.\r
-  \r
+\r
 --*/\r
 {\r
   STATIC UINTN NestDepth = 0;\r
@@ -681,7 +674,7 @@ Routine Description:
 \r
   Given a source file that's been opened, read the contents into an internal\r
   buffer and pre-process it to remove comments.\r
-  \r
+\r
 Arguments:\r
 \r
   SourceFile        - structure containing info on the file to process\r
@@ -689,7 +682,7 @@ Arguments:
 Returns:\r
 \r
   Standard status.\r
-  \r
+\r
 --*/\r
 {\r
   //\r
@@ -729,13 +722,13 @@ PreprocessFile (
 Routine Description:\r
   Preprocess a file to replace all carriage returns with NULLs so\r
   we can print lines (as part of error messages) from the file to the screen.\r
-  \r
+\r
 Arguments:\r
   SourceFile - structure that we use to keep track of an input file.\r
 \r
 Returns:\r
   Nothing.\r
-  \r
+\r
 --*/\r
 {\r
   BOOLEAN InComment;\r
@@ -833,8 +826,8 @@ SFPGetQuotedString (
 /*++\r
 \r
 Routine Description:\r
-  Retrieve a quoted-string from the input file. \r
-  \r
+  Retrieve a quoted-string from the input file.\r
+\r
 Arguments:\r
   Str    - pointer to a copy of the quoted string parsed\r
   Length - size of buffer pointed to by Str\r
@@ -843,7 +836,7 @@ Returns:
   TRUE    - next token in input stream was a quoted string, and\r
             the string value was returned in Str\r
   FALSE   - otherwise\r
-  \r
+\r
 --*/\r
 {\r
   SkipWhiteSpace (&mGlobals.SourceFile);\r
@@ -888,14 +881,14 @@ SFPIsEOF (
 Routine Description:\r
   Return TRUE of FALSE to indicate whether or not we've reached the end of the\r
   file we're parsing.\r
-  \r
+\r
 Arguments:\r
   NA\r
 \r
 Returns:\r
   TRUE    - EOF reached\r
   FALSE   - otherwise\r
-  \r
+\r
 --*/\r
 {\r
   SkipWhiteSpace (&mGlobals.SourceFile);\r
@@ -1239,12 +1232,10 @@ GetHexChars (
 {\r
   UINT32  Len;\r
   Len = 0;\r
-  while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) {\r
+  while (!EndOfFile (&mGlobals.SourceFile) && (Len < BufferLen)) {\r
     if (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {\r
-      *Buffer = mGlobals.SourceFile.FileBufferPtr[0];\r
-      Buffer++;\r
+      Buffer[Len] = mGlobals.SourceFile.FileBufferPtr[0];\r
       Len++;\r
-      BufferLen--;\r
       mGlobals.SourceFile.FileBufferPtr++;\r
     } else {\r
       break;\r
@@ -1253,8 +1244,8 @@ GetHexChars (
   //\r
   // Null terminate if we can\r
   //\r
-  if ((Len > 0) && (BufferLen > 0)) {\r
-    *Buffer = 0;\r
+  if ((Len > 0) && (Len < BufferLen)) {\r
+    Buffer[Len] = 0;\r
   }\r
 \r
   return Len;\r
@@ -1283,7 +1274,7 @@ Returns:
 \r
 --*/\r
 {\r
-  unsigned      Value32;\r
+  INT32         Value32;\r
   UINT32        Index;\r
   FILE_POSITION FPos;\r
   CHAR8         TempString[20];\r