Revision: 16681
http://sourceforge.net/p/edk2/code/16681
Author: jcarsey
Date: 2015-01-30 16:28:22 +0000 (Fri, 30 Jan 2015)
Log Message:
-----------
ShellPkg: Refactor Split search to generic function
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <[email protected]>
Signed-off-by: Joe Peterson <[email protected]>
Reviewed-by: Shumin Qiu <[email protected]>
Reviewed-by: Tapan Shah <[email protected]>
Modified Paths:
--------------
trunk/edk2/ShellPkg/Application/Shell/Shell.c
trunk/edk2/ShellPkg/Application/Shell/Shell.h
Modified: trunk/edk2/ShellPkg/Application/Shell/Shell.c
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/Shell.c 2015-01-30 05:35:30 UTC
(rev 16680)
+++ trunk/edk2/ShellPkg/Application/Shell/Shell.c 2015-01-30 16:28:22 UTC
(rev 16681)
@@ -190,33 +190,6 @@
}
/**
- Find a command line contains a split operation
-
- @param[in] CmdLine The command line to parse.
-
- @retval A pointer to the | character in CmdLine or NULL if
not present.
-**/
-CONST CHAR16*
-EFIAPI
-FindSplit(
- IN CONST CHAR16 *CmdLine
- )
-{
- CONST CHAR16 *TempSpot;
- TempSpot = NULL;
- if (StrStr(CmdLine, L"|") != NULL) {
- for (TempSpot = CmdLine ; TempSpot != NULL && *TempSpot != CHAR_NULL ;
TempSpot++) {
- if (*TempSpot == L'^' && *(TempSpot+1) == L'|') {
- TempSpot++;
- } else if (*TempSpot == L'|') {
- break;
- }
- }
- }
- return (TempSpot);
-}
-
-/**
Determine if a command line contains a split operation
@param[in] CmdLine The command line to parse.
@@ -236,7 +209,7 @@
FirstQuote = FindNextInstance (CmdLine, L"\"", TRUE);
SecondQuote = NULL;
- TempSpot = FindSplit(CmdLine);
+ TempSpot = FindFirstCharacter(CmdLine, L"|", L'^');
if (FirstQuote == NULL ||
TempSpot == NULL ||
@@ -259,7 +232,7 @@
continue;
} else {
FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);
- TempSpot = FindSplit(TempSpot + 1);
+ TempSpot = FindFirstCharacter(TempSpot + 1, L"|", L'^');
continue;
}
}
@@ -1919,7 +1892,7 @@
//
// recurse to verify the next item
//
- TempSpot = FindSplit(CmdLine)+1;
+ TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;
return (VerifySplit(TempSpot));
}
@@ -2921,3 +2894,38 @@
return (Status);
}
+
+/**
+ Return the pointer to the first occurance of any character from a list of
characters
+
+ @param[in] String the string to parse
+ @param[in] CharacterList the list of character to look for
+ @param[in] EscapeCharacter An escape character to skip
+
+ @return the location of the first character in the string
+ @retval CHAR_NULL no instance of any character in CharacterList was found in
String
+**/
+CONST CHAR16*
+EFIAPI
+FindFirstCharacter(
+ IN CONST CHAR16 *String,
+ IN CONST CHAR16 *CharacterList,
+ IN CONST CHAR16 EscapeCharacter
+ )
+{
+ UINT32 WalkChar;
+ UINT32 WalkStr;
+
+ for (WalkStr = 0; WalkStr < StrLen(String); WalkStr++) {
+ if (String[WalkStr] == EscapeCharacter) {
+ WalkStr++;
+ continue;
+ }
+ for (WalkChar = 0; WalkChar < StrLen(CharacterList); WalkChar++) {
+ if (String[WalkStr] == CharacterList[WalkChar]) {
+ return (&String[WalkStr]);
+ }
+ }
+ }
+ return (String + StrLen(String));
+}
\ No newline at end of file
Modified: trunk/edk2/ShellPkg/Application/Shell/Shell.h
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/Shell.h 2015-01-30 05:35:30 UTC
(rev 16680)
+++ trunk/edk2/ShellPkg/Application/Shell/Shell.h 2015-01-30 16:28:22 UTC
(rev 16681)
@@ -2,7 +2,7 @@
function definitions for internal to shell functions.
(C) Copyright 2014, Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD
License
which accompanies this distribution. The full text of the license may be
found at
@@ -342,6 +342,23 @@
IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol
);
+/**
+ Return the pointer to the first occurance of any character from a list of
characters
+ @param[in] String the string to parse
+ @param[in] CharacterList the list of character to look for
+ @param[in] EscapeCharacter An escape character to skip
+
+ @return the location of the first character in the string
+ @retval CHAR_NULL no instance of any character in CharacterList was found in
String
+**/
+CONST CHAR16*
+EFIAPI
+FindFirstCharacter(
+ IN CONST CHAR16 *String,
+ IN CONST CHAR16 *CharacterList,
+ IN CONST CHAR16 EscapeCharacter
+ );
+
#endif //_SHELL_INTERNAL_HEADER_
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits