Category : C Source Code
Archive   : CSRC2.ZIP
Filename : MATCH.C

 
Output of file : MATCH.C contained in archive : CSRC2.ZIP
/*
* m a t c h . c
*/

/*)LIBRARY
*/

#ifdef DOCUMENTATION

title match Determine if a String Is a Leading Substring of Another
index Determine if a string matches a leading substring of another
index Pattern matching - match constant string

synopsis

char *
match(s,p)
char *s;
char *p;

description

match(s,p) returns a pointer to the first character of s beyond those
matching p, if p is an initial substring of s. Otherwise, it returns
NULL. Thus,

match("abcde","abc")

returns a pointer to the 'd' in the first string;

match("abcde","bc")

returns NULL.

bugs

author

Jerry Leichter

#endif

/*
* )EDITLEVEL=05
* Edit history
* 0.0 4-May-81 JSL Invention
* 1.0 7-May-81 JSL Now returns pointer to first character after the match
* instead of just TRUE.
* 1.1 23-Jun-81 JSL Conversion to the new documentation conventions.
*/

#define NULL 0

char *
match(s,p)
register char *s, *p;
{
while (*s == *p && *s != '\0') {
/*
* No need to check *p; it equals *s or
* the first test fails.
*/
p++;
s++;
}
return((*p != '\0') ? NULL : s);
}


  3 Responses to “Category : C Source Code
Archive   : CSRC2.ZIP
Filename : MATCH.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/