From 8b7ebdb0055241e3e573fb7c561a969be33d591d Mon Sep 17 00:00:00 2001 From: "Gao, Liming liming.gao" Date: Fri, 25 Jul 2014 21:10:20 +0000 Subject: Update GenFv tool to handle the file path with space. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Gao, Liming liming.gao@intel.com Review-by: Kinney, Michael D michael.d.kinney@intel.com git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15685 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Source/C/Common/ParseInf.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/C/Common/ParseInf.c b/BaseTools/Source/C/Common/ParseInf.c index bbccb61732..385758f836 100644 --- a/BaseTools/Source/C/Common/ParseInf.c +++ b/BaseTools/Source/C/Common/ParseInf.c @@ -236,6 +236,7 @@ Returns: { CHAR8 InputBuffer[_MAX_PATH]; CHAR8 *CurrentToken; + CHAR8 *Delimiter; BOOLEAN ParseError; BOOLEAN ReadError; UINTN Occurrance; @@ -283,8 +284,13 @@ Returns: // // Get the first non-whitespace string // + Delimiter = strchr (InputBuffer, '='); + if (Delimiter != NULL) { + *Delimiter = 0; + } + CurrentToken = strtok (InputBuffer, " \t\n"); - if (CurrentToken == NULL) { + if (CurrentToken == NULL || Delimiter == NULL) { // // Whitespace line found (or comment) so continue // @@ -311,17 +317,29 @@ Returns: // // Copy the contents following the = // - CurrentToken = strtok (NULL, "= \t\n"); - if (CurrentToken == NULL) { + CurrentToken = Delimiter + 1; + if (*CurrentToken == 0) { // // Nothing found, parsing error // ParseError = TRUE; } else { + // + // Strip leading white space + // + while (*CurrentToken == ' ' || *CurrentToken == '\t') { + CurrentToken++; + } // // Copy the current token to the output value // strcpy (Value, CurrentToken); + // + // Strip trailing white space + // + while (strlen(Value) > 0 && (*(Value + strlen(Value) - 1) == ' ' || *(Value + strlen(Value) - 1) == '\t')) { + *(Value + strlen(Value) - 1) = 0; + } return EFI_SUCCESS; } } else { -- cgit v1.2.3