strpbrk.c 1.27 KB
Newer Older
1
/* Copyright (C) 1991, 1994, 2000, 2002-2003, 2006, 2009-2010 Free Software
2 3
   Foundation, Inc.

Jim Meyering's avatar
Jim Meyering committed
4 5
   NOTE: The canonical source of this file is maintained with the GNU C Library.
   Bugs can be reported to bug-glibc@prep.ai.mit.edu.
Jim Meyering's avatar
.  
Jim Meyering committed
6

Jim Meyering's avatar
Jim Meyering committed
7 8 9 10
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.
Jim Meyering's avatar
.  
Jim Meyering committed
11

Jim Meyering's avatar
Jim Meyering committed
12 13 14 15
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
Jim Meyering's avatar
.  
Jim Meyering committed
16

Jim Meyering's avatar
Jim Meyering committed
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software Foundation,
Paul Eggert's avatar
Paul Eggert committed
19
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
Jim Meyering's avatar
.  
Jim Meyering committed
20

21
#include <config.h>
Jim Meyering's avatar
.  
Jim Meyering committed
22

23
#include <stddef.h>
Bruno Haible's avatar
Bruno Haible committed
24
#include <string.h>
25 26 27 28

#undef strpbrk

/* Find the first occurrence in S of any character in ACCEPT.  */
Jim Meyering's avatar
.  
Jim Meyering committed
29
char *
Jim Meyering's avatar
Jim Meyering committed
30
strpbrk (const char *s, const char *accept)
Jim Meyering's avatar
.  
Jim Meyering committed
31 32 33 34 35
{
  while (*s != '\0')
    {
      const char *a = accept;
      while (*a != '\0')
36 37
        if (*a++ == *s)
          return (char *) s;
Jim Meyering's avatar
.  
Jim Meyering committed
38 39 40
      ++s;
    }

41
  return NULL;
Jim Meyering's avatar
.  
Jim Meyering committed
42
}