File: strstr.c

package info (click to toggle)
gcvs 1.0final-17
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,248 kB
  • ctags: 10,629
  • sloc: ansic: 71,711; cpp: 39,785; sh: 18,434; makefile: 1,917; yacc: 1,299; tcl: 1,283; perl: 910; lex: 249; csh: 185; lisp: 7
file content (40 lines) | stat: -rwxr-xr-x 1,807 bytes parent folder | download | duplicates (9)
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
36
37
38
39
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*/