Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
859 B

  1. #include "npcommon.h"
  2. // strchrf(str, ch)
  3. //
  4. // Returns a pointer to the first occurrence of ch in str.
  5. // Returns NULL if not found.
  6. // May search for a double-byte character.
  7. LPSTR WINAPI strchrf(LPCSTR lpString, UINT ch)
  8. {
  9. while (*lpString) {
  10. if (ch == (IS_LEAD_BYTE(*lpString) ? GetTwoByteChar(lpString) : *lpString))
  11. return (LPSTR)lpString;
  12. ADVANCE(lpString);
  13. }
  14. return NULL;
  15. }
  16. // strrchrf(str, ch)
  17. //
  18. // Returns a pointer to the last occurrence of ch in str.
  19. // Returns NULL if not found.
  20. // May search for a double-byte character.
  21. LPSTR WINAPI strrchrf(LPCSTR lpString, UINT ch)
  22. {
  23. LPSTR lpLast = NULL;
  24. while (*lpString) {
  25. if (ch == (IS_LEAD_BYTE(*lpString) ? GetTwoByteChar(lpString) : *lpString))
  26. lpLast = (LPSTR)lpString;
  27. ADVANCE(lpString);
  28. }
  29. return lpLast;
  30. }