mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-05 14:29:28 +00:00
18576028af
and non-unix code has been left out.
41 lines
1.8 KiB
C
41 lines
1.8 KiB
C
/******************************************************************************
|
|
* *
|
|
* 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*/
|