1 /* Pattern Matchers - Common Utilities.
2    Copyright (C) 1992, 1998, 2000, 2005 Free Software Foundation, Inc.
3 
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 2, or (at your option)
7    any later version.
8 
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.
13 
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 Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17 
18 #include <stdbool.h>
19 #include <stddef.h>
20 #include <limits.h>
21 #include "kwset.h"
22 
23 #if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC
24 /* We can handle multibyte string.  */
25 # define MBS_SUPPORT
26 # include <wchar.h>
27 # include <wctype.h>
28 #endif
29 
30 #define NCHAR (UCHAR_MAX + 1)
31 
32 struct compiled_kwset {
33   kwset_t kwset;
34   char *trans;
35   bool match_words;
36   bool match_lines;
37   char eolbyte;
38 };
39 
40 extern void
41        kwsinit (struct compiled_kwset *ckwset,
42 		bool match_icase, bool match_words, bool match_lines,
43 		char eolbyte);
44 
45 #ifdef MBS_SUPPORT
46 extern char*
47        check_multibyte_string (const char *buf, size_t buf_size);
48 #endif
49 
50 #define IS_WORD_CONSTITUENT(C) (ISALNUM(C) || (C) == '_')
51