MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / FindNextInstance

Function FindNextInstance

ShellPkg/Application/Shell/Shell.c:117–148  ·  view source on GitHub ↗

Parse for the next instance of one string within another string. Can optionally make sure that the string was not escaped (^ character) per the shell specification. @param[in] SourceString The string to search within @param[in] FindString The string to look for @param[in] CheckForEscapeCharacter TRUE to skip escaped instances of FinfString, otherwise will r

Source from the content-addressed store, hash-verified

115 @param[in] CheckForEscapeCharacter TRUE to skip escaped instances of FinfString, otherwise will return even escaped instances
116**/
117CHAR16*
118FindNextInstance(
119 IN CONST CHAR16 *SourceString,
120 IN CONST CHAR16 *FindString,
121 IN CONST BOOLEAN CheckForEscapeCharacter
122 )
123{
124 CHAR16 *Temp;
125 if (SourceString == NULL) {
126 return (NULL);
127 }
128 Temp = StrStr(SourceString, FindString);
129
130 //
131 // If nothing found, or we don't care about escape characters
132 //
133 if (Temp == NULL || !CheckForEscapeCharacter) {
134 return (Temp);
135 }
136
137 //
138 // If we found an escaped character, try again on the remainder of the string
139 //
140 if ((Temp > (SourceString)) && *(Temp-1) == L'^') {
141 return FindNextInstance(Temp+1, FindString, CheckForEscapeCharacter);
142 }
143
144 //
145 // we found the right character
146 //
147 return (Temp);
148}
149
150/**
151 Check whether the string between a pair of % is a valid environment variable name.

Callers 2

ContainsSplitFunction · 0.85

Calls 1

StrStrFunction · 0.85

Tested by

no test coverage detected