~ubuntu-branches/ubuntu/trusty/gettext/trusty

« back to all changes in this revision

Viewing changes to lib/strcspn.c

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2002-04-10 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20020410131742-npf89tsaygdolprj
Tags: upstream-0.10.40
ImportĀ upstreamĀ versionĀ 0.10.40

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 1991, 1994, 1996, 1997 Free Software Foundation, Inc.
 
2
 
 
3
   NOTE: The canonical source of this file is maintained with the GNU C Library.
 
4
   Bugs can be reported to bug-glibc@gnu.org.
 
5
 
 
6
   This program is free software; you can redistribute it and/or modify it
 
7
   under the terms of the GNU General Public License as published by the
 
8
   Free Software Foundation; either version 2, or (at your option) any
 
9
   later version.
 
10
 
 
11
   This program is distributed in the hope that it will be useful,
 
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
   GNU General Public License for more details.
 
15
 
 
16
   You should have received a copy of the GNU General Public License
 
17
   along with this program; if not, write to the Free Software
 
18
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 
19
   USA.  */
 
20
 
 
21
#if HAVE_CONFIG_H
 
22
# include <config.h>
 
23
#endif
 
24
 
 
25
#if defined _LIBC || HAVE_STRING_H
 
26
# include <string.h>
 
27
#else
 
28
# include <strings.h>
 
29
# ifndef strchr
 
30
#  define strchr index
 
31
# endif
 
32
#endif
 
33
 
 
34
#undef strcspn
 
35
 
 
36
/* Return the length of the maximum initial segment of S
 
37
   which contains no characters from REJECT.  */
 
38
size_t
 
39
strcspn (s, reject)
 
40
     const char *s;
 
41
     const char *reject;
 
42
{
 
43
  size_t count = 0;
 
44
 
 
45
  while (*s != '\0')
 
46
    if (strchr (reject, *s++) == NULL)
 
47
      ++count;
 
48
    else
 
49
      return count;
 
50
 
 
51
  return count;
 
52
}