Mercurial > gnulib
annotate lib/strcspn.c @ 40186:8964917f9574
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Mon, 18 Feb 2019 08:02:49 -0800 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
39890
diff
changeset
|
1 /* Copyright (C) 1991, 1994, 1996-1997, 2002-2003, 2005-2006, 2009-2019 Free |
12518
b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents:
9309
diff
changeset
|
2 * Software Foundation, Inc. |
9 | 3 |
1111
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
4 NOTE: The canonical source of this file is maintained with the GNU C Library. |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
5 Bugs can be reported to bug-glibc@gnu.org. |
1111
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
6 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
7 This program is free software: you can redistribute it and/or modify it |
1111
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7304
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or any |
1111
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
10 later version. |
309 | 11 |
311 | 12 This program is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
9 | 16 |
311 | 17 You should have received a copy of the GNU General Public License |
19190 | 18 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
311 | 19 |
7304
1c4ed7637c24
Include <config.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents:
7026
diff
changeset
|
20 #include <config.h> |
9 | 21 |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
22 #include <stddef.h> |
4682 | 23 #include <string.h> |
9 | 24 |
39890
3b389d4449c2
strcspn: Make it possible to namespace the defined symbol.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
25 #if _LIBC |
3b389d4449c2
strcspn: Make it possible to namespace the defined symbol.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
26 # undef strcspn |
3b389d4449c2
strcspn: Make it possible to namespace the defined symbol.
Bruno Haible <bruno@clisp.org>
parents:
19484
diff
changeset
|
27 #endif |
1111
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
28 |
884 | 29 /* Return the length of the maximum initial segment of S |
9 | 30 which contains no characters from REJECT. */ |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
31 size_t |
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
32 strcspn (const char *s, const char *reject) |
9 | 33 { |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
34 size_t count = 0; |
9 | 35 |
36 while (*s != '\0') | |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
37 if (strchr (reject, *s++) == NULL) |
9 | 38 ++count; |
39 else | |
40 return count; | |
41 | |
42 return count; | |
43 } |