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
| 115 | @param[in] CheckForEscapeCharacter TRUE to skip escaped instances of FinfString, otherwise will return even escaped instances |
| 116 | **/ |
| 117 | CHAR16* |
| 118 | FindNextInstance( |
| 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. |
no test coverage detected