source: trunk/libs/newlib/src/newlib/libc/string/strpbrk.c @ 543

Last change on this file since 543 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 864 bytes
Line 
1/*
2FUNCTION
3        <<strpbrk>>---find characters in string
4
5INDEX
6        strpbrk
7
8SYNOPSIS
9        #include <string.h>
10        char *strpbrk(const char *<[s1]>, const char *<[s2]>);
11
12DESCRIPTION
13        This function locates the first occurence in the string
14        pointed to by <[s1]> of any character in string pointed to by
15        <[s2]> (excluding the terminating null character).
16
17RETURNS
18        <<strpbrk>> returns a pointer to the character found in <[s1]>, or a
19        null pointer if no character from <[s2]> occurs in <[s1]>.
20
21PORTABILITY
22<<strpbrk>> requires no supporting OS subroutines.
23*/
24
25#include <string.h>
26
27char *
28strpbrk (const char *s1,
29        const char *s2)
30{
31  const char *c = s2;
32  if (!*s1)
33    return (char *) NULL;
34
35  while (*s1)
36    {
37      for (c = s2; *c; c++)
38        {
39          if (*s1 == *c)
40            break;
41        }
42      if (*c)
43        break;
44      s1++;
45    }
46
47  if (*c == '\0')
48    s1 = NULL;
49
50  return (char *) s1;
51}
Note: See TracBrowser for help on using the repository browser.