2003-09-13 22:01:20 +00:00
|
|
|
/* Copyright (C) 1991, 1994, 1996-1997, 2002-2003 Free Software Foundation, Inc.
|
1992-11-01 05:44:29 +00:00
|
|
|
|
1997-11-13 14:21:02 +00:00
|
|
|
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
2002-11-21 13:25:22 +00:00
|
|
|
Bugs can be reported to bug-glibc@gnu.org.
|
1997-11-13 14:21:02 +00:00
|
|
|
|
|
|
|
|
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.
|
1992-11-01 05:44:29 +00:00
|
|
|
|
1994-10-01 04:48:44 +00:00
|
|
|
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.
|
1992-11-01 05:44:29 +00:00
|
|
|
|
1994-10-01 04:48:44 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
1997-11-13 14:21:02 +00:00
|
|
|
along with this program; if not, write to the Free Software
|
2005-05-14 07:58:06 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
1997-11-13 14:21:02 +00:00
|
|
|
USA. */
|
1992-11-01 05:44:29 +00:00
|
|
|
|
2005-09-22 06:05:39 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
1996-07-15 03:56:06 +00:00
|
|
|
# include <config.h>
|
1994-10-01 04:48:44 +00:00
|
|
|
#endif
|
1994-09-28 01:19:14 +00:00
|
|
|
|
2002-11-21 13:25:22 +00:00
|
|
|
#include <stddef.h>
|
2003-09-13 22:01:20 +00:00
|
|
|
#include <string.h>
|
1992-11-01 05:44:29 +00:00
|
|
|
|
1997-11-13 14:21:02 +00:00
|
|
|
#undef strcspn
|
|
|
|
|
|
1997-02-18 15:12:41 +00:00
|
|
|
/* Return the length of the maximum initial segment of S
|
1992-11-01 05:44:29 +00:00
|
|
|
which contains no characters from REJECT. */
|
2002-11-21 13:25:22 +00:00
|
|
|
size_t
|
|
|
|
|
strcspn (const char *s, const char *reject)
|
1992-11-01 05:44:29 +00:00
|
|
|
{
|
2002-11-21 13:25:22 +00:00
|
|
|
size_t count = 0;
|
1992-11-01 05:44:29 +00:00
|
|
|
|
|
|
|
|
while (*s != '\0')
|
2002-11-21 13:25:22 +00:00
|
|
|
if (strchr (reject, *s++) == NULL)
|
1992-11-01 05:44:29 +00:00
|
|
|
++count;
|
|
|
|
|
else
|
|
|
|
|
return count;
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
}
|