Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/strcspn.c @ 4685:2e7b90348c21
Remove K&R cruft.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 11 Sep 2003 08:43:46 +0000 |
parents | 90abbdf08583 |
children | a48fb0e98c8c |
rev | line source |
---|---|
4682 | 1 /* Copyright (C) 1991, 1994, 1996-1997, 2002-2003 Free Software Foundation, Inc. |
9 | 2 |
1111
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
3 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
|
4 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
|
5 |
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify it |
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
7 under the terms of the GNU General Public License as published by the |
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
8 Free Software Foundation; either version 2, or (at your option) any |
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
9 later version. |
309 | 10 |
311 | 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. | |
9 | 15 |
311 | 16 You should have received a copy of the GNU General Public License |
1111
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
17 along with this program; if not, write to the Free Software |
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
19 USA. */ |
311 | 20 |
882 | 21 #if HAVE_CONFIG_H |
653 | 22 # include <config.h> |
311 | 23 #endif |
9 | 24 |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
25 #include <stddef.h> |
4682 | 26 #include <string.h> |
9 | 27 |
1111
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
28 #undef strcspn |
d443de4b7b3e
partial update from FSF -- use int, not size_t; 0, not NULL
Jim Meyering <jim@meyering.net>
parents:
884
diff
changeset
|
29 |
884 | 30 /* Return the length of the maximum initial segment of S |
9 | 31 which contains no characters from REJECT. */ |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
32 size_t |
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
33 strcspn (const char *s, const char *reject) |
9 | 34 { |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
35 size_t count = 0; |
9 | 36 |
37 while (*s != '\0') | |
3975
e34e6bd35c66
Minimize diffs to glibc. Modernize.
Bruno Haible <bruno@clisp.org>
parents:
2807
diff
changeset
|
38 if (strchr (reject, *s++) == NULL) |
9 | 39 ++count; |
40 else | |
41 return count; | |
42 | |
43 return count; | |
44 } |