diff options
Diffstat (limited to 'gnu/usr.bin/cvs/lib/strstr.c')
-rw-r--r-- | gnu/usr.bin/cvs/lib/strstr.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gnu/usr.bin/cvs/lib/strstr.c b/gnu/usr.bin/cvs/lib/strstr.c new file mode 100644 index 00000000000..e43bca0b4e8 --- /dev/null +++ b/gnu/usr.bin/cvs/lib/strstr.c @@ -0,0 +1,40 @@ +/****************************************************************************** +* * +* s t r s t r * +* * +* Find the first occurrence of a string in another string. * +* * +* Format: * +* return = strstr(Source,What); * +* * +* Parameters: * +* * +* Returns: * +* * +* Scope: PUBLIC * +* * +******************************************************************************/ + +char *strstr(Source, What) +register const char *Source; +register const char *What; +{ +register char WhatChar; +register char SourceChar; +register long Length; + + + if ((WhatChar = *What++) != 0) { + Length = strlen(What); + do { + do { + if ((SourceChar = *Source++) == 0) { + return (0); + } + } while (SourceChar != WhatChar); + } while (strncmp(Source, What, Length) != 0); + Source--; + } + return ((char *)Source); + +}/*strstr*/ |