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