windows-nt/Source/XPSP1/NT/shell/ext/ratings/common/chr.cpp

38 lines
859 B
C++
Raw Normal View History

2020-09-26 03:20:57 -05:00
#include "npcommon.h"
// strchrf(str, ch)
//
// Returns a pointer to the first occurrence of ch in str.
// Returns NULL if not found.
// May search for a double-byte character.
LPSTR WINAPI strchrf(LPCSTR lpString, UINT ch)
{
while (*lpString) {
if (ch == (IS_LEAD_BYTE(*lpString) ? GetTwoByteChar(lpString) : *lpString))
return (LPSTR)lpString;
ADVANCE(lpString);
}
return NULL;
}
// strrchrf(str, ch)
//
// Returns a pointer to the last occurrence of ch in str.
// Returns NULL if not found.
// May search for a double-byte character.
LPSTR WINAPI strrchrf(LPCSTR lpString, UINT ch)
{
LPSTR lpLast = NULL;
while (*lpString) {
if (ch == (IS_LEAD_BYTE(*lpString) ? GetTwoByteChar(lpString) : *lpString))
lpLast = (LPSTR)lpString;
ADVANCE(lpString);
}
return lpLast;
}