23 #define errcpy(err, msg) strlcpy((err), (msg), ONIG_MAX_ERROR_MESSAGE_LEN)
25 #define BEG(no) (regs->beg[(no)])
26 #define END(no) (regs->end[(no)])
29 static const char casetable[] = {
30 '\000',
'\001',
'\002',
'\003',
'\004',
'\005',
'\006',
'\007',
31 '\010',
'\011',
'\012',
'\013',
'\014',
'\015',
'\016',
'\017',
32 '\020',
'\021',
'\022',
'\023',
'\024',
'\025',
'\026',
'\027',
33 '\030',
'\031',
'\032',
'\033',
'\034',
'\035',
'\036',
'\037',
35 '\040',
'\041',
'\042',
'\043',
'\044',
'\045',
'\046',
'\047',
37 '\050',
'\051',
'\052',
'\053',
'\054',
'\055',
'\056',
'\057',
39 '\060',
'\061',
'\062',
'\063',
'\064',
'\065',
'\066',
'\067',
41 '\070',
'\071',
'\072',
'\073',
'\074',
'\075',
'\076',
'\077',
43 '\100',
'\141',
'\142',
'\143',
'\144',
'\145',
'\146',
'\147',
45 '\150',
'\151',
'\152',
'\153',
'\154',
'\155',
'\156',
'\157',
47 '\160',
'\161',
'\162',
'\163',
'\164',
'\165',
'\166',
'\167',
49 '\170',
'\171',
'\172',
'\133',
'\134',
'\135',
'\136',
'\137',
51 '\140',
'\141',
'\142',
'\143',
'\144',
'\145',
'\146',
'\147',
53 '\150',
'\151',
'\152',
'\153',
'\154',
'\155',
'\156',
'\157',
55 '\160',
'\161',
'\162',
'\163',
'\164',
'\165',
'\166',
'\167',
57 '\170',
'\171',
'\172',
'\173',
'\174',
'\175',
'\176',
'\177',
58 '\200',
'\201',
'\202',
'\203',
'\204',
'\205',
'\206',
'\207',
59 '\210',
'\211',
'\212',
'\213',
'\214',
'\215',
'\216',
'\217',
60 '\220',
'\221',
'\222',
'\223',
'\224',
'\225',
'\226',
'\227',
61 '\230',
'\231',
'\232',
'\233',
'\234',
'\235',
'\236',
'\237',
62 '\240',
'\241',
'\242',
'\243',
'\244',
'\245',
'\246',
'\247',
63 '\250',
'\251',
'\252',
'\253',
'\254',
'\255',
'\256',
'\257',
64 '\260',
'\261',
'\262',
'\263',
'\264',
'\265',
'\266',
'\267',
65 '\270',
'\271',
'\272',
'\273',
'\274',
'\275',
'\276',
'\277',
66 '\300',
'\301',
'\302',
'\303',
'\304',
'\305',
'\306',
'\307',
67 '\310',
'\311',
'\312',
'\313',
'\314',
'\315',
'\316',
'\317',
68 '\320',
'\321',
'\322',
'\323',
'\324',
'\325',
'\326',
'\327',
69 '\330',
'\331',
'\332',
'\333',
'\334',
'\335',
'\336',
'\337',
70 '\340',
'\341',
'\342',
'\343',
'\344',
'\345',
'\346',
'\347',
71 '\350',
'\351',
'\352',
'\353',
'\354',
'\355',
'\356',
'\357',
72 '\360',
'\361',
'\362',
'\363',
'\364',
'\365',
'\366',
'\367',
73 '\370',
'\371',
'\372',
'\373',
'\374',
'\375',
'\376',
'\377',
76 # error >>> "You lose. You will need a translation table for your character set." <<<
82 const unsigned char *p1 = x, *p2 = y;
86 if ((tmp = casetable[(
unsigned)*p1++] - casetable[(
unsigned)*p2++]))
97 return memcmp(p1, p2, len);
102 rb_memsearch_ss(
const unsigned char *xs,
long m,
const unsigned char *ys,
long n)
104 const unsigned char *y;
106 if (y = memmem(ys, n, xs, m))
115 const unsigned char *x = xs, *xe = xs +
m;
116 const unsigned char *y = ys, *ye = ys +
n;
118 # if SIZEOF_VALUE == 8
119 # define VALUE_MAX 0xFFFFFFFFFFFFFFFFULL
120 # elif SIZEOF_VALUE == 4
121 # define VALUE_MAX 0xFFFFFFFFUL
127 rb_bug(
"!!too long pattern string!!");
129 if (!(y = memchr(y, *x, n - m + 1)))
133 for (hx = *x++, hy = *y++; x < xe; ++x, ++y) {
155 const unsigned char *x = xs, *xe = xs +
m;
156 const unsigned char *y = ys;
160 for (i = 0; i < 256; ++
i)
163 qstable[*x] = xe - x;
165 for (; y + m <= ys +
n; y += *(qstable + y[
m])) {
166 if (*xs == *y &&
memcmp(xs, y, m) == 0)
172 static inline unsigned int
175 register const unsigned int mix = 8353;
176 register unsigned int h = *x;
201 return (
unsigned char)h;
207 const unsigned char *x = xs, *xe = xs +
m;
208 const unsigned char *y = ys;
212 for (i = 0; i < 512; ++
i) {
215 for (; x < xe; ++x) {
220 if (*xs == *y &&
memcmp(xs, y, m) == 0)
229 const unsigned char *x = xs, x0 = *xs, *y = ys;
233 if (x0 == *y &&
memcmp(x+1, y+1, m-1) == 0)
242 const unsigned char *x = xs, x0 = *xs, *y = ys;
246 if (x0 == *y &&
memcmp(x+1, y+1, m-1) == 0)
255 const unsigned char *x = x0, *y = y0;
257 if (m > n)
return -1;
259 return memcmp(x0, y0, m) == 0 ? 0 : -1;
265 const unsigned char *ys = memchr(y, *x, n);
289 #define REG_LITERAL FL_USER5
290 #define REG_ENCODING_NONE FL_USER6
292 #define KCODE_FIXED FL_USER4
294 #define ARG_REG_OPTION_MASK \
295 (ONIG_OPTION_IGNORECASE|ONIG_OPTION_MULTILINE|ONIG_OPTION_EXTEND)
296 #define ARG_ENCODING_FIXED 16
297 #define ARG_ENCODING_NONE 32
370 const char *
p, *pend;
375 p =
s; pend = p +
len;
383 p +=
mbclen(p, pend, enc);
411 if (c ==
'\\' && p+clen < pend) {
412 int n = clen +
mbclen(p+clen, pend, enc);
425 c = (
unsigned char)*p;
445 snprintf(b,
sizeof(b),
"\\x%02X", c);
566 options =
RREGEXP(re)->ptr->options;
570 if (len >= 4 && ptr[0] ==
'(' && ptr[1] ==
'?') {
573 if ((len -= 2) > 0) {
585 if (len > 1 && *ptr ==
'-') {
604 if (*ptr ==
':' && ptr[len-1] ==
')') {
617 options =
RREGEXP(re)->ptr->options;
625 if ((options & embeddable) != embeddable) {
759 int back_num,
int *back_refs,
OnigRegex regex,
void *
arg)
793 int back_num,
int *back_refs,
OnigRegex regex,
void *
arg)
799 for (i = 0; i < back_num; i++)
851 r =
onig_compile(*reg, pattern, pattern_end, einfo, sourcefile, sourceline);
862 const char *sourcefile,
int sourceline)
878 onig_error_code_to_str((
UChar*)err, r, &einfo);
922 #if SIZEOF_LONG > SIZEOF_INT
923 return diff ? diff > 0 ? 1 : -1 : 0;
973 for (i = 0; i < num_pos; i++) {
1003 if (!
RMATCH(match)->regexp) {
1019 rm =
RMATCH(obj)->rmatch;
1053 return RMATCH(match)->regexp;
1106 switch (
TYPE(backref)) {
1120 (
const unsigned char*)name,
1121 (
const unsigned char*)name +
strlen(name),
1243 #define MATCH_BUSY FL_USER2
1298 "incompatible encoding regexp match (%s regexp with %s string)",
1310 "invalid byte sequence in %s",
1332 rb_warn(
"regexp match /.../n against to %s string",
1345 const char *pattern;
1350 if (reg->
enc == enc)
return reg;
1360 if (unescaped ==
Qnil) {
1369 onig_error_code_to_str((
UChar*)err, r, &einfo);
1425 tmpreg = reg !=
RREGEXP(re)->ptr;
1426 if (!tmpreg)
RREGEXP(re)->usecnt++;
1429 if (!
NIL_P(match)) {
1449 if (!tmpreg)
RREGEXP(re)->usecnt--;
1468 onig_error_code_to_str((
UChar*)err, (
int)result);
1486 RMATCH(match)->regexp = re;
1487 RMATCH(match)->rmatch->char_offset_updated = 0;
1508 if (nth <= 0)
return Qnil;
1529 if (nth <= 0)
return Qnil;
1532 if (start == -1)
return Qnil;
1567 if (
BEG(0) == -1)
return Qnil;
1595 if (
BEG(0) == -1)
return Qnil;
1596 str =
RMATCH(match)->str;
1612 if (
BEG(0) == -1)
return Qnil;
1614 for (i=regs->
num_regs-1;
BEG(i) == -1 && i > 0; i--)
1616 if (i == 0)
return Qnil;
1656 target =
RMATCH(match)->str;
1658 for (i=start; i<regs->
num_regs; i++) {
1659 if (regs->
beg[i] == -1) {
1727 (
const unsigned char* )name, (
const unsigned char* )name_end, regs);
1783 switch (
TYPE(idx)) {
1874 return RMATCH(match)->str;
1884 int back_num,
int *back_refs,
OnigRegex regex,
void *arg0)
1889 for (i = 0; i < back_num; i++) {
1891 arg[back_refs[
i]].
len = name_end -
name;
1928 return rb_sprintf(
"#<%s:%p>", cname, (
void*)match);
1940 for (i = 0; i < num_regs; i++) {
1967 const char *
p = *pp;
1969 int meta_prefix = 0, ctrl_prefix = 0;
1972 if (p == end || *p++ !=
'\\') {
1973 errcpy(err,
"too short escaped multibyte character");
1979 errcpy(err,
"too short escape sequence");
1983 case '\\': code =
'\\';
break;
1984 case 'n': code =
'\n';
break;
1985 case 't': code =
'\t';
break;
1986 case 'r': code =
'\r';
break;
1987 case 'f': code =
'\f';
break;
1988 case 'v': code =
'\013';
break;
1989 case 'a': code =
'\007';
break;
1990 case 'e': code =
'\033';
break;
1993 case '0':
case '1':
case '2':
case '3':
1994 case '4':
case '5':
case '6':
case '7':
1996 code =
scan_oct(p, end < p+3 ? end-p : 3, &len);
2001 code =
scan_hex(p, end < p+2 ? end-p : 2, &len);
2003 errcpy(err,
"invalid hex escape");
2011 errcpy(err,
"duplicate meta escape");
2015 if (p+1 < end && *p++ ==
'-' && (*p & 0x80) == 0) {
2025 errcpy(err,
"too short meta escape");
2029 if (p == end || *p++ !=
'-') {
2030 errcpy(err,
"too short control escape");
2035 errcpy(err,
"duplicate control escape");
2039 if (p < end && (*p & 0x80) == 0) {
2049 errcpy(err,
"too short control escape");
2053 errcpy(err,
"unexpected escape sequence");
2056 if (code < 0 || 0xff < code) {
2057 errcpy(err,
"invalid escape code");
2074 const char *
p = *pp;
2076 char *chbuf =
ALLOCA_N(
char, chmaxlen);
2081 memset(chbuf, 0, chmaxlen);
2088 chbuf[chlen++] = byte;
2089 while (chlen < chmaxlen &&
2095 chbuf[chlen++] = byte;
2100 errcpy(err,
"invalid multibyte escape");
2103 if (1 < chlen || (chbuf[0] & 0x80)) {
2108 else if (*encp != enc) {
2109 errcpy(err,
"escaped non ASCII character in UTF-8 regexp");
2115 snprintf(escbuf,
sizeof(escbuf),
"\\x%02X", chbuf[0]&0xff);
2125 if ((0xd800 <= code && code <= 0xdfff) ||
2127 errcpy(err,
"invalid Unicode range");
2141 snprintf(escbuf,
sizeof(escbuf),
"\\x%02X", (
int)uv);
2153 errcpy(err,
"UTF-8 character in non UTF-8 regexp");
2164 const char *
p = *pp;
2165 int has_unicode = 0;
2169 while (p < end &&
ISSPACE(*p)) p++;
2176 errcpy(err,
"invalid Unicode range");
2184 while (p < end &&
ISSPACE(*p)) p++;
2187 if (has_unicode == 0) {
2188 errcpy(err,
"invalid Unicode list");
2201 const char *
p = *pp;
2206 errcpy(err,
"invalid Unicode escape");
2211 errcpy(err,
"invalid Unicode escape");
2231 errcpy(err,
"invalid multibyte character");
2235 if (1 < chlen || (*p & 0x80)) {
2240 else if (*encp != enc) {
2241 errcpy(err,
"non ASCII character in UTF-8 regexp");
2250 errcpy(err,
"too short escape sequence");
2254 case '1':
case '2':
case '3':
2255 case '4':
case '5':
case '6':
case '7':
2280 errcpy(err,
"too short escape sequence");
2288 if (p == end || *p++ !=
'}') {
2289 errcpy(err,
"invalid Unicode list");
2331 int has_property = 0;
2345 if (has_property && !*fixed_enc) {
2401 src_enc != ascii8bit) {
2405 src_enc = ascii8bit;
2417 if (fixed_enc != 0) {
2418 if (regexp_enc != 0 && regexp_enc != fixed_enc) {
2422 regexp_enc = fixed_enc;
2440 const char *sourcefile,
int sourceline)
2455 errcpy(err,
"can't make regexp with dummy encoding");
2460 if (unescaped ==
Qnil)
2466 errcpy(err,
"incompatible character encoding");
2469 if (fixed_enc != a_enc) {
2479 if ((options & ARG_ENCODING_FIXED) || fixed_enc) {
2488 sourcefile, sourceline);
2489 if (!re->ptr)
return -1;
2497 const char *sourcefile,
int sourceline)
2503 if (enc != ascii8bit) {
2505 errcpy(err,
"/.../n has a non escaped non ASCII character in non ASCII-8BIT script");
2512 options, err, sourcefile, sourceline);
2629 hashval =
RREGEXP(re)->ptr->options;
2653 if (re1 == re2)
return Qtrue;
2702 if (match1 == match2)
return Qtrue;
2800 if (pos < 0)
return Qnil;
2909 if (
rb_scan_args(argc, argv,
"11", &str, &initpos) == 2) {
2991 if (argc == 3 && !
NIL_P(argv[2])) {
2993 if (kcode[0] ==
'n' || kcode[0] ==
'N') {
2998 rb_warn(
"encoding option is ignored - %s", kcode);
3026 s +=
mbclen(s, send, enc);
3030 case '[':
case ']':
case '{':
case '}':
3031 case '(':
case ')':
case '|':
case '-':
3032 case '*':
case '.':
case '\\':
3033 case '?':
case '+':
case '^':
case '$':
3035 case '\t':
case '\f':
case '\v':
case '\n':
case '\r':
3062 int n =
mbclen(s, send, enc);
3070 case '[':
case ']':
case '{':
case '}':
3071 case '(':
case ')':
case '|':
case '-':
3072 case '*':
case '.':
case '\\':
3073 case '?':
case '+':
case '^':
case '$':
3181 else if (argc == 1) {
3197 int has_asciionly = 0;
3201 for (i = 0; i <
argc; i++) {
3212 if (!has_ascii_incompat)
3213 has_ascii_incompat =
enc;
3214 else if (has_ascii_incompat != enc)
3219 if (!has_ascii_compat_fixed)
3220 has_ascii_compat_fixed =
enc;
3221 else if (has_ascii_compat_fixed != enc)
3235 if (!has_ascii_incompat)
3236 has_ascii_incompat =
enc;
3237 else if (has_ascii_incompat != enc)
3245 if (!has_ascii_compat_fixed)
3246 has_ascii_compat_fixed =
enc;
3247 else if (has_ascii_compat_fixed != enc)
3253 if (has_ascii_incompat) {
3254 if (has_asciionly) {
3258 if (has_ascii_compat_fixed) {
3270 if (has_ascii_incompat) {
3271 result_enc = has_ascii_incompat;
3273 else if (has_ascii_compat_fixed) {
3274 result_enc = has_ascii_compat_fixed;
3330 err,
NULL, 0) != 0) {
3345 #define ASCGET(s,e,cl) (acompat ? (*(cl)=1,ISASCII((s)[0])?(s)[0]:-1) : rb_enc_ascget((s), (e), (cl), str_enc))
3355 s +=
mbclen(s, e, str_enc);
3361 if (c !=
'\\' || s == e)
continue;
3370 s +=
mbclen(s, e, str_enc);
3379 case '1':
case '2':
case '3':
case '4':
3380 case '5':
case '6':
case '7':
case '8':
case '9':
3390 if (s < e &&
ASCGET(s, e, &clen) ==
'<') {
3391 char *
name, *name_end;
3393 name_end = name = s + clen;
3394 while (name_end < e) {
3395 c =
ASCGET(name_end, e, &clen);
3396 if (c ==
'>')
break;
3397 name_end += c == -1 ?
mbclen(name_end, e, str_enc) : clen;
3401 (
long)(name_end - name));
3406 p = s = name_end + clen;
3432 while (
BEG(no) == -1 && no > 0) no--;
3433 if (no == 0)
continue;
3446 if (no >= regs->
num_regs)
continue;
3447 if (
BEG(no) == -1)
continue;
3452 if (!val)
return str;
3463 rb_warn(
"variable $KCODE is no longer effective");
3470 rb_warn(
"variable $KCODE is no longer effective; ignored");
3476 rb_warn(
"variable $= is no longer effective");
3483 rb_warn(
"variable $= is no longer effective; ignored");
3538 if (argc > 0 &&
rb_scan_args(argc, argv,
"01", &nth) == 1) {
VALUE rb_reg_match_last(VALUE)
static VALUE rb_reg_source(VALUE re)
#define RB_TYPE_P(obj, type)
static VALUE match_hash(VALUE match)
static VALUE rb_reg_hash(VALUE re)
void onig_set_warn_func(OnigWarnFunc f)
VALUE rb_reg_last_match(VALUE)
long rb_reg_adjust_startpos(VALUE, VALUE, long, int)
int onig_new(regex_t **reg, const UChar *pattern, const UChar *pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType *syntax, OnigErrorInfo *einfo)
unsigned int OnigOptionType
int onig_foreach_name(regex_t *reg, int(*func)(const UChar *, const UChar *, int, int *, regex_t *, void *), void *arg)
VALUE rb_ary_entry(VALUE ary, long offset)
static VALUE rb_reg_options_m(VALUE re)
static void reg_enc_error(VALUE re, VALUE str)
void rb_bug(const char *fmt,...)
RUBY_EXTERN VALUE rb_cMatch
#define RB_OBJ_WRITE(a, slot, b)
void rb_enc_copy(VALUE obj1, VALUE obj2)
void rb_match_busy(VALUE)
static VALUE rb_reg_s_last_match(int argc, VALUE *argv)
static unsigned int rb_memsearch_qs_utf8_hash(const unsigned char *x)
size_t strlen(const char *)
#define ONIG_ENCODING_ASCII
VALUE rb_class_new_instance(int, VALUE *, VALUE)
#define scan_oct(s, l, e)
const char * rb_obj_classname(VALUE)
VALUE rb_str_buf_cat_ascii(VALUE, const char *)
static VALUE rb_reg_match_m(int argc, VALUE *argv, VALUE re)
static int unescape_nonascii(const char *p, const char *end, rb_encoding *enc, VALUE buf, rb_encoding **encp, int *has_property, onig_errmsg_buffer err)
static VALUE rb_enc_reg_error_desc(const char *s, long len, rb_encoding *enc, int options, const char *err)
static void kcode_setter(VALUE val, ID id)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static long rb_memsearch_qs_utf8(const unsigned char *xs, long m, const unsigned char *ys, long n)
VALUE rb_str_buf_append(VALUE, VALUE)
static VALUE match_inspect(VALUE match)
UChar * onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar *start, const UChar *s, const UChar *end)
int onigenc_set_default_encoding(OnigEncoding enc)
#define ARG_ENCODING_FIXED
static char * option_to_str(char str[4], int options)
#define rb_check_frozen(obj)
static VALUE match_equal(VALUE match1, VALUE match2)
VALUE rb_str_subseq(VALUE, long, long)
void onig_region_copy(OnigRegion *to, OnigRegion *from)
static VALUE match_getter(void)
#define ONIGENC_MBC_MAXLEN(enc)
static int append_utf8(unsigned long uv, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
#define RGENGC_WB_PROTECTED_REGEXP
#define REG_ENCODING_NONE
VALUE rb_enc_from_encoding(rb_encoding *encoding)
static VALUE kcode_getter(void)
#define ONIGENC_CASE_FOLD_DEFAULT
static VALUE rb_reg_initialize_m(int argc, VALUE *argv, VALUE self)
static VALUE rb_reg_equal(VALUE re1, VALUE re2)
static int unescape_unicode_bmp(const char **pp, const char *end, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
static VALUE rb_reg_s_alloc(VALUE klass)
static VALUE rb_reg_desc(const char *s, long len, VALUE re)
rb_encoding * rb_default_internal_encoding(void)
static int pair_byte_cmp(const void *pair1, const void *pair2)
VALUE rb_ary_push(VALUE ary, VALUE item)
static VALUE match_string(VALUE match)
VALUE rb_reg_regsub(VALUE, VALUE, struct re_registers *, VALUE)
static void update_char_offset(VALUE match)
static void ignorecase_setter(VALUE val, ID id)
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
static long rb_memsearch_wchar(const unsigned char *xs, long m, const unsigned char *ys, long n)
static VALUE match_to_s(VALUE match)
int rb_reg_options(VALUE)
VALUE rb_str_buf_cat2(VALUE, const char *)
static int onig_new_with_source(regex_t **reg, const UChar *pattern, const UChar *pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType *syntax, OnigErrorInfo *einfo, const char *sourcefile, int sourceline)
#define MBCLEN_NEEDMORE_P(ret)
void rb_raise(VALUE exc, const char *fmt,...)
static int name_to_backref_number(struct re_registers *regs, VALUE regexp, const char *name, const char *name_end)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
#define rb_enc_left_char_head(s, p, e, enc)
static void rb_reg_expr_str(VALUE str, const char *s, long len, rb_encoding *enc, rb_encoding *resenc)
static long rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
static VALUE match_aref(int argc, VALUE *argv, VALUE match)
VALUE rb_reg_nth_match(int, VALUE)
static VALUE rb_reg_casefold_p(VALUE re)
VALUE rb_lastline_get(void)
static int match_backref_number(VALUE match, VALUE backref)
int char_offset_num_allocated
rb_encoding * rb_utf8_encoding(void)
void rb_undef_method(VALUE klass, const char *name)
#define ENC_CODERANGE_BROKEN
static VALUE match_captures(VALUE match)
struct re_pattern_buffer * ptr
static VALUE last_paren_match_getter(void)
VALUE rb_reg_match_post(VALUE)
static int unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
int rb_reg_backref_number(VALUE match, VALUE backref)
VALUE rb_str_to_str(VALUE)
VALUE rb_str_equal(VALUE str1, VALUE str2)
RUBY_EXTERN VALUE rb_cRegexp
#define ENCODING_GET(obj)
static void rb_reg_raise_str(VALUE str, int options, const char *err)
#define ONIG_OPTION_EXTEND
st_index_t rb_hash_start(st_index_t)
#define MEMZERO(p, type, n)
int onig_compile(regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigErrorInfo *einfo, const char *sourcefile, int sourceline)
void rb_exc_raise(VALUE mesg)
static int rb_reg_initialize_str(VALUE obj, VALUE str, int options, onig_errmsg_buffer err, const char *sourcefile, int sourceline)
VALUE rb_reg_new_str(VALUE, int)
static VALUE rb_reg_s_union(VALUE self, VALUE args0)
static VALUE match_alloc(VALUE klass)
rb_encoding * rb_default_external_encoding(void)
memset(y->frac+ix+1, 0,(y->Prec-(ix+1))*sizeof(BDIGIT))
static st_index_t reg_hash(VALUE re)
#define scan_hex(s, l, e)
void onigenc_set_default_caseconv_table(const UChar *table ARG_UNUSED)
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p)
static VALUE ignorecase_getter(void)
static int read_escaped_byte(const char **pp, const char *end, onig_errmsg_buffer err)
int rb_char_to_option_kcode(int c, int *option, int *kcode)
static VALUE rb_reg_preprocess_dregexp(VALUE ary, int options)
int rb_block_given_p(void)
long rb_str_offset(VALUE, long)
static int reg_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg)
static int check_unicode_range(unsigned long code, onig_errmsg_buffer err)
#define StringValuePtr(v)
static void match_check(VALUE match)
VALUE rb_reg_new_ary(VALUE ary, int opt)
VALUE rb_reg_new(const char *, long, int)
static VALUE rb_reg_error_desc(VALUE str, int options, const char *err)
#define RARRAY_AREF(a, i)
#define mbclen(p, e, enc)
#define StringValueCStr(v)
void rb_define_const(VALUE, const char *, VALUE)
static VALUE rb_reg_fixed_encoding_p(VALUE re)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
static int reg_names_iter(const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg)
int onig_name_to_backref_number(regex_t *reg, const UChar *name, const UChar *name_end, OnigRegion *region)
void rb_ary_store(VALUE ary, long idx, VALUE val)
void rb_backref_set(VALUE)
static int rb_enc_dummy_p(rb_encoding *enc)
static Regexp * make_regexp(const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_buffer err, const char *sourcefile, int sourceline)
static VALUE match_values_at(int argc, VALUE *argv, VALUE match)
#define MBCLEN_CHARFOUND_P(ret)
void onig_region_free(OnigRegion *r, int free_self)
int onig_reg_init(regex_t *reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, const OnigSyntaxType *syntax)
#define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s, end)
#define rb_enc_isprint(c, enc)
void onig_set_verb_warn_func(OnigWarnFunc f)
#define OBJ_INIT_COPY(obj, orig)
static VALUE match_regexp(VALUE match)
#define range(low, item, hi)
unsigned char buf[MIME_BUF_SIZE]
static void match_setter(VALUE val)
VALUE rb_check_regexp_type(VALUE re)
#define ALLOCA_N(type, n)
static VALUE rb_reg_inspect(VALUE re)
#define ENC_CODERANGE_UNKNOWN
VALUE rb_reg_init_str(VALUE re, VALUE s, int options)
#define rb_enc_mbc_to_codepoint(p, e, enc)
VALUE rb_reg_match(VALUE, VALUE)
VALUE rb_str_buf_cat(VALUE, const char *, long)
static VALUE reg_operand(VALUE s, int check)
#define rb_utf8_encindex()
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
VALUE rb_str_resize(VALUE, long)
#define RREGEXP_SRC_PTR(r)
static void rb_reg_raise(const char *s, long len, const char *err, VALUE re)
static void rb_enc_reg_raise(const char *s, long len, rb_encoding *enc, int options, const char *err)
#define rb_enc_mbminlen(enc)
static VALUE rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc, rb_encoding **fixed_enc, onig_errmsg_buffer err)
#define ONIG_MAX_ERROR_MESSAGE_LEN
VALUE rb_reg_match2(VALUE)
#define rb_ascii8bit_encindex()
VALUE rb_sprintf(const char *format,...)
#define rb_enc_mbcput(c, buf, enc)
#define ONIG_OPTION_DEFAULT
long rb_memsearch(const void *, long, const void *, long, rb_encoding *)
#define MBCLEN_CHARFOUND_LEN(ret)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
int rb_enc_unicode_p(rb_encoding *enc)
long rb_str_coderange_scan_restartable(const char *, const char *, rb_encoding *, int *)
static VALUE match_to_a(VALUE match)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
int rb_uv_to_utf8(char[6], unsigned long)
long rb_reg_search(VALUE, VALUE, long, int)
VALUE rb_assoc_new(VALUE car, VALUE cdr)
VALUE rb_get_values_at(VALUE obj, long olen, int argc, VALUE *argv, VALUE(*func)(VALUE, long))
rb_encoding * rb_usascii_encoding(void)
static void re_warn(const char *s)
VALUE rb_reg_eqq(VALUE re, VALUE str)
VALUE rb_str_inspect(VALUE)
static VALUE postmatch_getter(void)
VALUE rb_str_buf_new(long)
static VALUE rb_reg_s_quote(VALUE c, VALUE str)
rb_hash_aset(hash, RARRAY_AREF(key_value_pair, 0), RARRAY_AREF(key_value_pair, 1))
VALUE rb_obj_encoding(VALUE obj)
int memcmp(const void *s1, const void *s2, size_t len)
static VALUE match_end(VALUE match, VALUE n)
VALUE rb_reg_check_preprocess(VALUE)
static VALUE rb_reg_s_union_m(VALUE self, VALUE args)
static VALUE last_match_getter(void)
static VALUE match_names(VALUE match)
static long reg_match_pos(VALUE re, VALUE *strp, long pos)
static void name_to_backref_error(VALUE name)
static long rb_memsearch_qchar(const unsigned char *xs, long m, const unsigned char *ys, long n)
VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
#define ONIG_OPTION_IGNORECASE
#define MEMCPY(p1, p2, type, n)
static VALUE match_begin(VALUE match, VALUE n)
#define ENC_CODERANGE_VALID
#define rb_enc_str_asciicompat_p(str)
VALUE rb_reg_nth_defined(int, VALUE)
#define ONIG_OPTION_MULTILINE
static VALUE rb_reg_to_s(VALUE re)
#define NEWOBJ_OF(obj, type, klass, flags)
VALUE rb_str_length(VALUE)
#define ENC_CODERANGE_7BIT
rb_encoding * rb_enc_get(VALUE obj)
int onig_noname_group_capture_is_active(regex_t *reg)
static VALUE prematch_getter(void)
char onig_errmsg_buffer[ONIG_MAX_ERROR_MESSAGE_LEN]
OnigPosition onig_search(regex_t *reg, const UChar *str, const UChar *end, const UChar *start, const UChar *range, OnigRegion *region, OnigOptionType option)
long rb_str_sublen(VALUE, long)
int rb_enc_str_asciionly_p(VALUE)
static VALUE match_init_copy(VALUE obj, VALUE orig)
void rb_set_errinfo(VALUE err)
static int unescape_unicode_list(const char **pp, const char *end, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
#define MBCLEN_INVALID_P(ret)
#define rb_enc_isspace(c, enc)
st_index_t rb_memhash(const void *ptr, long len)
VALUE rb_check_array_type(VALUE ary)
typedefRUBY_SYMBOL_EXPORT_BEGIN struct re_pattern_buffer Regexp
VALUE rb_reg_quote(VALUE)
st_index_t rb_str_hash(VALUE)
VALUE rb_str_catf(VALUE str, const char *format,...)
VALUE rb_reg_match_pre(VALUE)
RUBY_EXTERN VALUE rb_cObject
static int char_to_option(int c)
static VALUE match_size(VALUE match)
regex_t * rb_reg_prepare_re(VALUE re, VALUE str)
static VALUE match_entry(VALUE match, long n)
static Bigint * diff(Bigint *a, Bigint *b)
#define char_size(c2, c1)
#define ARG_REG_OPTION_MASK
static rb_encoding * rb_reg_prepare_enc(VALUE re, VALUE str, int warn)
VALUE rb_backref_get(void)
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
VALUE rb_str_new(const char *, long)
static int match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg0)
struct rmatch_offset * char_offset
unsigned long ruby_scan_hex(const char *, size_t, size_t *)
#define rb_enc_asciicompat(enc)
static VALUE rb_reg_named_captures(VALUE re)
const char * rb_id2name(ID id)
void rb_global_variable(VALUE *)
static VALUE rb_reg_s_try_convert(VALUE dummy, VALUE re)
rb_encoding * rb_ascii8bit_encoding(void)
static VALUE rb_reg_names(VALUE re)
static void rb_reg_check(VALUE re)
#define RREGEXP_SRC_LEN(r)
#define ARG_ENCODING_NONE
static VALUE rb_reg_init_copy(VALUE copy, VALUE re)
static long rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
int rb_memcicmp(const void *, const void *, long)
VALUE rb_enc_reg_new(const char *, long, rb_encoding *, int)
VALUE rb_check_string_type(VALUE)
#define REALLOC_N(var, type, n)
void onig_free(regex_t *reg)
VALUE rb_reg_regcomp(VALUE)
int rb_enc_str_coderange(VALUE)
long rb_enc_strlen(const char *, const char *, rb_encoding *)
static int match(VALUE str, VALUE pat, VALUE hash, int(*cb)(VALUE, VALUE))
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
#define rb_enc_mbmaxlen(enc)
void rb_warn(const char *fmt,...)
static VALUE match_array(VALUE match, int start)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
static VALUE match_offset(VALUE match, VALUE n)
unsigned long ruby_scan_oct(const char *, size_t, size_t *)
ONIG_EXTERN const OnigSyntaxType * OnigDefaultSyntax
VALUE rb_ary_aref(int argc, VALUE *argv, VALUE ary)
#define rb_hash_uint(h, i)
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc)
RUBY_EXTERN VALUE rb_eRegexpError
static int rb_reg_initialize(VALUE obj, const char *s, long len, rb_encoding *enc, int options, onig_errmsg_buffer err, const char *sourcefile, int sourceline)
int rb_memcmp(const void *p1, const void *p2, long len)