]>
Commit | Line | Data |
---|---|---|
db3b92b4 CS |
1 | #ifndef ONIGURUMA_H\r |
2 | #define ONIGURUMA_H\r | |
3 | /**********************************************************************\r | |
4 | oniguruma.h - Oniguruma (regular expression library)\r | |
5 | **********************************************************************/\r | |
6 | /*-\r | |
7 | * Copyright (c) 2002-2009 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>\r | |
8 | * All rights reserved.\r | |
9 | *\r | |
10 | * Redistribution and use in source and binary forms, with or without\r | |
11 | * modification, are permitted provided that the following conditions\r | |
12 | * are met:\r | |
13 | * 1. Redistributions of source code must retain the above copyright\r | |
14 | * notice, this list of conditions and the following disclaimer.\r | |
15 | * 2. Redistributions in binary form must reproduce the above copyright\r | |
16 | * notice, this list of conditions and the following disclaimer in the\r | |
17 | * documentation and/or other materials provided with the distribution.\r | |
18 | *\r | |
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\r | |
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r | |
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r | |
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r | |
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r | |
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r | |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r | |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r | |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r | |
29 | * SUCH DAMAGE.\r | |
30 | */\r | |
31 | \r | |
32 | #include "OnigurumaUefiPort.h"\r | |
33 | \r | |
34 | #ifdef __cplusplus\r | |
35 | extern "C" {\r | |
36 | #endif\r | |
37 | \r | |
38 | #define ONIGURUMA\r | |
39 | #define ONIGURUMA_VERSION_MAJOR 5\r | |
40 | #define ONIGURUMA_VERSION_MINOR 9\r | |
41 | #define ONIGURUMA_VERSION_TEENY 6\r | |
42 | \r | |
43 | #ifdef __cplusplus\r | |
44 | # ifndef HAVE_PROTOTYPES\r | |
45 | # define HAVE_PROTOTYPES 1\r | |
46 | # endif\r | |
47 | # ifndef HAVE_STDARG_PROTOTYPES\r | |
48 | # define HAVE_STDARG_PROTOTYPES 1\r | |
49 | # endif\r | |
50 | #endif\r | |
51 | \r | |
52 | /* escape Mac OS X/Xcode 2.4/gcc 4.0.1 problem */\r | |
53 | #if defined(__APPLE__) && defined(__GNUC__) && __GNUC__ >= 4\r | |
54 | # ifndef HAVE_STDARG_PROTOTYPES\r | |
55 | # define HAVE_STDARG_PROTOTYPES 1\r | |
56 | # endif\r | |
57 | #endif\r | |
58 | \r | |
59 | #ifdef HAVE_STDARG_H\r | |
60 | # ifndef HAVE_STDARG_PROTOTYPES\r | |
61 | # define HAVE_STDARG_PROTOTYPES 1\r | |
62 | # endif\r | |
63 | #endif\r | |
64 | \r | |
65 | #ifndef P_\r | |
66 | #if defined(__STDC__) || defined(_WIN32)\r | |
67 | # define P_(args) args\r | |
68 | #else\r | |
69 | # define P_(args) ()\r | |
70 | #endif\r | |
71 | #endif\r | |
72 | \r | |
73 | #ifndef PV_\r | |
74 | #ifdef HAVE_STDARG_PROTOTYPES\r | |
75 | # define PV_(args) args\r | |
76 | #else\r | |
77 | # define PV_(args) ()\r | |
78 | #endif\r | |
79 | #endif\r | |
80 | \r | |
81 | #ifndef ONIG_EXTERN\r | |
82 | #if defined(_WIN32) && !defined(__GNUC__)\r | |
83 | #if defined(EXPORT) || defined(RUBY_EXPORT)\r | |
84 | #define ONIG_EXTERN extern __declspec(dllexport)\r | |
85 | #else\r | |
86 | #define ONIG_EXTERN extern __declspec(dllimport)\r | |
87 | #endif\r | |
88 | #endif\r | |
89 | #endif\r | |
90 | \r | |
91 | #ifndef ONIG_EXTERN\r | |
92 | #define ONIG_EXTERN extern\r | |
93 | #endif\r | |
94 | \r | |
95 | /* PART: character encoding */\r | |
96 | \r | |
97 | #ifndef ONIG_ESCAPE_UCHAR_COLLISION\r | |
98 | #define UChar OnigUChar\r | |
99 | #endif\r | |
100 | \r | |
101 | #ifdef _WIN32\r | |
102 | # include <windows.h>\r | |
103 | typedef ULONG_PTR OnigCodePoint;\r | |
104 | #else\r | |
105 | typedef unsigned long OnigCodePoint;\r | |
106 | #endif\r | |
107 | typedef unsigned char OnigUChar;\r | |
108 | typedef unsigned int OnigCtype;\r | |
109 | typedef unsigned int OnigDistance;\r | |
110 | \r | |
111 | #define ONIG_INFINITE_DISTANCE ~((OnigDistance )0)\r | |
112 | \r | |
113 | typedef unsigned int OnigCaseFoldType; /* case fold flag */\r | |
114 | \r | |
115 | ONIG_EXTERN OnigCaseFoldType OnigDefaultCaseFoldFlag;\r | |
116 | \r | |
117 | /* #define ONIGENC_CASE_FOLD_HIRAGANA_KATAKANA (1<<1) */\r | |
118 | /* #define ONIGENC_CASE_FOLD_KATAKANA_WIDTH (1<<2) */\r | |
119 | #define ONIGENC_CASE_FOLD_TURKISH_AZERI (1<<20)\r | |
120 | #define INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR (1<<30)\r | |
121 | \r | |
122 | #define ONIGENC_CASE_FOLD_MIN INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR\r | |
123 | #define ONIGENC_CASE_FOLD_DEFAULT OnigDefaultCaseFoldFlag\r | |
124 | \r | |
125 | \r | |
126 | #define ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN 3\r | |
127 | #define ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM 13\r | |
128 | /* 13 => Unicode:0x1ffc */\r | |
129 | \r | |
130 | /* code range */\r | |
131 | #define ONIGENC_CODE_RANGE_NUM(range) ((int )range[0])\r | |
132 | #define ONIGENC_CODE_RANGE_FROM(range,i) range[((i)*2) + 1]\r | |
133 | #define ONIGENC_CODE_RANGE_TO(range,i) range[((i)*2) + 2]\r | |
134 | \r | |
135 | typedef struct {\r | |
136 | int byte_len; /* argument(original) character(s) byte length */\r | |
137 | int code_len; /* number of code */\r | |
138 | OnigCodePoint code[ONIGENC_MAX_COMP_CASE_FOLD_CODE_LEN];\r | |
139 | } OnigCaseFoldCodeItem;\r | |
140 | \r | |
141 | typedef struct {\r | |
142 | OnigCodePoint esc;\r | |
143 | OnigCodePoint anychar;\r | |
144 | OnigCodePoint anytime;\r | |
145 | OnigCodePoint zero_or_one_time;\r | |
146 | OnigCodePoint one_or_more_time;\r | |
147 | OnigCodePoint anychar_anytime;\r | |
148 | } OnigMetaCharTableType;\r | |
149 | \r | |
150 | typedef int (*OnigApplyAllCaseFoldFunc)(OnigCodePoint from, OnigCodePoint* to, int to_len, void* arg);\r | |
151 | \r | |
152 | typedef struct OnigEncodingTypeST {\r | |
153 | int (*mbc_enc_len)(const OnigUChar* p);\r | |
154 | const char* name;\r | |
155 | int max_enc_len;\r | |
156 | int min_enc_len;\r | |
157 | int (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end);\r | |
158 | OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end);\r | |
159 | int (*code_to_mbclen)(OnigCodePoint code);\r | |
160 | int (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf);\r | |
161 | int (*mbc_case_fold)(OnigCaseFoldType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to);\r | |
162 | int (*apply_all_case_fold)(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg);\r | |
163 | int (*get_case_fold_codes_by_str)(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem acs[]);\r | |
164 | int (*property_name_to_ctype)(struct OnigEncodingTypeST* enc, OnigUChar* p, OnigUChar* end);\r | |
165 | int (*is_code_ctype)(OnigCodePoint code, OnigCtype ctype);\r | |
166 | int (*get_ctype_code_range)(OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[]);\r | |
167 | OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p);\r | |
168 | int (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end);\r | |
169 | } OnigEncodingType;\r | |
170 | \r | |
171 | typedef OnigEncodingType* OnigEncoding;\r | |
172 | \r | |
173 | ONIG_EXTERN OnigEncodingType OnigEncodingASCII;\r | |
174 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_1;\r | |
175 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_2;\r | |
176 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_3;\r | |
177 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_4;\r | |
178 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_5;\r | |
179 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_6;\r | |
180 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_7;\r | |
181 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_8;\r | |
182 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_9;\r | |
183 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_10;\r | |
184 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_11;\r | |
185 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_13;\r | |
186 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_14;\r | |
187 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_15;\r | |
188 | ONIG_EXTERN OnigEncodingType OnigEncodingISO_8859_16;\r | |
189 | ONIG_EXTERN OnigEncodingType OnigEncodingUTF8;\r | |
190 | ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_BE;\r | |
191 | ONIG_EXTERN OnigEncodingType OnigEncodingUTF16_LE;\r | |
192 | ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_BE;\r | |
193 | ONIG_EXTERN OnigEncodingType OnigEncodingUTF32_LE;\r | |
194 | ONIG_EXTERN OnigEncodingType OnigEncodingEUC_JP;\r | |
195 | ONIG_EXTERN OnigEncodingType OnigEncodingEUC_TW;\r | |
196 | ONIG_EXTERN OnigEncodingType OnigEncodingEUC_KR;\r | |
197 | ONIG_EXTERN OnigEncodingType OnigEncodingEUC_CN;\r | |
198 | ONIG_EXTERN OnigEncodingType OnigEncodingSJIS;\r | |
199 | ONIG_EXTERN OnigEncodingType OnigEncodingKOI8;\r | |
200 | ONIG_EXTERN OnigEncodingType OnigEncodingKOI8_R;\r | |
201 | ONIG_EXTERN OnigEncodingType OnigEncodingCP1251;\r | |
202 | ONIG_EXTERN OnigEncodingType OnigEncodingBIG5;\r | |
203 | ONIG_EXTERN OnigEncodingType OnigEncodingGB18030;\r | |
204 | \r | |
205 | #define ONIG_ENCODING_ASCII (&OnigEncodingASCII)\r | |
206 | #define ONIG_ENCODING_ISO_8859_1 (&OnigEncodingISO_8859_1)\r | |
207 | #define ONIG_ENCODING_ISO_8859_2 (&OnigEncodingISO_8859_2)\r | |
208 | #define ONIG_ENCODING_ISO_8859_3 (&OnigEncodingISO_8859_3)\r | |
209 | #define ONIG_ENCODING_ISO_8859_4 (&OnigEncodingISO_8859_4)\r | |
210 | #define ONIG_ENCODING_ISO_8859_5 (&OnigEncodingISO_8859_5)\r | |
211 | #define ONIG_ENCODING_ISO_8859_6 (&OnigEncodingISO_8859_6)\r | |
212 | #define ONIG_ENCODING_ISO_8859_7 (&OnigEncodingISO_8859_7)\r | |
213 | #define ONIG_ENCODING_ISO_8859_8 (&OnigEncodingISO_8859_8)\r | |
214 | #define ONIG_ENCODING_ISO_8859_9 (&OnigEncodingISO_8859_9)\r | |
215 | #define ONIG_ENCODING_ISO_8859_10 (&OnigEncodingISO_8859_10)\r | |
216 | #define ONIG_ENCODING_ISO_8859_11 (&OnigEncodingISO_8859_11)\r | |
217 | #define ONIG_ENCODING_ISO_8859_13 (&OnigEncodingISO_8859_13)\r | |
218 | #define ONIG_ENCODING_ISO_8859_14 (&OnigEncodingISO_8859_14)\r | |
219 | #define ONIG_ENCODING_ISO_8859_15 (&OnigEncodingISO_8859_15)\r | |
220 | #define ONIG_ENCODING_ISO_8859_16 (&OnigEncodingISO_8859_16)\r | |
221 | #define ONIG_ENCODING_UTF8 (&OnigEncodingUTF8)\r | |
222 | #define ONIG_ENCODING_UTF16_BE (&OnigEncodingUTF16_BE)\r | |
223 | #define ONIG_ENCODING_UTF16_LE (&OnigEncodingUTF16_LE)\r | |
224 | #define ONIG_ENCODING_UTF32_BE (&OnigEncodingUTF32_BE)\r | |
225 | #define ONIG_ENCODING_UTF32_LE (&OnigEncodingUTF32_LE)\r | |
226 | #define ONIG_ENCODING_EUC_JP (&OnigEncodingEUC_JP)\r | |
227 | #define ONIG_ENCODING_EUC_TW (&OnigEncodingEUC_TW)\r | |
228 | #define ONIG_ENCODING_EUC_KR (&OnigEncodingEUC_KR)\r | |
229 | #define ONIG_ENCODING_EUC_CN (&OnigEncodingEUC_CN)\r | |
230 | #define ONIG_ENCODING_SJIS (&OnigEncodingSJIS)\r | |
231 | #define ONIG_ENCODING_KOI8 (&OnigEncodingKOI8)\r | |
232 | #define ONIG_ENCODING_KOI8_R (&OnigEncodingKOI8_R)\r | |
233 | #define ONIG_ENCODING_CP1251 (&OnigEncodingCP1251)\r | |
234 | #define ONIG_ENCODING_BIG5 (&OnigEncodingBIG5)\r | |
235 | #define ONIG_ENCODING_GB18030 (&OnigEncodingGB18030)\r | |
236 | \r | |
237 | #define ONIG_ENCODING_UNDEF ((OnigEncoding )0)\r | |
238 | \r | |
239 | \r | |
240 | /* work size */\r | |
241 | #define ONIGENC_CODE_TO_MBC_MAXLEN 7\r | |
242 | #define ONIGENC_MBC_CASE_FOLD_MAXLEN 18\r | |
243 | /* 18: 6(max-byte) * 3(case-fold chars) */\r | |
244 | \r | |
245 | /* character types */\r | |
246 | #define ONIGENC_CTYPE_NEWLINE 0\r | |
247 | #define ONIGENC_CTYPE_ALPHA 1\r | |
248 | #define ONIGENC_CTYPE_BLANK 2\r | |
249 | #define ONIGENC_CTYPE_CNTRL 3\r | |
250 | #define ONIGENC_CTYPE_DIGIT 4\r | |
251 | #define ONIGENC_CTYPE_GRAPH 5\r | |
252 | #define ONIGENC_CTYPE_LOWER 6\r | |
253 | #define ONIGENC_CTYPE_PRINT 7\r | |
254 | #define ONIGENC_CTYPE_PUNCT 8\r | |
255 | #define ONIGENC_CTYPE_SPACE 9\r | |
256 | #define ONIGENC_CTYPE_UPPER 10\r | |
257 | #define ONIGENC_CTYPE_XDIGIT 11\r | |
258 | #define ONIGENC_CTYPE_WORD 12\r | |
259 | #define ONIGENC_CTYPE_ALNUM 13 /* alpha || digit */\r | |
260 | #define ONIGENC_CTYPE_ASCII 14\r | |
261 | #define ONIGENC_MAX_STD_CTYPE ONIGENC_CTYPE_ASCII\r | |
262 | \r | |
263 | \r | |
264 | #define onig_enc_len(enc,p,end) ONIGENC_MBC_ENC_LEN(enc,p)\r | |
265 | \r | |
266 | #define ONIGENC_IS_UNDEF(enc) ((enc) == ONIG_ENCODING_UNDEF)\r | |
267 | #define ONIGENC_IS_SINGLEBYTE(enc) (ONIGENC_MBC_MAXLEN(enc) == 1)\r | |
268 | #define ONIGENC_IS_MBC_HEAD(enc,p) (ONIGENC_MBC_ENC_LEN(enc,p) != 1)\r | |
269 | #define ONIGENC_IS_MBC_ASCII(p) (*(p) < 128)\r | |
270 | #define ONIGENC_IS_CODE_ASCII(code) ((code) < 128)\r | |
271 | #define ONIGENC_IS_MBC_WORD(enc,s,end) \\r | |
272 | ONIGENC_IS_CODE_WORD(enc,ONIGENC_MBC_TO_CODE(enc,s,end))\r | |
273 | \r | |
274 | \r | |
275 | #define ONIGENC_NAME(enc) ((enc)->name)\r | |
276 | \r | |
277 | #define ONIGENC_MBC_CASE_FOLD(enc,flag,pp,end,buf) \\r | |
278 | (enc)->mbc_case_fold(flag,(const OnigUChar** )pp,end,buf)\r | |
279 | #define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \\r | |
280 | (enc)->is_allowed_reverse_match(s,end)\r | |
281 | #define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,start,s) \\r | |
282 | (enc)->left_adjust_char_head(start, s)\r | |
283 | #define ONIGENC_APPLY_ALL_CASE_FOLD(enc,case_fold_flag,f,arg) \\r | |
284 | (enc)->apply_all_case_fold(case_fold_flag,f,arg)\r | |
285 | #define ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc,case_fold_flag,p,end,acs) \\r | |
286 | (enc)->get_case_fold_codes_by_str(case_fold_flag,p,end,acs)\r | |
287 | #define ONIGENC_STEP_BACK(enc,start,s,n) \\r | |
288 | onigenc_step_back((enc),(start),(s),(n))\r | |
289 | \r | |
290 | #define ONIGENC_MBC_ENC_LEN(enc,p) (enc)->mbc_enc_len(p)\r | |
291 | #define ONIGENC_MBC_MAXLEN(enc) ((enc)->max_enc_len)\r | |
292 | #define ONIGENC_MBC_MAXLEN_DIST(enc) ONIGENC_MBC_MAXLEN(enc)\r | |
293 | #define ONIGENC_MBC_MINLEN(enc) ((enc)->min_enc_len)\r | |
294 | #define ONIGENC_IS_MBC_NEWLINE(enc,p,end) (enc)->is_mbc_newline((p),(end))\r | |
295 | #define ONIGENC_MBC_TO_CODE(enc,p,end) (enc)->mbc_to_code((p),(end))\r | |
296 | #define ONIGENC_CODE_TO_MBCLEN(enc,code) (enc)->code_to_mbclen(code)\r | |
297 | #define ONIGENC_CODE_TO_MBC(enc,code,buf) (enc)->code_to_mbc(code,buf)\r | |
298 | #define ONIGENC_PROPERTY_NAME_TO_CTYPE(enc,p,end) \\r | |
299 | (enc)->property_name_to_ctype(enc,p,end)\r | |
300 | \r | |
301 | #define ONIGENC_IS_CODE_CTYPE(enc,code,ctype) (enc)->is_code_ctype(code,ctype)\r | |
302 | \r | |
303 | #define ONIGENC_IS_CODE_NEWLINE(enc,code) \\r | |
304 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_NEWLINE)\r | |
305 | #define ONIGENC_IS_CODE_GRAPH(enc,code) \\r | |
306 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_GRAPH)\r | |
307 | #define ONIGENC_IS_CODE_PRINT(enc,code) \\r | |
308 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PRINT)\r | |
309 | #define ONIGENC_IS_CODE_ALNUM(enc,code) \\r | |
310 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALNUM)\r | |
311 | #define ONIGENC_IS_CODE_ALPHA(enc,code) \\r | |
312 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_ALPHA)\r | |
313 | #define ONIGENC_IS_CODE_LOWER(enc,code) \\r | |
314 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_LOWER)\r | |
315 | #define ONIGENC_IS_CODE_UPPER(enc,code) \\r | |
316 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_UPPER)\r | |
317 | #define ONIGENC_IS_CODE_CNTRL(enc,code) \\r | |
318 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_CNTRL)\r | |
319 | #define ONIGENC_IS_CODE_PUNCT(enc,code) \\r | |
320 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_PUNCT)\r | |
321 | #define ONIGENC_IS_CODE_SPACE(enc,code) \\r | |
322 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_SPACE)\r | |
323 | #define ONIGENC_IS_CODE_BLANK(enc,code) \\r | |
324 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_BLANK)\r | |
325 | #define ONIGENC_IS_CODE_DIGIT(enc,code) \\r | |
326 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_DIGIT)\r | |
327 | #define ONIGENC_IS_CODE_XDIGIT(enc,code) \\r | |
328 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_XDIGIT)\r | |
329 | #define ONIGENC_IS_CODE_WORD(enc,code) \\r | |
330 | ONIGENC_IS_CODE_CTYPE(enc,code,ONIGENC_CTYPE_WORD)\r | |
331 | \r | |
332 | #define ONIGENC_GET_CTYPE_CODE_RANGE(enc,ctype,sbout,ranges) \\r | |
333 | (enc)->get_ctype_code_range(ctype,sbout,ranges)\r | |
334 | \r | |
335 | ONIG_EXTERN\r | |
336 | OnigUChar* onigenc_step_back P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, int n));\r | |
337 | \r | |
338 | \r | |
339 | /* encoding API */\r | |
340 | ONIG_EXTERN\r | |
341 | int onigenc_init P_((void));\r | |
342 | ONIG_EXTERN\r | |
343 | int onigenc_set_default_encoding P_((OnigEncoding enc));\r | |
344 | ONIG_EXTERN\r | |
345 | OnigEncoding onigenc_get_default_encoding P_((void));\r | |
346 | ONIG_EXTERN\r | |
347 | void onigenc_set_default_caseconv_table P_((const OnigUChar* table));\r | |
348 | ONIG_EXTERN\r | |
349 | OnigUChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar** prev));\r | |
350 | ONIG_EXTERN\r | |
351 | OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));\r | |
352 | ONIG_EXTERN\r | |
353 | OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));\r | |
354 | ONIG_EXTERN\r | |
355 | OnigUChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));\r | |
356 | ONIG_EXTERN\r | |
357 | int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end));\r | |
358 | ONIG_EXTERN\r | |
359 | int onigenc_strlen_null P_((OnigEncoding enc, const OnigUChar* p));\r | |
360 | ONIG_EXTERN\r | |
361 | int onigenc_str_bytelen_null P_((OnigEncoding enc, const OnigUChar* p));\r | |
362 | \r | |
363 | \r | |
364 | \r | |
365 | /* PART: regular expression */\r | |
366 | \r | |
367 | /* config parameters */\r | |
368 | #define ONIG_NREGION 10\r | |
369 | #define ONIG_MAX_BACKREF_NUM 1000\r | |
370 | #define ONIG_MAX_REPEAT_NUM 100000\r | |
371 | #define ONIG_MAX_MULTI_BYTE_RANGES_NUM 10000\r | |
372 | /* constants */\r | |
373 | #define ONIG_MAX_ERROR_MESSAGE_LEN 90\r | |
374 | \r | |
375 | typedef unsigned int OnigOptionType;\r | |
376 | \r | |
377 | #define ONIG_OPTION_DEFAULT ONIG_OPTION_NONE\r | |
378 | \r | |
379 | /* options */\r | |
380 | #define ONIG_OPTION_NONE 0U\r | |
381 | #define ONIG_OPTION_IGNORECASE 1U\r | |
382 | #define ONIG_OPTION_EXTEND (ONIG_OPTION_IGNORECASE << 1)\r | |
383 | #define ONIG_OPTION_MULTILINE (ONIG_OPTION_EXTEND << 1)\r | |
384 | #define ONIG_OPTION_SINGLELINE (ONIG_OPTION_MULTILINE << 1)\r | |
385 | #define ONIG_OPTION_FIND_LONGEST (ONIG_OPTION_SINGLELINE << 1)\r | |
386 | #define ONIG_OPTION_FIND_NOT_EMPTY (ONIG_OPTION_FIND_LONGEST << 1)\r | |
387 | #define ONIG_OPTION_NEGATE_SINGLELINE (ONIG_OPTION_FIND_NOT_EMPTY << 1)\r | |
388 | #define ONIG_OPTION_DONT_CAPTURE_GROUP (ONIG_OPTION_NEGATE_SINGLELINE << 1)\r | |
389 | #define ONIG_OPTION_CAPTURE_GROUP (ONIG_OPTION_DONT_CAPTURE_GROUP << 1)\r | |
390 | /* options (search time) */\r | |
391 | #define ONIG_OPTION_NOTBOL (ONIG_OPTION_CAPTURE_GROUP << 1)\r | |
392 | #define ONIG_OPTION_NOTEOL (ONIG_OPTION_NOTBOL << 1)\r | |
393 | #define ONIG_OPTION_POSIX_REGION (ONIG_OPTION_NOTEOL << 1)\r | |
394 | #define ONIG_OPTION_MAXBIT ONIG_OPTION_POSIX_REGION /* limit */\r | |
395 | \r | |
396 | #define ONIG_OPTION_ON(options,regopt) ((options) |= (regopt))\r | |
397 | #define ONIG_OPTION_OFF(options,regopt) ((options) &= ~(regopt))\r | |
398 | #define ONIG_IS_OPTION_ON(options,option) ((options) & (option))\r | |
399 | \r | |
400 | /* syntax */\r | |
401 | typedef struct {\r | |
402 | unsigned int op;\r | |
403 | unsigned int op2;\r | |
404 | unsigned int behavior;\r | |
405 | OnigOptionType options; /* default option */\r | |
406 | OnigMetaCharTableType meta_char_table;\r | |
407 | } OnigSyntaxType;\r | |
408 | \r | |
409 | ONIG_EXTERN OnigSyntaxType OnigSyntaxASIS;\r | |
410 | ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;\r | |
411 | ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;\r | |
412 | ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;\r | |
413 | ONIG_EXTERN OnigSyntaxType OnigSyntaxGrep;\r | |
414 | ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;\r | |
415 | ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;\r | |
416 | ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;\r | |
417 | ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl_NG;\r | |
418 | ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;\r | |
419 | \r | |
420 | /* predefined syntaxes (see regsyntax.c) */\r | |
421 | #define ONIG_SYNTAX_ASIS (&OnigSyntaxASIS)\r | |
422 | #define ONIG_SYNTAX_POSIX_BASIC (&OnigSyntaxPosixBasic)\r | |
423 | #define ONIG_SYNTAX_POSIX_EXTENDED (&OnigSyntaxPosixExtended)\r | |
424 | #define ONIG_SYNTAX_EMACS (&OnigSyntaxEmacs)\r | |
425 | #define ONIG_SYNTAX_GREP (&OnigSyntaxGrep)\r | |
426 | #define ONIG_SYNTAX_GNU_REGEX (&OnigSyntaxGnuRegex)\r | |
427 | #define ONIG_SYNTAX_JAVA (&OnigSyntaxJava)\r | |
428 | #define ONIG_SYNTAX_PERL (&OnigSyntaxPerl)\r | |
429 | #define ONIG_SYNTAX_PERL_NG (&OnigSyntaxPerl_NG)\r | |
430 | #define ONIG_SYNTAX_RUBY (&OnigSyntaxRuby)\r | |
431 | \r | |
432 | /* default syntax */\r | |
433 | ONIG_EXTERN OnigSyntaxType* OnigDefaultSyntax;\r | |
434 | #define ONIG_SYNTAX_DEFAULT OnigDefaultSyntax\r | |
435 | \r | |
436 | /* syntax (operators) */\r | |
437 | #define ONIG_SYN_OP_VARIABLE_META_CHARACTERS (1U<<0)\r | |
438 | #define ONIG_SYN_OP_DOT_ANYCHAR (1U<<1) /* . */\r | |
439 | #define ONIG_SYN_OP_ASTERISK_ZERO_INF (1U<<2) /* * */\r | |
440 | #define ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF (1U<<3)\r | |
441 | #define ONIG_SYN_OP_PLUS_ONE_INF (1U<<4) /* + */\r | |
442 | #define ONIG_SYN_OP_ESC_PLUS_ONE_INF (1U<<5)\r | |
443 | #define ONIG_SYN_OP_QMARK_ZERO_ONE (1U<<6) /* ? */\r | |
444 | #define ONIG_SYN_OP_ESC_QMARK_ZERO_ONE (1U<<7)\r | |
445 | #define ONIG_SYN_OP_BRACE_INTERVAL (1U<<8) /* {lower,upper} */\r | |
446 | #define ONIG_SYN_OP_ESC_BRACE_INTERVAL (1U<<9) /* \{lower,upper\} */\r | |
447 | #define ONIG_SYN_OP_VBAR_ALT (1U<<10) /* | */\r | |
448 | #define ONIG_SYN_OP_ESC_VBAR_ALT (1U<<11) /* \| */\r | |
449 | #define ONIG_SYN_OP_LPAREN_SUBEXP (1U<<12) /* (...) */\r | |
450 | #define ONIG_SYN_OP_ESC_LPAREN_SUBEXP (1U<<13) /* \(...\) */\r | |
451 | #define ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR (1U<<14) /* \A, \Z, \z */\r | |
452 | #define ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR (1U<<15) /* \G */\r | |
453 | #define ONIG_SYN_OP_DECIMAL_BACKREF (1U<<16) /* \num */\r | |
454 | #define ONIG_SYN_OP_BRACKET_CC (1U<<17) /* [...] */\r | |
455 | #define ONIG_SYN_OP_ESC_W_WORD (1U<<18) /* \w, \W */\r | |
456 | #define ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END (1U<<19) /* \<. \> */\r | |
457 | #define ONIG_SYN_OP_ESC_B_WORD_BOUND (1U<<20) /* \b, \B */\r | |
458 | #define ONIG_SYN_OP_ESC_S_WHITE_SPACE (1U<<21) /* \s, \S */\r | |
459 | #define ONIG_SYN_OP_ESC_D_DIGIT (1U<<22) /* \d, \D */\r | |
460 | #define ONIG_SYN_OP_LINE_ANCHOR (1U<<23) /* ^, $ */\r | |
461 | #define ONIG_SYN_OP_POSIX_BRACKET (1U<<24) /* [:xxxx:] */\r | |
462 | #define ONIG_SYN_OP_QMARK_NON_GREEDY (1U<<25) /* ??,*?,+?,{n,m}? */\r | |
463 | #define ONIG_SYN_OP_ESC_CONTROL_CHARS (1U<<26) /* \n,\r,\t,\a ... */\r | |
464 | #define ONIG_SYN_OP_ESC_C_CONTROL (1U<<27) /* \cx */\r | |
465 | #define ONIG_SYN_OP_ESC_OCTAL3 (1U<<28) /* \OOO */\r | |
466 | #define ONIG_SYN_OP_ESC_X_HEX2 (1U<<29) /* \xHH */\r | |
467 | #define ONIG_SYN_OP_ESC_X_BRACE_HEX8 (1U<<30) /* \x{7HHHHHHH} */\r | |
468 | \r | |
469 | #define ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE (1U<<0) /* \Q...\E */\r | |
470 | #define ONIG_SYN_OP2_QMARK_GROUP_EFFECT (1U<<1) /* (?...) */\r | |
471 | #define ONIG_SYN_OP2_OPTION_PERL (1U<<2) /* (?imsx),(?-imsx) */\r | |
472 | #define ONIG_SYN_OP2_OPTION_RUBY (1U<<3) /* (?imx), (?-imx) */\r | |
473 | #define ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT (1U<<4) /* ?+,*+,++ */\r | |
474 | #define ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL (1U<<5) /* {n,m}+ */\r | |
475 | #define ONIG_SYN_OP2_CCLASS_SET_OP (1U<<6) /* [...&&..[..]..] */\r | |
476 | #define ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP (1U<<7) /* (?<name>...) */\r | |
477 | #define ONIG_SYN_OP2_ESC_K_NAMED_BACKREF (1U<<8) /* \k<name> */\r | |
478 | #define ONIG_SYN_OP2_ESC_G_SUBEXP_CALL (1U<<9) /* \g<name>, \g<n> */\r | |
479 | #define ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY (1U<<10) /* (?@..),(?@<x>..) */\r | |
480 | #define ONIG_SYN_OP2_ESC_CAPITAL_C_BAR_CONTROL (1U<<11) /* \C-x */\r | |
481 | #define ONIG_SYN_OP2_ESC_CAPITAL_M_BAR_META (1U<<12) /* \M-x */\r | |
482 | #define ONIG_SYN_OP2_ESC_V_VTAB (1U<<13) /* \v as VTAB */\r | |
483 | #define ONIG_SYN_OP2_ESC_U_HEX4 (1U<<14) /* \uHHHH */\r | |
484 | #define ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR (1U<<15) /* \`, \' */\r | |
485 | #define ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY (1U<<16) /* \p{...}, \P{...} */\r | |
486 | #define ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT (1U<<17) /* \p{^..}, \P{^..} */\r | |
487 | /* #define ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS (1U<<18) */\r | |
488 | #define ONIG_SYN_OP2_ESC_H_XDIGIT (1U<<19) /* \h, \H */\r | |
489 | #define ONIG_SYN_OP2_INEFFECTIVE_ESCAPE (1U<<20) /* \ */\r | |
490 | \r | |
491 | /* syntax (behavior) */\r | |
492 | #define ONIG_SYN_CONTEXT_INDEP_ANCHORS (1U<<31) /* not implemented */\r | |
493 | #define ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS (1U<<0) /* ?, *, +, {n,m} */\r | |
494 | #define ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS (1U<<1) /* error or ignore */\r | |
495 | #define ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP (1U<<2) /* ...)... */\r | |
496 | #define ONIG_SYN_ALLOW_INVALID_INTERVAL (1U<<3) /* {??? */\r | |
497 | #define ONIG_SYN_ALLOW_INTERVAL_LOW_ABBREV (1U<<4) /* {,n} => {0,n} */\r | |
498 | #define ONIG_SYN_STRICT_CHECK_BACKREF (1U<<5) /* /(\1)/,/\1()/ ..*/\r | |
499 | #define ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND (1U<<6) /* (?<=a|bc) */\r | |
500 | #define ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP (1U<<7) /* see doc/RE */\r | |
501 | #define ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME (1U<<8) /* (?<x>)(?<x>) */\r | |
502 | #define ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY (1U<<9) /* a{n}?=(?:a{n})? */\r | |
503 | \r | |
504 | /* syntax (behavior) in char class [...] */\r | |
505 | #define ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC (1U<<20) /* [^...] */\r | |
506 | #define ONIG_SYN_BACKSLASH_ESCAPE_IN_CC (1U<<21) /* [..\w..] etc.. */\r | |
507 | #define ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC (1U<<22)\r | |
508 | #define ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC (1U<<23) /* [0-9-a]=[0-9\-a] */\r | |
509 | /* syntax (behavior) warning */\r | |
510 | #define ONIG_SYN_WARN_CC_OP_NOT_ESCAPED (1U<<24) /* [,-,] */\r | |
511 | #define ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT (1U<<25) /* (?:a*)+ */\r | |
512 | \r | |
513 | /* meta character specifiers (onig_set_meta_char()) */\r | |
514 | #define ONIG_META_CHAR_ESCAPE 0\r | |
515 | #define ONIG_META_CHAR_ANYCHAR 1\r | |
516 | #define ONIG_META_CHAR_ANYTIME 2\r | |
517 | #define ONIG_META_CHAR_ZERO_OR_ONE_TIME 3\r | |
518 | #define ONIG_META_CHAR_ONE_OR_MORE_TIME 4\r | |
519 | #define ONIG_META_CHAR_ANYCHAR_ANYTIME 5\r | |
520 | \r | |
521 | #define ONIG_INEFFECTIVE_META_CHAR 0\r | |
522 | \r | |
523 | /* error codes */\r | |
524 | #define ONIG_IS_PATTERN_ERROR(ecode) ((ecode) <= -100 && (ecode) > -1000)\r | |
525 | /* normal return */\r | |
526 | #define ONIG_NORMAL 0\r | |
527 | #define ONIG_MISMATCH -1\r | |
528 | #define ONIG_NO_SUPPORT_CONFIG -2\r | |
529 | \r | |
530 | /* internal error */\r | |
531 | #define ONIGERR_MEMORY -5\r | |
532 | #define ONIGERR_TYPE_BUG -6\r | |
533 | #define ONIGERR_PARSER_BUG -11\r | |
534 | #define ONIGERR_STACK_BUG -12\r | |
535 | #define ONIGERR_UNDEFINED_BYTECODE -13\r | |
536 | #define ONIGERR_UNEXPECTED_BYTECODE -14\r | |
537 | #define ONIGERR_MATCH_STACK_LIMIT_OVER -15\r | |
538 | #define ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED -21\r | |
539 | #define ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR -22\r | |
540 | /* general error */\r | |
541 | #define ONIGERR_INVALID_ARGUMENT -30 \r | |
542 | /* syntax error */\r | |
543 | #define ONIGERR_END_PATTERN_AT_LEFT_BRACE -100\r | |
544 | #define ONIGERR_END_PATTERN_AT_LEFT_BRACKET -101\r | |
545 | #define ONIGERR_EMPTY_CHAR_CLASS -102\r | |
546 | #define ONIGERR_PREMATURE_END_OF_CHAR_CLASS -103\r | |
547 | #define ONIGERR_END_PATTERN_AT_ESCAPE -104\r | |
548 | #define ONIGERR_END_PATTERN_AT_META -105\r | |
549 | #define ONIGERR_END_PATTERN_AT_CONTROL -106\r | |
550 | #define ONIGERR_META_CODE_SYNTAX -108\r | |
551 | #define ONIGERR_CONTROL_CODE_SYNTAX -109\r | |
552 | #define ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE -110\r | |
553 | #define ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE -111\r | |
554 | #define ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS -112\r | |
555 | #define ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED -113\r | |
556 | #define ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID -114\r | |
557 | #define ONIGERR_NESTED_REPEAT_OPERATOR -115\r | |
558 | #define ONIGERR_UNMATCHED_CLOSE_PARENTHESIS -116\r | |
559 | #define ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS -117\r | |
560 | #define ONIGERR_END_PATTERN_IN_GROUP -118\r | |
561 | #define ONIGERR_UNDEFINED_GROUP_OPTION -119\r | |
562 | #define ONIGERR_INVALID_POSIX_BRACKET_TYPE -121\r | |
563 | #define ONIGERR_INVALID_LOOK_BEHIND_PATTERN -122\r | |
564 | #define ONIGERR_INVALID_REPEAT_RANGE_PATTERN -123\r | |
565 | /* values error (syntax error) */\r | |
566 | #define ONIGERR_TOO_BIG_NUMBER -200\r | |
567 | #define ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE -201\r | |
568 | #define ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE -202\r | |
569 | #define ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS -203\r | |
570 | #define ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE -204\r | |
571 | #define ONIGERR_TOO_MANY_MULTI_BYTE_RANGES -205\r | |
572 | #define ONIGERR_TOO_SHORT_MULTI_BYTE_STRING -206\r | |
573 | #define ONIGERR_TOO_BIG_BACKREF_NUMBER -207\r | |
574 | #define ONIGERR_INVALID_BACKREF -208\r | |
575 | #define ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED -209\r | |
576 | #define ONIGERR_TOO_LONG_WIDE_CHAR_VALUE -212\r | |
577 | #define ONIGERR_EMPTY_GROUP_NAME -214\r | |
578 | #define ONIGERR_INVALID_GROUP_NAME -215\r | |
579 | #define ONIGERR_INVALID_CHAR_IN_GROUP_NAME -216\r | |
580 | #define ONIGERR_UNDEFINED_NAME_REFERENCE -217\r | |
581 | #define ONIGERR_UNDEFINED_GROUP_REFERENCE -218\r | |
582 | #define ONIGERR_MULTIPLEX_DEFINED_NAME -219\r | |
583 | #define ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL -220\r | |
584 | #define ONIGERR_NEVER_ENDING_RECURSION -221\r | |
585 | #define ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY -222\r | |
586 | #define ONIGERR_INVALID_CHAR_PROPERTY_NAME -223\r | |
587 | #define ONIGERR_INVALID_CODE_POINT_VALUE -400\r | |
588 | #define ONIGERR_INVALID_WIDE_CHAR_VALUE -400\r | |
589 | #define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE -401\r | |
590 | #define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION -402\r | |
591 | #define ONIGERR_INVALID_COMBINATION_OF_OPTIONS -403\r | |
592 | \r | |
593 | /* errors related to thread */\r | |
594 | #define ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT -1001\r | |
595 | \r | |
596 | \r | |
597 | /* must be smaller than BIT_STATUS_BITS_NUM (unsigned int * 8) */\r | |
598 | #define ONIG_MAX_CAPTURE_HISTORY_GROUP 31\r | |
599 | #define ONIG_IS_CAPTURE_HISTORY_GROUP(r, i) \\r | |
600 | ((i) <= ONIG_MAX_CAPTURE_HISTORY_GROUP && (r)->list && (r)->list[i])\r | |
601 | \r | |
602 | typedef struct OnigCaptureTreeNodeStruct {\r | |
603 | int group; /* group number */\r | |
604 | int beg;\r | |
605 | int end;\r | |
606 | int allocated;\r | |
607 | int num_childs;\r | |
608 | struct OnigCaptureTreeNodeStruct** childs;\r | |
609 | } OnigCaptureTreeNode;\r | |
610 | \r | |
611 | /* match result region type */\r | |
612 | struct re_registers {\r | |
613 | int allocated;\r | |
614 | int num_regs;\r | |
615 | int* beg;\r | |
616 | int* end;\r | |
617 | /* extended */\r | |
618 | OnigCaptureTreeNode* history_root; /* capture history tree root */\r | |
619 | };\r | |
620 | \r | |
621 | /* capture tree traverse */\r | |
622 | #define ONIG_TRAVERSE_CALLBACK_AT_FIRST 1\r | |
623 | #define ONIG_TRAVERSE_CALLBACK_AT_LAST 2\r | |
624 | #define ONIG_TRAVERSE_CALLBACK_AT_BOTH \\r | |
625 | ( ONIG_TRAVERSE_CALLBACK_AT_FIRST | ONIG_TRAVERSE_CALLBACK_AT_LAST )\r | |
626 | \r | |
627 | \r | |
628 | #define ONIG_REGION_NOTPOS -1\r | |
629 | \r | |
630 | typedef struct re_registers OnigRegion;\r | |
631 | \r | |
632 | typedef struct {\r | |
633 | OnigEncoding enc;\r | |
634 | OnigUChar* par;\r | |
635 | OnigUChar* par_end;\r | |
636 | } OnigErrorInfo;\r | |
637 | \r | |
638 | typedef struct {\r | |
639 | int lower;\r | |
640 | int upper;\r | |
641 | } OnigRepeatRange;\r | |
642 | \r | |
643 | typedef void (*OnigWarnFunc) P_((const char* s));\r | |
644 | extern void onig_null_warn P_((const char* s));\r | |
645 | #define ONIG_NULL_WARN onig_null_warn\r | |
646 | \r | |
647 | #define ONIG_CHAR_TABLE_SIZE 256\r | |
648 | \r | |
649 | /* regex_t state */\r | |
650 | #define ONIG_STATE_NORMAL 0\r | |
651 | #define ONIG_STATE_SEARCHING 1\r | |
652 | #define ONIG_STATE_COMPILING -1\r | |
653 | #define ONIG_STATE_MODIFY -2\r | |
654 | \r | |
655 | #define ONIG_STATE(reg) \\r | |
656 | ((reg)->state > 0 ? ONIG_STATE_SEARCHING : (reg)->state)\r | |
657 | \r | |
658 | typedef struct re_pattern_buffer {\r | |
659 | /* common members of BBuf(bytes-buffer) */\r | |
660 | unsigned char* p; /* compiled pattern */\r | |
661 | unsigned int used; /* used space for p */\r | |
662 | unsigned int alloc; /* allocated space for p */\r | |
663 | \r | |
664 | int state; /* normal, searching, compiling */\r | |
665 | int num_mem; /* used memory(...) num counted from 1 */\r | |
666 | int num_repeat; /* OP_REPEAT/OP_REPEAT_NG id-counter */\r | |
667 | int num_null_check; /* OP_NULL_CHECK_START/END id counter */\r | |
668 | int num_comb_exp_check; /* combination explosion check */\r | |
669 | int num_call; /* number of subexp call */\r | |
670 | unsigned int capture_history; /* (?@...) flag (1-31) */\r | |
671 | unsigned int bt_mem_start; /* need backtrack flag */\r | |
672 | unsigned int bt_mem_end; /* need backtrack flag */\r | |
673 | int stack_pop_level;\r | |
674 | int repeat_range_alloc;\r | |
675 | OnigRepeatRange* repeat_range;\r | |
676 | \r | |
677 | OnigEncoding enc;\r | |
678 | OnigOptionType options;\r | |
679 | OnigSyntaxType* syntax;\r | |
680 | OnigCaseFoldType case_fold_flag;\r | |
681 | void* name_table;\r | |
682 | \r | |
683 | /* optimization info (string search, char-map and anchors) */\r | |
684 | int optimize; /* optimize flag */\r | |
685 | int threshold_len; /* search str-length for apply optimize */\r | |
686 | int anchor; /* BEGIN_BUF, BEGIN_POS, (SEMI_)END_BUF */\r | |
687 | OnigDistance anchor_dmin; /* (SEMI_)END_BUF anchor distance */\r | |
688 | OnigDistance anchor_dmax; /* (SEMI_)END_BUF anchor distance */\r | |
689 | int sub_anchor; /* start-anchor for exact or map */\r | |
690 | unsigned char *exact;\r | |
691 | unsigned char *exact_end;\r | |
692 | unsigned char map[ONIG_CHAR_TABLE_SIZE]; /* used as BM skip or char-map */\r | |
693 | int *int_map; /* BM skip for exact_len > 255 */\r | |
694 | int *int_map_backward; /* BM skip for backward search */\r | |
695 | OnigDistance dmin; /* min-distance of exact or map */\r | |
696 | OnigDistance dmax; /* max-distance of exact or map */\r | |
697 | \r | |
698 | /* regex_t link chain */\r | |
699 | struct re_pattern_buffer* chain; /* escape compile-conflict */\r | |
700 | } OnigRegexType;\r | |
701 | \r | |
702 | typedef OnigRegexType* OnigRegex;\r | |
703 | \r | |
704 | #ifndef ONIG_ESCAPE_REGEX_T_COLLISION\r | |
705 | typedef OnigRegexType regex_t;\r | |
706 | #endif\r | |
707 | \r | |
708 | \r | |
709 | typedef struct {\r | |
710 | int num_of_elements;\r | |
711 | OnigEncoding pattern_enc;\r | |
712 | OnigEncoding target_enc;\r | |
713 | OnigSyntaxType* syntax;\r | |
714 | OnigOptionType option;\r | |
715 | OnigCaseFoldType case_fold_flag;\r | |
716 | } OnigCompileInfo;\r | |
717 | \r | |
718 | /* Oniguruma Native API */\r | |
719 | ONIG_EXTERN\r | |
720 | int onig_init P_((void));\r | |
721 | ONIG_EXTERN\r | |
722 | int onig_error_code_to_str PV_((OnigUChar* s, int err_code, ...));\r | |
723 | ONIG_EXTERN\r | |
724 | void onig_set_warn_func P_((OnigWarnFunc f));\r | |
725 | ONIG_EXTERN\r | |
726 | void onig_set_verb_warn_func P_((OnigWarnFunc f));\r | |
727 | ONIG_EXTERN\r | |
728 | int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));\r | |
729 | ONIG_EXTERN\r | |
730 | int onig_reg_init P_((regex_t* reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, OnigSyntaxType* syntax));\r | |
731 | int onig_new_without_alloc P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));\r | |
732 | ONIG_EXTERN\r | |
733 | int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));\r | |
734 | ONIG_EXTERN\r | |
735 | void onig_free P_((OnigRegex));\r | |
736 | ONIG_EXTERN\r | |
737 | void onig_free_body P_((OnigRegex));\r | |
738 | ONIG_EXTERN\r | |
739 | int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));\r | |
740 | ONIG_EXTERN\r | |
741 | int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));\r | |
742 | ONIG_EXTERN\r | |
743 | int onig_search P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option));\r | |
744 | ONIG_EXTERN\r | |
745 | int onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option));\r | |
746 | ONIG_EXTERN\r | |
747 | OnigRegion* onig_region_new P_((void));\r | |
748 | ONIG_EXTERN\r | |
749 | void onig_region_init P_((OnigRegion* region));\r | |
750 | ONIG_EXTERN\r | |
751 | void onig_region_free P_((OnigRegion* region, int free_self));\r | |
752 | ONIG_EXTERN\r | |
753 | void onig_region_copy P_((OnigRegion* to, OnigRegion* from));\r | |
754 | ONIG_EXTERN\r | |
755 | void onig_region_clear P_((OnigRegion* region));\r | |
756 | ONIG_EXTERN\r | |
757 | int onig_region_resize P_((OnigRegion* region, int n));\r | |
758 | ONIG_EXTERN\r | |
759 | int onig_region_set P_((OnigRegion* region, int at, int beg, int end));\r | |
760 | ONIG_EXTERN\r | |
761 | int onig_name_to_group_numbers P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, int** nums));\r | |
762 | ONIG_EXTERN\r | |
763 | int onig_name_to_backref_number P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, OnigRegion *region));\r | |
764 | ONIG_EXTERN\r | |
765 | int onig_foreach_name P_((OnigRegex reg, int (*func)(const OnigUChar*, const OnigUChar*,int,int*,OnigRegex,void*), void* arg));\r | |
766 | ONIG_EXTERN\r | |
767 | int onig_number_of_names P_((OnigRegex reg));\r | |
768 | ONIG_EXTERN\r | |
769 | int onig_number_of_captures P_((OnigRegex reg));\r | |
770 | ONIG_EXTERN\r | |
771 | int onig_number_of_capture_histories P_((OnigRegex reg));\r | |
772 | ONIG_EXTERN\r | |
773 | OnigCaptureTreeNode* onig_get_capture_tree P_((OnigRegion* region));\r | |
774 | ONIG_EXTERN\r | |
775 | int onig_capture_tree_traverse P_((OnigRegion* region, int at, int(*callback_func)(int,int,int,int,int,void*), void* arg));\r | |
776 | ONIG_EXTERN\r | |
777 | int onig_noname_group_capture_is_active P_((OnigRegex reg));\r | |
778 | ONIG_EXTERN\r | |
779 | OnigEncoding onig_get_encoding P_((OnigRegex reg));\r | |
780 | ONIG_EXTERN\r | |
781 | OnigOptionType onig_get_options P_((OnigRegex reg));\r | |
782 | ONIG_EXTERN\r | |
783 | OnigCaseFoldType onig_get_case_fold_flag P_((OnigRegex reg));\r | |
784 | ONIG_EXTERN\r | |
785 | OnigSyntaxType* onig_get_syntax P_((OnigRegex reg));\r | |
786 | ONIG_EXTERN\r | |
787 | int onig_set_default_syntax P_((OnigSyntaxType* syntax));\r | |
788 | ONIG_EXTERN\r | |
789 | void onig_copy_syntax P_((OnigSyntaxType* to, OnigSyntaxType* from));\r | |
790 | ONIG_EXTERN\r | |
791 | unsigned int onig_get_syntax_op P_((OnigSyntaxType* syntax));\r | |
792 | ONIG_EXTERN\r | |
793 | unsigned int onig_get_syntax_op2 P_((OnigSyntaxType* syntax));\r | |
794 | ONIG_EXTERN\r | |
795 | unsigned int onig_get_syntax_behavior P_((OnigSyntaxType* syntax));\r | |
796 | ONIG_EXTERN\r | |
797 | OnigOptionType onig_get_syntax_options P_((OnigSyntaxType* syntax));\r | |
798 | ONIG_EXTERN\r | |
799 | void onig_set_syntax_op P_((OnigSyntaxType* syntax, unsigned int op));\r | |
800 | ONIG_EXTERN\r | |
801 | void onig_set_syntax_op2 P_((OnigSyntaxType* syntax, unsigned int op2));\r | |
802 | ONIG_EXTERN\r | |
803 | void onig_set_syntax_behavior P_((OnigSyntaxType* syntax, unsigned int behavior));\r | |
804 | ONIG_EXTERN\r | |
805 | void onig_set_syntax_options P_((OnigSyntaxType* syntax, OnigOptionType options));\r | |
806 | ONIG_EXTERN\r | |
807 | int onig_set_meta_char P_((OnigSyntaxType* syntax, unsigned int what, OnigCodePoint code));\r | |
808 | ONIG_EXTERN\r | |
809 | void onig_copy_encoding P_((OnigEncoding to, OnigEncoding from));\r | |
810 | ONIG_EXTERN\r | |
811 | OnigCaseFoldType onig_get_default_case_fold_flag P_((void));\r | |
812 | ONIG_EXTERN\r | |
813 | int onig_set_default_case_fold_flag P_((OnigCaseFoldType case_fold_flag));\r | |
814 | ONIG_EXTERN\r | |
815 | unsigned int onig_get_match_stack_limit_size P_((void));\r | |
816 | ONIG_EXTERN\r | |
817 | int onig_set_match_stack_limit_size P_((unsigned int size));\r | |
818 | ONIG_EXTERN\r | |
819 | int onig_end P_((void));\r | |
820 | ONIG_EXTERN\r | |
821 | const char* onig_version P_((void));\r | |
822 | ONIG_EXTERN\r | |
823 | const char* onig_copyright P_((void));\r | |
824 | \r | |
825 | #ifdef __cplusplus\r | |
826 | }\r | |
827 | #endif\r | |
828 | \r | |
829 | #endif /* ONIGURUMA_H */\r |