diff --git a/Include/Acidanthera/Library/OcStringLib.h b/Include/Acidanthera/Library/OcStringLib.h index 3d8435bf..f58a23ee 100755 --- a/Include/Acidanthera/Library/OcStringLib.h +++ b/Include/Acidanthera/Library/OcStringLib.h @@ -255,9 +255,7 @@ OcStrniCmp ( the length of SearchString is zero, then String is returned. If String is NULL, then ASSERT(). - If String is not aligned on a 8-bit boundary, then ASSERT(). If SearchString is NULL, then ASSERT(). - If SearchString is not aligned on a 8-bit boundary, then ASSERT(). If PcdMaximumAsciiStringLength is not zero, and SearchString or String contains more than PcdMaximumAsciiStringLength ASCII @@ -277,6 +275,52 @@ OcAsciiStriStr ( IN CONST CHAR8 *SearchString ); +/** + Returns a pointer to the first occurrence of Char + in a Null-terminated ASCII string. + + If String is NULL, then ASSERT(). + + If PcdMaximumAsciiStringLength is not zero, and String + contains more than PcdMaximumAsciiStringLength ASCII + characters, not including the Null-terminator, then ASSERT(). + + @param String The pointer to a Null-terminated ASCII string. + @param Char Character to be located. + + @return A pointer to the first occurrence of Char in String. + @retval NULL If Char cannot be found in String. +**/ +CHAR8 * +EFIAPI +OcAsciiStrChr ( + IN CONST CHAR8 *String, + IN CHAR8 Char + ); + +/** + Returns a pointer to the last occurrence of Char + in a Null-terminated ASCII string. + + If String is NULL, then ASSERT(). + + If PcdMaximumAsciiStringLength is not zero, and String + contains more than PcdMaximumAsciiStringLength ASCII + characters, not including the Null-terminator, then ASSERT(). + + @param String The pointer to a Null-terminated ASCII string. + @param Char Character to be located. + + @return A pointer to the last occurrence of Char in String. + @retval NULL If Char cannot be found in String. +**/ +CHAR8 * +EFIAPI +OcAsciiStrrChr ( + IN CONST CHAR8 *String, + IN CHAR8 Char + ); + /** Returns the first occurrence of a Null-terminated Unicode sub-string in a Null-terminated Unicode string through a case insensitive comparison. diff --git a/Library/OcStringLib/OcAsciiLib.c b/Library/OcStringLib/OcAsciiLib.c index 4bcb37f6..1443a690 100755 --- a/Library/OcStringLib/OcAsciiLib.c +++ b/Library/OcStringLib/OcAsciiLib.c @@ -262,3 +262,53 @@ OcAsciiStriStr ( return NULL; } + +CHAR8 * +EFIAPI +OcAsciiStrChr ( + IN CONST CHAR8 *String, + IN CHAR8 Char + ) +{ + ASSERT (AsciiStrSize (String) != 0); + + while (*String != '\0') { + // + // Return immediately when matching first occurrence of Char. + // + if (*String == Char) { + return (CHAR8 *) String; + } + + ++String; + } + + return NULL; +} + +CHAR8 * +EFIAPI +OcAsciiStrrChr ( + IN CONST CHAR8 *String, + IN CHAR8 Char + ) +{ + CHAR8 *Save; + + ASSERT (AsciiStrSize (String) != 0); + + Save = NULL; + + while (*String != '\0') { + // + // Record the last occurrence of Char. + // + if (*String == Char) { + Save = (CHAR8 *) String; + } + + ++String; + } + + return Save; +}