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.

72 lines
1.7 KiB

  1. /***
  2. *wcsstr.c - search for one wide-character string inside another
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines wcsstr() - search for one wchar_t string inside another
  8. *
  9. *Revision History:
  10. * 09-09-91 ETC Created from strstr.c.
  11. * 04-07-92 KRS Updated and ripped out _INTL switches.
  12. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  13. * 02-07-94 CFW POSIXify.
  14. * 08-02-00 GB fixed str2 = ""
  15. *
  16. *******************************************************************************/
  17. #ifndef _POSIX_
  18. #include <cruntime.h>
  19. #include <string.h>
  20. /***
  21. *wchar_t *wcsstr(string1, string2) - search for string2 in string1
  22. * (wide strings)
  23. *
  24. *Purpose:
  25. * finds the first occurrence of string2 in string1 (wide strings)
  26. *
  27. *Entry:
  28. * wchar_t *string1 - string to search in
  29. * wchar_t *string2 - string to search for
  30. *
  31. *Exit:
  32. * returns a pointer to the first occurrence of string2 in
  33. * string1, or NULL if string2 does not occur in string1
  34. *
  35. *Uses:
  36. *
  37. *Exceptions:
  38. *
  39. *******************************************************************************/
  40. wchar_t * __cdecl wcsstr (
  41. const wchar_t * wcs1,
  42. const wchar_t * wcs2
  43. )
  44. {
  45. wchar_t *cp = (wchar_t *) wcs1;
  46. wchar_t *s1, *s2;
  47. if ( !*wcs2)
  48. return (wchar_t *)wcs1;
  49. while (*cp)
  50. {
  51. s1 = cp;
  52. s2 = (wchar_t *) wcs2;
  53. while ( *s1 && *s2 && !(*s1-*s2) )
  54. s1++, s2++;
  55. if (!*s2)
  56. return(cp);
  57. cp++;
  58. }
  59. return(NULL);
  60. }
  61. #endif /* _POSIX_ */