1 /* search.c - searching subroutines using dfa, kwset and regex for grep.
2 Copyright 1992, 1998, 2000, 2007, 2009-2015 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
20 #define GREP_SEARCH_H 1
24 #include <sys/types.h>
37 _GL_INLINE_HEADER_BEGIN
39 # define SEARCH_INLINE _GL_INLINE
42 /* This must be a signed type. Each value is the difference in the size
43 of a character (in bytes) induced by converting to lower case.
44 The vast majority of values are 0, but a few are 1 or -1, so
45 technically, two bits may be sufficient. */
46 typedef signed char mb_len_map_t;
49 extern void kwsinit (kwset_t *);
51 extern char *mbtoupper (char const *, size_t *, mb_len_map_t **);
52 extern void build_mbclen_cache (void);
53 extern size_t mbclen_cache[];
54 extern ptrdiff_t mb_goback (char const **, char const *, char const *);
55 extern wint_t mb_prev_wc (char const *, char const *, char const *);
56 extern wint_t mb_next_wc (char const *, char const *);
59 extern void GEAcompile (char const *, size_t, reg_syntax_t);
60 extern size_t EGexecute (char const *, size_t, size_t *, char const *);
63 extern void Fcompile (char const *, size_t);
64 extern size_t Fexecute (char const *, size_t, size_t *, char const *);
67 extern void Pcompile (char const *, size_t);
68 extern size_t Pexecute (char const *, size_t, size_t *, char const *);
70 /* Return the number of bytes in the character at the start of S, which
71 is of size N. N must be positive. MBS is the conversion state.
72 This acts like mbrlen, except it returns 1 when mbrlen would return 0,
73 and it is typically faster because of the cache. */
75 mb_clen (char const *s, size_t n, mbstate_t *mbs)
77 size_t len = mbclen_cache[to_uchar (*s)];
78 return len == (size_t) -2 ? mbrlen (s, n, mbs) : len;
83 #endif /* GREP_SEARCH_H */