File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 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}.
1616
1717*/
1818
19-
20- /* FIXME: The above description is ANSI compiliant. This routine has not
21- been validated to comply with it. -fnf */
22-
2319#include <stddef.h>
2420
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 );
2722extern size_t strlen (const char * );
2823
2924char *
3025strstr (const char * s1 , const char * s2 )
3126{
32- const char * p = s1 ;
3327 const size_t len = strlen (s2 );
34-
35- for (; (p = strchr (p , * s2 )) != 0 ; p ++ )
28+ while (* s1 )
3629 {
37- if (strncmp (p , s2 , len ) == 0 )
38- return (char * )p ;
30+ if (!memcmp (s1 , s2 , len ))
31+ return (char * )s1 ;
32+ ++ s1 ;
3933 }
4034 return (0 );
4135}
You can’t perform that action at this time.
0 commit comments