summaryrefslogtreecommitdiffstats
path: root/private/crt32/string/wcsstr.c
blob: df6d3d638d811a48d5d89e5f3f517063cd928f2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/***
*wcsstr.c - search for one wide-character string inside another
*
*	Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
*	defines wcsstr() - search for one wchar_t string inside another
*
*Revision History:
*	09-09-91   ETC	Created from strstr.c.
*	04-07-92   KRS	Updated and ripped out _INTL switches.
*
*******************************************************************************/

#include <cruntime.h>
#include <string.h>

/***
*wchar_t *wcsstr(string1, string2) - search for string2 in string1 
*	(wide strings)
*
*Purpose:
*	finds the first occurrence of string2 in string1 (wide strings)
*
*Entry:
*	wchar_t *string1 - string to search in
*	wchar_t *string2 - string to search for
*
*Exit:
*	returns a pointer to the first occurrence of string2 in
*	string1, or NULL if string2 does not occur in string1
*
*Uses:
*
*Exceptions:
*
*******************************************************************************/

wchar_t * _CALLTYPE1 wcsstr (
	const wchar_t * wcs1,
	const wchar_t * wcs2
	)
{
	wchar_t *cp = (wchar_t *) wcs1;
	wchar_t *s1, *s2;

	while (*cp)
	{
		s1 = cp;
		s2 = (wchar_t *) wcs2;

		while ( *s1 && *s2 && !(*s1-*s2) )
			s1++, s2++;

		if (!*s2)
			return(cp);

		cp++;
	}

	return(NULL);
}