return (EFI_SUCCESS);\r
}\r
\r
+/**\r
+ Parse for the next instance of one string within another string. Can optionally make sure that \r
+ the string was not escaped (^ character) per the shell specification.\r
+\r
+ @param[in] SourceString The string to search within\r
+ @param[in] FindString The string to look for\r
+ @param[in] CheckForEscapeCharacter TRUE to skip escaped instances of FinfString, otherwise will return even escaped instances\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+FindNextInstance(\r
+ IN CONST CHAR16 *SourceString,\r
+ IN CONST CHAR16 *FindString,\r
+ IN CONST BOOLEAN CheckForEscapeCharacter\r
+ )\r
+{\r
+ CHAR16 *Temp;\r
+ if (SourceString == NULL) {\r
+ return (NULL);\r
+ }\r
+ Temp = StrStr(SourceString, FindString);\r
+\r
+ //\r
+ // If nothing found, or we dont care about escape characters\r
+ //\r
+ if (Temp == NULL || !CheckForEscapeCharacter) {\r
+ return (Temp);\r
+ }\r
+\r
+ //\r
+ // If we found an escaped character, try again on the remainder of the string\r
+ //\r
+ if ((Temp > (SourceString)) && *(Temp-1) == L'^') {\r
+ return FindNextInstance(Temp+1, FindString, CheckForEscapeCharacter);\r
+ }\r
+\r
+ //\r
+ // we found the right character\r
+ //\r
+ return (Temp);\r
+}\r
+\r
/**\r
Find a command line contains a split operation\r
\r
)\r
{\r
CONST CHAR16 *TempSpot;\r
- TempSpot = FindSplit(CmdLine);\r
+ CONST CHAR16 *FirstQuote;\r
+ CONST CHAR16 *SecondQuote;\r
+\r
+ FirstQuote = FindNextInstance (CmdLine, L"\"", TRUE);\r
+ SecondQuote = NULL;\r
+ TempSpot = FindSplit(CmdLine);\r
+\r
+ if (FirstQuote == NULL || \r
+ TempSpot == NULL || \r
+ TempSpot == CHAR_NULL || \r
+ FirstQuote > TempSpot\r
+ ) {\r
+ return (BOOLEAN) ((TempSpot != NULL) && (*TempSpot != CHAR_NULL));\r
+ }\r
+\r
+ while ((TempSpot != NULL) && (*TempSpot != CHAR_NULL)) {\r
+ if (FirstQuote == NULL || FirstQuote > TempSpot) {\r
+ break;\r
+ } \r
+ SecondQuote = FindNextInstance (FirstQuote + 1, L"\"", TRUE);\r
+ if (SecondQuote == NULL) {\r
+ break;\r
+ }\r
+ if (SecondQuote < TempSpot) {\r
+ FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);\r
+ continue;\r
+ } else {\r
+ FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);\r
+ TempSpot = FindSplit(TempSpot + 1);\r
+ continue;\r
+ } \r
+ }\r
+ \r
return (BOOLEAN) ((TempSpot != NULL) && (*TempSpot != CHAR_NULL));\r
}\r
\r
return (EFI_SUCCESS);\r
}\r
\r
-/**\r
- Parse for the next instance of one string within another string. Can optionally make sure that \r
- the string was not escaped (^ character) per the shell specification.\r
-\r
- @param[in] SourceString The string to search within\r
- @param[in] FindString The string to look for\r
- @param[in] CheckForEscapeCharacter TRUE to skip escaped instances of FinfString, otherwise will return even escaped instances\r
-**/\r
-CHAR16*\r
-EFIAPI\r
-FindNextInstance(\r
- IN CONST CHAR16 *SourceString,\r
- IN CONST CHAR16 *FindString,\r
- IN CONST BOOLEAN CheckForEscapeCharacter\r
- )\r
-{\r
- CHAR16 *Temp;\r
- if (SourceString == NULL) {\r
- return (NULL);\r
- }\r
- Temp = StrStr(SourceString, FindString);\r
-\r
- //\r
- // If nothing found, or we dont care about escape characters\r
- //\r
- if (Temp == NULL || !CheckForEscapeCharacter) {\r
- return (Temp);\r
- }\r
-\r
- //\r
- // If we found an escaped character, try again on the remainder of the string\r
- //\r
- if ((Temp > (SourceString)) && *(Temp-1) == L'^') {\r
- return FindNextInstance(Temp+1, FindString, CheckForEscapeCharacter);\r
- }\r
-\r
- //\r
- // we found the right character\r
- //\r
- return (Temp);\r
-}\r
-\r
/**\r
This function will eliminate unreplaced (and therefore non-found) environment variables.\r
\r