version 1.7, 1998/12/05 00:06:29 |
version 1.8, 1999/11/11 11:35:17 |
|
|
} |
} |
|
|
/* |
/* |
* Str_FindSubstring -- See if a string contains a particular substring. |
|
* |
|
* Results: If string contains substring, the return value is the location of |
|
* the first matching instance of substring in string. If string doesn't |
|
* contain substring, the return value is NULL. Matching is done on an exact |
|
* character-for-character basis with no wildcards or special characters. |
|
* |
|
* Side effects: None. |
|
*/ |
|
char * |
|
Str_FindSubstring(string, substring) |
|
register char *string; /* String to search. */ |
|
char *substring; /* Substring to find in string */ |
|
{ |
|
register char *a, *b; |
|
|
|
/* |
|
* First scan quickly through the two strings looking for a single- |
|
* character match. When it's found, then compare the rest of the |
|
* substring. |
|
*/ |
|
|
|
for (b = substring; *string != 0; string += 1) { |
|
if (*string != *b) |
|
continue; |
|
a = string; |
|
for (;;) { |
|
if (*b == 0) |
|
return(string); |
|
if (*a++ != *b++) |
|
break; |
|
} |
|
b = substring; |
|
} |
|
return((char *) NULL); |
|
} |
|
|
|
/* |
|
* Str_Match -- |
* Str_Match -- |
* |
* |
* See if a particular string matches a particular pattern. |
* See if a particular string matches a particular pattern. |