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

 
Output of file : AFTER.C contained in archive : CSRC2.ZIP
/*
* a f t e r . c
*/

/*)LIBRARY
*/

#ifdef DOCUMENTATION

title after Point After a Matching String
index Point after a matching string

synopsis

char *
after(s,p)
char s[]; /* Subject string */
char p[]; /* Pattern string */

description

after(s,p) searches s for the first occurence of p. If p occurs as
a substring of s, after() returns a pointer to the next memory
location beyond the matching instance. If p is not a substring of p,
after() returns NULL. Thus, after("abcde","bcd") returns a pointer to
the "e" in the first argument; after("abcde","acd") returns NULL.

If strlen(p) == 0, after() returns s.

See also instr().

bugs

author

Jerry Leichter

#endif

/*
* )EDITLEVEL=13
* Edit history
* 0.0 19-Jul-82 JSL Invention - converted from instr().
*/

#define NULL 0
#define EOS '\0'

extern char *match();

after(s,p)
register char *s; /* Subject */
register char p[]; /* Pattern */
{ register char *ss;

if (p[0] == EOS) /* Null pattern... */
return(s); /* matches at start */

ss = s;

while ((ss = strchr(ss,p[0])) != NULL)
if ((s = match(++ss,&p[1])) != NULL)
return(s);

return(NULL);
}


  3 Responses to “Category : C Source Code
Archive   : CSRC2.ZIP
Filename : AFTER.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/