]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Refactor out a now-redundant function
authorJaben Carsey <Jaben.carsey@intel.com>
Tue, 3 Feb 2015 16:50:12 +0000 (16:50 +0000)
committerjcarsey <jcarsey@Edk2>
Tue, 3 Feb 2015 16:50:12 +0000 (16:50 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <Jaben.carsey@intel.com>
Reviewed-by: Joe Peterson <joe.peterson@intel.com>
Reviewed-by: Shumin Qiu <shumin.qiu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16720 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Application/Shell/Shell.c

index 7a89f028995909d52d459cbce89e3dc6ba6dd767..49318b52285aac66eca70e4d2ab63e9bcbbf8d5a 100644 (file)
@@ -100,48 +100,6 @@ TrimSpaces(
   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
   Check whether the string between a pair of % is a valid envifronment variable name.\r
 \r
@@ -207,7 +165,7 @@ ContainsSplit(
   CONST CHAR16 *FirstQuote;\r
   CONST CHAR16 *SecondQuote;\r
 \r
-  FirstQuote    = FindNextInstance (CmdLine, L"\"", TRUE);\r
+  FirstQuote    = FindFirstCharacter (CmdLine, L"\"", L'^');\r
   SecondQuote   = NULL;\r
   TempSpot      = FindFirstCharacter(CmdLine, L"|", L'^');\r
 \r
@@ -223,15 +181,15 @@ ContainsSplit(
     if (FirstQuote == NULL || FirstQuote > TempSpot) {\r
       break;\r
     }    \r
-    SecondQuote = FindNextInstance (FirstQuote + 1, L"\"", TRUE);\r
+    SecondQuote = FindFirstCharacter (FirstQuote + 1, L"\"", L'^');\r
     if (SecondQuote == NULL) {\r
       break;\r
     }\r
     if (SecondQuote < TempSpot) {\r
-      FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);\r
+      FirstQuote = FindFirstCharacter (SecondQuote + 1, L"\"", L'^');\r
       continue;\r
     } else {\r
-      FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);\r
+      FirstQuote = FindFirstCharacter (SecondQuote + 1, L"\"", L'^');\r
       TempSpot = FindFirstCharacter(TempSpot + 1, L"|", L'^');\r
       continue;\r
     } \r
@@ -1344,9 +1302,9 @@ StripUnreplacedEnvironmentVariables(
   CHAR16 *CurrentLocator;\r
 \r
   for (CurrentLocator = CmdLine ; CurrentLocator != NULL ; ) {\r
-    FirstQuote = FindNextInstance(CurrentLocator, L"\"", TRUE);\r
-    FirstPercent = FindNextInstance(CurrentLocator, L"%", TRUE);\r
-    SecondPercent = FirstPercent!=NULL?FindNextInstance(FirstPercent+1, L"%", TRUE):NULL;\r
+    FirstQuote = FindFirstCharacter(CurrentLocator, L"\"", L'^');\r
+    FirstPercent = FindFirstCharacter(CurrentLocator, L"%", L'^');\r
+    SecondPercent = FirstPercent!=NULL?FindFirstCharacter(FirstPercent+1, L"%", L'^'):NULL;\r
     if (FirstPercent == NULL || SecondPercent == NULL) {\r
       //\r
       // If we ever dont have 2 % we are done.\r
@@ -1355,11 +1313,10 @@ StripUnreplacedEnvironmentVariables(
     }\r
 \r
     if (FirstQuote!= NULL && FirstQuote < FirstPercent) {\r
-      SecondQuote = FindNextInstance(FirstQuote+1, L"\"", TRUE);\r
+      SecondQuote = FindFirstCharacter(FirstQuote+1, L"\"", L'^');\r
       //\r
       // Quote is first found\r
       //\r
-\r
       if (SecondQuote < FirstPercent) {\r
         //\r
         // restart after the pair of "\r