blob: 00355bc8165efdc7c33910b46c97a75e36e594c7 (
plain)
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
|
/* File : strstr.c
Author : Monty
Updated: 1986.11.24
Defines: strstr()
strstr(src, pat) looks for an instance of pat in src. pat is not a
regex(3) pattern, it is a literal string which must be matched exactly.
The result is a pointer to the first character of the located instance,
or NullS if pat does not occur in src.
*/
#include <my_global.h>
#include "m_string.h"
#ifndef HAVE_STRSTR
char *strstr(register const char *str,const char *search)
{
register char *i,*j;
register char first= *search;
skipp:
while (*str != '\0') {
if (*str++ == first) {
i=(char*) str; j=(char*) search+1;
while (*j)
if (*i++ != *j++) goto skipp;
return ((char*) str-1);
}
}
return ((char*) 0);
} /* strstr */
#endif
|