1 /* Skipping sequences of characters satisfying a predicate
3 Copyright 2023-2024 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 _GL_INLINE_HEADER_BEGIN
21 #ifndef SKIPCHARS_INLINE
22 # define SKIPCHARS_INLINE _GL_INLINE
25 /* Return the address just past the leading sequence of possibly
26 multi-byte characters or encoding errors G in STR that satisfy
27 PREDICATE (G) if OK is true, or that do not satisfy the predicate
28 call if OK is false. */
30 SKIPCHARS_INLINE
char *
31 skip_str_matching (char const *str
, bool (*predicate
) (mcel_t
), bool ok
)
34 for (mcel_t g
; *s
&& predicate (g
= mcel_scanz (s
)) == ok
;
40 /* Return the address just past the leading sequence of possibly
41 multi-byte characters or encoding errors G in BUF (which ends at LIM)
42 that satisfy PREDICATE (G) if OK is true, or that do not satisfy
43 the predicate call if OK is false. */
45 SKIPCHARS_INLINE
char *
46 skip_buf_matching (char const *buf
, char const *lim
,
47 bool (*predicate
) (mcel_t
), bool ok
)
50 for (mcel_t g
; s
< lim
&& predicate (g
= mcel_scan (s
, lim
)) == ok
;