|
|
1.1 ! root 1: /* ! 2: * strpbrk.c -- ! 3: * ! 4: * Source code for the "strpbrk" library routine. ! 5: * ! 6: * Copyright 1988 Regents of the University of California ! 7: * Permission to use, copy, modify, and distribute this ! 8: * software and its documentation for any purpose and without ! 9: * fee is hereby granted, provided that the above copyright ! 10: * notice appear in all copies. The University of California ! 11: * makes no representations about the suitability of this ! 12: * software for any purpose. It is provided "as is" without ! 13: * express or implied warranty. ! 14: */ ! 15: ! 16: #ifndef lint ! 17: static char rcsid[] = "$Header: /sprite/src/lib/c/string/RCS/strpbrk.c,v 1.2 89/03/22 16:07:46 rab Exp $ SPRITE (Berkeley)"; ! 18: #endif /* not lint */ ! 19: ! 20: #include <string.h> ! 21: ! 22: /* ! 23: *---------------------------------------------------------------------- ! 24: * ! 25: * strpbrk -- ! 26: * ! 27: * Search a string for a character from a given set. ! 28: * ! 29: * Results: ! 30: * The return value is the address of the first character ! 31: * in "string" that is also a character in "chars". If there ! 32: * is no such character, then 0 is returned. ! 33: * ! 34: * Side effects: ! 35: * None. ! 36: * ! 37: *---------------------------------------------------------------------- ! 38: */ ! 39: ! 40: char * ! 41: strpbrk(string, chars) ! 42: register char *string; /* String to search. */ ! 43: char *chars; /* Characters to look for in string. */ ! 44: { ! 45: register char c, *p; ! 46: ! 47: for (c = *string; c != 0; string++, c = *string) { ! 48: for (p = chars; *p != 0; p++) { ! 49: if (c == *p) { ! 50: return string; ! 51: } ! 52: } ! 53: } ! 54: return 0; ! 55: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.