fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / string / strstr.c
blobdddced3b2ec33219d98f334bf2f2650bbbc928d3
1 /*
2 FUNCTION
3 <<strstr>>---find string segment
5 INDEX
6 strstr
8 ANSI_SYNOPSIS
9 #include <string.h>
10 char *strstr(const char *<[s1]>, const char *<[s2]>);
12 TRAD_SYNOPSIS
13 #include <string.h>
14 char *strstr(<[s1]>, <[s2]>)
15 char *<[s1]>;
16 char *<[s2]>;
18 DESCRIPTION
19 Locates the first occurence in the string pointed to by <[s1]> of
20 the sequence of characters in the string pointed to by <[s2]>
21 (excluding the terminating null character).
23 RETURNS
24 Returns a pointer to the located string segment, or a null
25 pointer if the string <[s2]> is not found. If <[s2]> points to
26 a string with zero length, the <[s1]> is returned.
28 PORTABILITY
29 <<strstr>> is ANSI C.
31 <<strstr>> requires no supporting OS subroutines.
33 QUICKREF
34 strstr ansi pure
37 #include <string.h>
39 char *
40 _DEFUN (strstr, (searchee, lookfor),
41 _CONST char *searchee _AND
42 _CONST char *lookfor)
44 if (*searchee == 0)
46 if (*lookfor)
47 return (char *) NULL;
48 return (char *) searchee;
51 while (*searchee)
53 size_t i;
54 i = 0;
56 while (1)
58 if (lookfor[i] == 0)
60 return (char *) searchee;
63 if (lookfor[i] != searchee[i])
65 break;
67 i++;
69 searchee++;
72 return (char *) NULL;