File tree 1 file changed +5
-11
lines changed
1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -16,26 +16,20 @@ length, the function returns @var{string}.
16
16
17
17
*/
18
18
19
-
20
- /* FIXME: The above description is ANSI compiliant. This routine has not
21
- been validated to comply with it. -fnf */
22
-
23
19
#include <stddef.h>
24
20
25
- extern char * strchr (const char * , int );
26
- extern int strncmp (const void * , const void * , size_t );
21
+ extern int memcmp (const void * , const void * , size_t );
27
22
extern size_t strlen (const char * );
28
23
29
24
char *
30
25
strstr (const char * s1 , const char * s2 )
31
26
{
32
- const char * p = s1 ;
33
27
const size_t len = strlen (s2 );
34
-
35
- for (; (p = strchr (p , * s2 )) != 0 ; p ++ )
28
+ while (* s1 )
36
29
{
37
- if (strncmp (p , s2 , len ) == 0 )
38
- return (char * )p ;
30
+ if (!memcmp (s1 , s2 , len ))
31
+ return (char * )s1 ;
32
+ ++ s1 ;
39
33
}
40
34
return (0 );
41
35
}
You can’t perform that action at this time.
0 commit comments