22 #define errcpy(err, msg) strlcpy((err), (msg), ONIG_MAX_ERROR_MESSAGE_LEN) 24 #define BEG(no) (regs->beg[(no)]) 25 #define END(no) (regs->end[(no)]) 28 static const char casetable[] = {
29 '\000',
'\001',
'\002',
'\003',
'\004',
'\005',
'\006',
'\007',
30 '\010',
'\011',
'\012',
'\013',
'\014',
'\015',
'\016',
'\017',
31 '\020',
'\021',
'\022',
'\023',
'\024',
'\025',
'\026',
'\027',
32 '\030',
'\031',
'\032',
'\033',
'\034',
'\035',
'\036',
'\037',
34 '\040',
'\041',
'\042',
'\043',
'\044',
'\045',
'\046',
'\047',
36 '\050',
'\051',
'\052',
'\053',
'\054',
'\055',
'\056',
'\057',
38 '\060',
'\061',
'\062',
'\063',
'\064',
'\065',
'\066',
'\067',
40 '\070',
'\071',
'\072',
'\073',
'\074',
'\075',
'\076',
'\077',
42 '\100',
'\141',
'\142',
'\143',
'\144',
'\145',
'\146',
'\147',
44 '\150',
'\151',
'\152',
'\153',
'\154',
'\155',
'\156',
'\157',
46 '\160',
'\161',
'\162',
'\163',
'\164',
'\165',
'\166',
'\167',
48 '\170',
'\171',
'\172',
'\133',
'\134',
'\135',
'\136',
'\137',
50 '\140',
'\141',
'\142',
'\143',
'\144',
'\145',
'\146',
'\147',
52 '\150',
'\151',
'\152',
'\153',
'\154',
'\155',
'\156',
'\157',
54 '\160',
'\161',
'\162',
'\163',
'\164',
'\165',
'\166',
'\167',
56 '\170',
'\171',
'\172',
'\173',
'\174',
'\175',
'\176',
'\177',
57 '\200',
'\201',
'\202',
'\203',
'\204',
'\205',
'\206',
'\207',
58 '\210',
'\211',
'\212',
'\213',
'\214',
'\215',
'\216',
'\217',
59 '\220',
'\221',
'\222',
'\223',
'\224',
'\225',
'\226',
'\227',
60 '\230',
'\231',
'\232',
'\233',
'\234',
'\235',
'\236',
'\237',
61 '\240',
'\241',
'\242',
'\243',
'\244',
'\245',
'\246',
'\247',
62 '\250',
'\251',
'\252',
'\253',
'\254',
'\255',
'\256',
'\257',
63 '\260',
'\261',
'\262',
'\263',
'\264',
'\265',
'\266',
'\267',
64 '\270',
'\271',
'\272',
'\273',
'\274',
'\275',
'\276',
'\277',
65 '\300',
'\301',
'\302',
'\303',
'\304',
'\305',
'\306',
'\307',
66 '\310',
'\311',
'\312',
'\313',
'\314',
'\315',
'\316',
'\317',
67 '\320',
'\321',
'\322',
'\323',
'\324',
'\325',
'\326',
'\327',
68 '\330',
'\331',
'\332',
'\333',
'\334',
'\335',
'\336',
'\337',
69 '\340',
'\341',
'\342',
'\343',
'\344',
'\345',
'\346',
'\347',
70 '\350',
'\351',
'\352',
'\353',
'\354',
'\355',
'\356',
'\357',
71 '\360',
'\361',
'\362',
'\363',
'\364',
'\365',
'\366',
'\367',
72 '\370',
'\371',
'\372',
'\373',
'\374',
'\375',
'\376',
'\377',
75 # error >>> "You lose. You will need a translation table for your character set." <<< 81 const unsigned char *p1 = x, *p2 = y;
85 if ((tmp = casetable[(
unsigned)*p1++] - casetable[(
unsigned)*p2++]))
96 return memcmp(p1, p2, len);
101 rb_memsearch_ss(
const unsigned char *xs,
long m,
const unsigned char *ys,
long n)
103 const unsigned char *y;
105 if (y = memmem(ys, n, xs, m))
114 const unsigned char *x = xs, *xe = xs + m;
115 const unsigned char *y = ys, *ye = ys + n;
117 # if SIZEOF_VALUE == 8 118 # define VALUE_MAX 0xFFFFFFFFFFFFFFFFULL 119 # elif SIZEOF_VALUE == 4 120 # define VALUE_MAX 0xFFFFFFFFUL 126 rb_bug(
"!!too long pattern string!!");
128 if (!(y = memchr(y, *x, n - m + 1)))
132 for (hx = *x++, hy = *y++; x < xe; ++x, ++y) {
154 const unsigned char *x = xs, *xe = xs + m;
155 const unsigned char *y = ys;
156 VALUE i, qstable[256];
159 for (i = 0; i < 256; ++i)
162 qstable[*x] = xe - x;
164 for (; y + m <= ys + n; y += *(qstable + y[m])) {
165 if (*xs == *y &&
memcmp(xs, y, m) == 0)
171 static inline unsigned int 174 register const unsigned int mix = 8353;
175 register unsigned int h = *x;
200 return (
unsigned char)h;
206 const unsigned char *x = xs, *xe = xs + m;
207 const unsigned char *y = ys;
208 VALUE i, qstable[512];
211 for (i = 0; i < 512; ++i) {
214 for (; x < xe; ++x) {
219 if (*xs == *y &&
memcmp(xs, y, m) == 0)
228 const unsigned char *x = xs, x0 = *xs, *y = ys;
232 if (x0 == *y &&
memcmp(x+1, y+1, m-1) == 0)
241 const unsigned char *x = xs, x0 = *xs, *y = ys;
245 if (x0 == *y &&
memcmp(x+1, y+1, m-1) == 0)
254 const unsigned char *x = x0, *y = y0;
256 if (m > n)
return -1;
258 return memcmp(x0, y0, m) == 0 ? 0 : -1;
264 const unsigned char *ys = memchr(y, *x, n);
288 #define REG_LITERAL FL_USER5 289 #define REG_ENCODING_NONE FL_USER6 291 #define KCODE_FIXED FL_USER4 293 #define ARG_REG_OPTION_MASK \ 294 (ONIG_OPTION_IGNORECASE|ONIG_OPTION_MULTILINE|ONIG_OPTION_EXTEND) 295 #define ARG_ENCODING_FIXED 16 296 #define ARG_ENCODING_NONE 32 369 const char *p, *pend;
374 p = s; pend = p +
len;
381 p +=
mbclen(p, pend, enc);
409 if (c ==
'\\' && p+clen < pend) {
410 int n = clen +
mbclen(p+clen, pend, enc);
423 c = (
unsigned char)*p;
443 snprintf(b,
sizeof(b),
"\\x%02X", c);
568 if (len >= 4 && ptr[0] ==
'(' && ptr[1] ==
'?') {
571 if ((len -= 2) > 0) {
583 if (len > 1 && *ptr ==
'-') {
602 if (*ptr ==
':' && ptr[len-1] ==
')') {
623 if ((options & embeddable) != embeddable) {
757 int back_num,
int *back_refs,
OnigRegex regex,
void *arg)
792 int back_num,
int *back_refs,
OnigRegex regex,
void *arg)
798 for (i = 0; i < back_num; i++)
840 OnigErrorInfo* einfo,
const char *sourcefile,
int sourceline)
850 r =
onig_compile_ruby(*reg, pattern, pattern_end, einfo, sourcefile, sourceline);
861 const char *sourcefile,
int sourceline)
931 #if SIZEOF_LONG > SIZEOF_INT 932 return diff ? diff > 0 ? 1 : -1 : 0;
982 for (i = 0; i < num_pos; i++) {
1012 if (!
RMATCH(match)->regexp) {
1028 rm =
RMATCH(obj)->rmatch;
1065 regexp =
RMATCH(match)->regexp;
1066 if (
NIL_P(regexp)) {
1069 RMATCH(match)->regexp = regexp;
1257 #define MATCH_BUSY FL_USER2 1269 if (
NIL_P(match))
return -1;
1271 if (!regs)
return -1;
1281 if (!regs)
return FALSE;
1287 if (nth <= 0)
return FALSE;
1289 return (
BEG(nth) != -1);
1298 match->
str = string;
1365 "incompatible encoding regexp match (%s regexp with %s string)",
1388 "invalid byte sequence in %s",
1413 rb_warn(
"regexp match /.../n against to %s string",
1425 const char *pattern;
1430 if (reg->
enc == enc)
return reg;
1440 if (unescaped ==
Qnil) {
1514 if (!tmpreg)
RREGEXP(re)->usecnt++;
1517 if (!
NIL_P(match)) {
1537 if (!tmpreg)
RREGEXP(re)->usecnt--;
1571 if (set_backref_str) {
1576 RMATCH(match)->regexp = re;
1577 RMATCH(match)->rmatch->char_offset_updated = 0;
1603 if (nth <= 0)
return Qnil;
1624 if (nth <= 0)
return Qnil;
1627 if (start == -1)
return Qnil;
1662 if (
BEG(0) == -1)
return Qnil;
1690 if (
BEG(0) == -1)
return Qnil;
1691 str =
RMATCH(match)->str;
1707 if (
BEG(0) == -1)
return Qnil;
1709 for (i=regs->
num_regs-1;
BEG(i) == -1 && i > 0; i--)
1711 if (i == 0)
return Qnil;
1751 target =
RMATCH(match)->str;
1753 for (i=start; i<regs->
num_regs; i++) {
1754 if (regs->
beg[i] == -1) {
1818 (
const unsigned char *)name, (
const unsigned char *)name_end, regs);
1829 #define NAME_TO_NUMBER(regs, re, name, name_ptr, name_end) \ 1831 !rb_enc_compatible(RREGEXP_SRC(re), (name)) ? 0 : \ 1832 name_to_backref_number((regs), (re), (name_ptr), (name_end))) 1857 long j,
end = olen < beg+len ? olen : beg+
len;
1859 if (len == 0)
return result;
1861 for (j = beg; j <
end; j++) {
1864 if (beg + len > j) {
1924 if (
NIL_P(length)) {
1947 if (beg < 0)
return Qnil;
1949 else if (beg > num_regs) {
1952 else if (beg+len > num_regs) {
1953 len = num_regs -
beg;
1985 for (i=0; i<
argc; i++) {
2027 int back_num,
int *back_refs,
OnigRegex regex,
void *arg) {
2038 for (i = 0; i < back_num; i++) {
2108 return RMATCH(match)->str;
2118 int back_num,
int *back_refs,
OnigRegex regex,
void *arg0)
2123 for (i = 0; i < back_num; i++) {
2125 arg[back_refs[i]].
len = name_end -
name;
2164 else if (
NIL_P(regexp)) {
2178 for (i = 0; i < num_regs; i++) {
2205 const char *p = *pp;
2207 int meta_prefix = 0, ctrl_prefix = 0;
2210 if (p == end || *p++ !=
'\\') {
2211 errcpy(err,
"too short escaped multibyte character");
2217 errcpy(err,
"too short escape sequence");
2221 case '\\': code =
'\\';
break;
2222 case 'n': code =
'\n';
break;
2223 case 't': code =
'\t';
break;
2224 case 'r': code =
'\r';
break;
2225 case 'f': code =
'\f';
break;
2226 case 'v': code =
'\013';
break;
2227 case 'a': code =
'\007';
break;
2228 case 'e': code =
'\033';
break;
2231 case '0':
case '1':
case '2':
case '3':
2232 case '4':
case '5':
case '6':
case '7':
2234 code =
scan_oct(p, end < p+3 ? end-p : 3, &len);
2239 code =
scan_hex(p, end < p+2 ? end-p : 2, &len);
2241 errcpy(err,
"invalid hex escape");
2249 errcpy(err,
"duplicate meta escape");
2253 if (p+1 < end && *p++ ==
'-' && (*p & 0x80) == 0) {
2263 errcpy(err,
"too short meta escape");
2267 if (p == end || *p++ !=
'-') {
2268 errcpy(err,
"too short control escape");
2273 errcpy(err,
"duplicate control escape");
2277 if (p < end && (*p & 0x80) == 0) {
2287 errcpy(err,
"too short control escape");
2291 errcpy(err,
"unexpected escape sequence");
2294 if (code < 0 || 0xff < code) {
2295 errcpy(err,
"invalid escape code");
2312 const char *p = *pp;
2314 char *chbuf =
ALLOCA_N(
char, chmaxlen);
2319 memset(chbuf, 0, chmaxlen);
2326 chbuf[chlen++] = byte;
2327 while (chlen < chmaxlen &&
2333 chbuf[chlen++] = byte;
2338 errcpy(err,
"invalid multibyte escape");
2341 if (1 < chlen || (chbuf[0] & 0x80)) {
2346 else if (*encp != enc) {
2347 errcpy(err,
"escaped non ASCII character in UTF-8 regexp");
2353 snprintf(escbuf,
sizeof(escbuf),
"\\x%02X", chbuf[0]&0xff);
2363 if ((0xd800 <= code && code <= 0xdfff) ||
2365 errcpy(err,
"invalid Unicode range");
2379 snprintf(escbuf,
sizeof(escbuf),
"\\x%02X", (
int)uv);
2391 errcpy(err,
"UTF-8 character in non UTF-8 regexp");
2402 const char *p = *pp;
2403 int has_unicode = 0;
2407 while (p < end &&
ISSPACE(*p)) p++;
2414 errcpy(err,
"invalid Unicode range");
2422 while (p < end &&
ISSPACE(*p)) p++;
2425 if (has_unicode == 0) {
2426 errcpy(err,
"invalid Unicode list");
2439 const char *p = *pp;
2444 errcpy(err,
"invalid Unicode escape");
2449 errcpy(err,
"invalid Unicode escape");
2469 errcpy(err,
"invalid multibyte character");
2473 if (1 < chlen || (*p & 0x80)) {
2478 else if (*encp != enc) {
2479 errcpy(err,
"non ASCII character in UTF-8 regexp");
2488 errcpy(err,
"too short escape sequence");
2492 case '1':
case '2':
case '3':
2493 case '4':
case '5':
case '6':
case '7':
2495 size_t len = end-(p-1), octlen;
2496 if (
ruby_scan_oct(p-1, len < 3 ? len : 3, &octlen) <= 0177) {
2513 const char *pbeg = p;
2515 if (c == (
char)-1)
return -1;
2526 errcpy(err,
"too short escape sequence");
2534 if (p == end || *p++ !=
'}') {
2535 errcpy(err,
"invalid Unicode list");
2577 int has_property = 0;
2591 if (has_property && !*fixed_enc) {
2647 src_enc != ascii8bit) {
2651 src_enc = ascii8bit;
2663 if (fixed_enc != 0) {
2664 if (regexp_enc != 0 && regexp_enc != fixed_enc) {
2668 regexp_enc = fixed_enc;
2686 const char *sourcefile,
int sourceline)
2701 errcpy(err,
"can't make regexp with dummy encoding");
2706 if (unescaped ==
Qnil)
2712 errcpy(err,
"incompatible character encoding");
2715 if (fixed_enc != a_enc) {
2725 if ((options & ARG_ENCODING_FIXED) || fixed_enc) {
2734 sourcefile, sourceline);
2735 if (!re->ptr)
return -1;
2744 if (regenc != enc) {
2752 const char *sourcefile,
int sourceline)
2758 if (enc != ascii8bit) {
2760 errcpy(err,
"/.../n has a non escaped non ASCII character in non ASCII-8BIT script");
2767 options, err, sourcefile, sourceline);
2815 enc, options, err,
NULL, 0) != 0) {
2924 if (re1 == re2)
return Qtrue;
2978 if (match1 == match2)
return Qtrue;
3077 if (pos < 0)
return Qnil;
3190 if (
rb_scan_args(argc, argv,
"11", &str, &initpos) == 2) {
3247 if (pos < 0)
return Qfalse;
3258 if (!tmpreg)
RREGEXP(re)->usecnt++;
3261 result =
onig_search(reg, start, end, start + pos, end,
3263 if (!tmpreg)
RREGEXP(re)->usecnt--;
3336 if (argc == 3 && !
NIL_P(argv[2])) {
3338 if (kcode[0] ==
'n' || kcode[0] ==
'N') {
3343 rb_warn(
"encoding option is ignored - %s", kcode);
3369 s +=
mbclen(s, send, enc);
3373 case '[':
case ']':
case '{':
case '}':
3374 case '(':
case ')':
case '|':
case '-':
3375 case '*':
case '.':
case '\\':
3376 case '?':
case '+':
case '^':
case '$':
3378 case '\t':
case '\f':
case '\v':
case '\n':
case '\r':
3405 int n =
mbclen(s, send, enc);
3413 case '[':
case ']':
case '{':
case '}':
3414 case '(':
case ')':
case '|':
case '-':
3415 case '*':
case '.':
case '\\':
3416 case '?':
case '+':
case '^':
case '$':
3524 else if (argc == 1) {
3540 int has_asciionly = 0;
3544 for (i = 0; i <
argc; i++) {
3555 if (!has_ascii_incompat)
3556 has_ascii_incompat = enc;
3557 else if (has_ascii_incompat != enc)
3562 if (!has_ascii_compat_fixed)
3563 has_ascii_compat_fixed = enc;
3564 else if (has_ascii_compat_fixed != enc)
3578 if (!has_ascii_incompat)
3579 has_ascii_incompat = enc;
3580 else if (has_ascii_incompat != enc)
3588 if (!has_ascii_compat_fixed)
3589 has_ascii_compat_fixed = enc;
3590 else if (has_ascii_compat_fixed != enc)
3596 if (has_ascii_incompat) {
3597 if (has_asciionly) {
3601 if (has_ascii_compat_fixed) {
3613 if (has_ascii_incompat) {
3614 result_enc = has_ascii_incompat;
3616 else if (has_ascii_compat_fixed) {
3617 result_enc = has_ascii_compat_fixed;
3678 #define ASCGET(s,e,cl) (acompat ? (*(cl)=1,ISASCII((s)[0])?(s)[0]:-1) : rb_enc_ascget((s), (e), (cl), str_enc)) 3684 int c =
ASCGET(s, e, &clen);
3688 s +=
mbclen(s, e, str_enc);
3694 if (c !=
'\\' || s == e)
continue;
3703 s +=
mbclen(s, e, str_enc);
3712 case '1':
case '2':
case '3':
case '4':
3713 case '5':
case '6':
case '7':
case '8':
case '9':
3723 if (s < e &&
ASCGET(s, e, &clen) ==
'<') {
3724 char *
name, *name_end;
3726 name_end = name = s + clen;
3727 while (name_end < e) {
3728 c =
ASCGET(name_end, e, &clen);
3729 if (c ==
'>')
break;
3730 name_end += c == -1 ?
mbclen(name_end, e, str_enc) : clen;
3734 (
long)(name_end - name));
3735 if ((no =
NAME_TO_NUMBER(regs, regexp, n, name, name_end)) < 1) {
3738 p = s = name_end + clen;
3764 while (
BEG(no) == -1 && no > 0) no--;
3765 if (no == 0)
continue;
3778 if (no >= regs->
num_regs)
continue;
3779 if (
BEG(no) == -1)
continue;
3784 if (!val)
return str;
3795 rb_warn(
"variable $KCODE is no longer effective");
3802 rb_warn(
"variable $KCODE is no longer effective; ignored");
3808 rb_warn(
"variable $= is no longer effective");
3815 rb_warn(
"variable $= is no longer effective; ignored");
3870 if (argc > 0 &&
rb_scan_args(argc, argv,
"01", &nth) == 1) {
unsigned int OnigOptionType
VALUE rb_reg_match(VALUE re, VALUE str)
static VALUE rb_reg_source(VALUE re)
static VALUE match_hash(VALUE match)
static VALUE rb_reg_hash(VALUE re)
ONIG_EXTERN int onig_foreach_name(OnigRegex reg, int(*func)(const OnigUChar *, const OnigUChar *, int, int *, OnigRegex, void *), void *arg)
ONIG_EXTERN int onigenc_set_default_encoding(OnigEncoding enc)
int onig_compile_ruby(regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigErrorInfo *einfo, const char *sourcefile, int sourceline)
#define MBCLEN_CHARFOUND_P(ret)
#define ONIGENC_MBC_MAXLEN(enc)
ONIG_EXTERN OnigUChar * onigenc_get_right_adjust_char_head(OnigEncoding enc, const OnigUChar *start, const OnigUChar *s, const OnigUChar *end)
VALUE rb_str_length(VALUE)
VALUE rb_ary_entry(VALUE ary, long offset)
#define MBCLEN_CHARFOUND_LEN(ret)
static VALUE rb_reg_options_m(VALUE re)
static void reg_enc_error(VALUE re, VALUE str)
void rb_bug(const char *fmt,...)
#define rb_enc_mbc_to_codepoint(p, e, enc)
VALUE rb_ary_new_capa(long capa)
void rb_enc_copy(VALUE obj1, VALUE obj2)
VALUE rb_str_equal(VALUE str1, VALUE str2)
long rb_str_coderange_scan_restartable(const char *, const char *, rb_encoding *, int *)
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 scan_oct(s, l, e)
void rb_backref_set(VALUE)
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)
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
static unsigned int hash(str, len) register const char *str
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)
static VALUE match_inspect(VALUE match)
ONIG_EXTERN int onig_number_of_names(const OnigRegexType *reg)
static VALUE rb_reg_match_m_p(int argc, VALUE *argv, VALUE re)
ONIG_EXTERN int onig_new(OnigRegex *, const OnigUChar *pattern, const OnigUChar *pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType *syntax, OnigErrorInfo *einfo)
st_index_t rb_hash_end(st_index_t)
#define ARG_ENCODING_FIXED
static char * option_to_str(char str[4], int options)
#define OBJ_INIT_COPY(obj, orig)
static VALUE match_equal(VALUE match1, VALUE match2)
#define ONIGENC_CASE_FOLD_DEFAULT
int rb_enc_dummy_p(rb_encoding *enc)
static VALUE match_getter(void)
regex_t * rb_reg_prepare_re0(VALUE re, VALUE str, onig_errmsg_buffer err)
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)
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)
static VALUE rb_reg_s_alloc(VALUE klass)
static VALUE rb_reg_desc(const char *s, long len, VALUE re)
#define ONIG_ENCODING_ASCII
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)
VALUE rb_str_buf_new2(const char *)
static VALUE match_string(VALUE match)
static void update_char_offset(VALUE match)
static void ignorecase_setter(VALUE val, ID id)
st_index_t rb_memhash(const void *ptr, long len)
ONIG_EXTERN void onig_region_free(OnigRegion *region, int free_self)
int rb_reg_region_copy(struct re_registers *to, const struct re_registers *from)
static long rb_memsearch_wchar(const unsigned char *xs, long m, const unsigned char *ys, long n)
static VALUE match_to_s(VALUE match)
VALUE rb_backref_get(void)
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)
int rb_enc_str_coderange(VALUE)
void rb_raise(VALUE exc, const char *fmt,...)
static int namev_to_backref_number(struct re_registers *regs, VALUE re, VALUE name)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
VALUE rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
NORETURN(static void name_to_backref_error(VALUE name))
ONIG_EXTERN void onig_free(OnigRegex)
int rb_reg_backref_number(VALUE match, VALUE backref)
static void rb_reg_expr_str(VALUE str, const char *s, long len, rb_encoding *enc, rb_encoding *resenc)
st_index_t rb_str_hash(VALUE)
static long rb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
char * rb_str_subpos(VALUE, long, long *)
#define ONIG_OPTION_IGNORECASE
VALUE rb_range_beg_len(VALUE, long *, long *, long, int)
static VALUE match_aref(int argc, VALUE *argv, VALUE match)
static VALUE rb_reg_casefold_p(VALUE re)
#define rb_enc_mbmaxlen(enc)
static int match_backref_number(VALUE match, VALUE backref)
int char_offset_num_allocated
#define MEMO_NEW(a, b, c)
rb_encoding * rb_utf8_encoding(void)
#define ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s, end)
void rb_undef_method(VALUE klass, const char *name)
VALUE rb_str_buf_append(VALUE, VALUE)
static VALUE match_captures(VALUE match)
static VALUE last_paren_match_getter(void)
static int unescape_escaped_nonascii(const char **pp, const char *end, rb_encoding *enc, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
long rb_reg_search0(VALUE re, VALUE str, long pos, int reverse, int set_backref_str)
#define ENC_CODERANGE_7BIT
ONIG_EXTERN int onig_error_code_to_str(OnigUChar *s, OnigPosition err_code,...)
static void match_set_string(VALUE m, VALUE string, long pos, long len)
static void rb_reg_raise_str(VALUE str, int options, const char *err)
VALUE rb_reg_init_str(VALUE re, VALUE s, int options)
ONIG_EXTERN int onig_noname_group_capture_is_active(const OnigRegexType *reg)
static VALUE match_ary_aref(VALUE match, VALUE idx, VALUE result)
VALUE rb_str_buf_cat(VALUE, const char *, long)
#define NEWOBJ_OF(obj, type, klass, flags)
long rb_reg_search(VALUE re, VALUE str, long pos, int reverse)
void rb_global_variable(VALUE *var)
VALUE rb_reg_new_str(VALUE s, int options)
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)
static VALUE rb_reg_s_union(VALUE self, VALUE args0)
ONIG_EXTERN int onig_reg_init(OnigRegex reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, const OnigSyntaxType *syntax)
static VALUE match_alloc(VALUE klass)
#define RB_TYPE_P(obj, type)
VALUE rb_reg_last_match(VALUE match)
#define MEMZERO(p, type, n)
VALUE rb_lastline_get(void)
rb_encoding * rb_default_external_encoding(void)
VALUE rb_reg_match_post(VALUE match)
static st_index_t reg_hash(VALUE re)
regex_t * rb_reg_prepare_re(VALUE re, VALUE str)
#define scan_hex(s, l, e)
int rb_match_nth_defined(int nth, VALUE match)
static VALUE ignorecase_getter(void)
static int read_escaped_byte(const char **pp, const char *end, onig_errmsg_buffer err)
static VALUE rb_reg_preprocess_dregexp(VALUE ary, int options)
int rb_block_given_p(void)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static int reg_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg)
ONIG_EXTERN void onig_set_verb_warn_func(OnigWarnFunc f)
static int check_unicode_range(unsigned long code, onig_errmsg_buffer err)
static void match_check(VALUE match)
#define RREGEXP_SRC_PTR(r)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_reg_new_ary(VALUE ary, int opt)
#define MBCLEN_NEEDMORE_P(ret)
static VALUE rb_reg_error_desc(VALUE str, int options, const char *err)
#define mbclen(p, e, enc)
VALUE rb_str_buf_cat2(VALUE, const char *)
ONIG_EXTERN int onig_name_to_backref_number(OnigRegex reg, const OnigUChar *name, const OnigUChar *name_end, const OnigRegion *region)
int rb_ascii8bit_encindex(void)
#define ONIG_MAX_ERROR_MESSAGE_LEN
static VALUE rb_reg_fixed_encoding_p(VALUE re)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_reg_nth_match(int nth, VALUE match)
static int reg_names_iter(const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg)
#define ENC_CODERANGE_CLEAN_P(cr)
static void reg_set_source(VALUE reg, VALUE str, rb_encoding *enc)
void rb_define_const(VALUE, const char *, VALUE)
void rb_ary_store(VALUE ary, long idx, VALUE val)
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)
static VALUE match_regexp(VALUE match)
#define ALLOCA_N(type, n)
int rb_uv_to_utf8(char[6], unsigned long)
#define range(low, item, hi)
#define ENC_CODERANGE_UNKNOWN
#define rb_enc_isprint(c, enc)
#define MEMCPY(p1, p2, type, n)
#define ENC_CODERANGE_BROKEN
static void match_setter(VALUE val)
void rb_match_busy(VALUE match)
#define rb_enc_mbminlen(enc)
VALUE rb_check_regexp_type(VALUE re)
static VALUE rb_reg_inspect(VALUE re)
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
#define ONIG_OPTION_EXTEND
VALUE rb_reg_match2(VALUE re)
static VALUE reg_operand(VALUE s, int check)
VALUE rb_str_resize(VALUE, long)
long rb_str_offset(VALUE, long)
int rb_reg_options(VALUE re)
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
long rb_memsearch(const void *x0, long m, const void *y0, long n, rb_encoding *enc)
VALUE rb_str_subseq(VALUE, long, long)
#define NAME_TO_NUMBER(regs, re, name, name_ptr, name_end)
struct re_pattern_buffer * ptr
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 REALLOC_N(var, type, n)
static VALUE rb_reg_preprocess(const char *p, const char *end, rb_encoding *enc, rb_encoding **fixed_enc, onig_errmsg_buffer err)
VALUE rb_sprintf(const char *format,...)
#define rb_enc_isspace(c, enc)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
int rb_enc_unicode_p(rb_encoding *enc)
VALUE rb_class_path(VALUE)
static VALUE match_to_a(VALUE match)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_assoc_new(VALUE car, VALUE cdr)
rb_encoding * rb_usascii_encoding(void)
static void re_warn(const char *s)
VALUE rb_reg_eqq(VALUE re, VALUE str)
static VALUE postmatch_getter(void)
static int options(unsigned char *cp)
ONIG_EXTERN int onig_region_resize(OnigRegion *region, int n)
static int match_named_captures_iter(const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg)
static VALUE match_ary_subseq(VALUE match, long beg, long len, VALUE result)
ONIG_EXTERN OnigPosition onig_search(OnigRegex, const OnigUChar *str, const OnigUChar *end, const OnigUChar *start, const OnigUChar *range, OnigRegion *region, OnigOptionType option)
static VALUE rb_reg_s_quote(VALUE c, VALUE str)
int rb_utf8_encindex(void)
VALUE rb_enc_reg_new(const char *s, long len, rb_encoding *enc, int options)
int rb_match_count(VALUE match)
static VALUE match_named_captures(VALUE match)
VALUE rb_obj_encoding(VALUE obj)
#define rb_enc_asciicompat(enc)
int memcmp(const void *s1, const void *s2, size_t len)
static VALUE match_end(VALUE match, VALUE n)
static VALUE rb_reg_s_union_m(VALUE self, VALUE args)
static VALUE last_match_getter(void)
static VALUE match_names(VALUE match)
#define ONIG_OPTION_DEFAULT
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)
int rb_memcicmp(const void *x, const void *y, long len)
register unsigned int len
#define StringValueCStr(v)
static VALUE match_begin(VALUE match, VALUE n)
static VALUE rb_reg_to_s(VALUE re)
#define ONIG_OPTION_MULTILINE
VALUE rb_ary_resize(VALUE ary, long len)
expands or shrinks ary to len elements.
static int name_to_backref_number(struct re_registers *, VALUE, const char *, const char *)
#define ENCODING_GET(obj)
rb_encoding * rb_enc_get(VALUE obj)
static VALUE prematch_getter(void)
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p)
char onig_errmsg_buffer[ONIG_MAX_ERROR_MESSAGE_LEN]
VALUE rb_reg_quote(VALUE str)
long rb_enc_strlen(const char *, const char *, rb_encoding *)
VALUE rb_reg_match_p(VALUE re, VALUE str, long pos)
#define MBCLEN_INVALID_P(ret)
#define RARRAY_AREF(a, i)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
static VALUE match_init_copy(VALUE obj, VALUE orig)
VALUE rb_str_buf_cat_ascii(VALUE, const char *)
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)
void rb_backref_set_string(VALUE string, long pos, long len)
VALUE rb_check_array_type(VALUE ary)
long rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, int reverse)
typedefRUBY_SYMBOL_EXPORT_BEGIN struct re_pattern_buffer Regexp
#define ENCINDEX_Windows_31J
VALUE rb_str_catf(VALUE str, const char *format,...)
#define ENC_CODERANGE(obj)
VALUE rb_check_string_type(VALUE)
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline)
static int char_to_option(int c)
static VALUE match_size(VALUE match)
static Bigint * diff(Bigint *a, Bigint *b)
st_index_t rb_hash_uint(st_index_t, st_index_t)
#define char_size(c2, c1)
VALUE rb_reg_match_last(VALUE match)
#define ARG_REG_OPTION_MASK
static rb_encoding * rb_reg_prepare_enc(VALUE re, VALUE str, int warn)
long rb_str_sublen(VALUE, long)
#define rb_enc_left_char_head(s, p, e, enc)
VALUE rb_str_inspect(VALUE)
int rb_char_to_option_kcode(int c, int *option, int *kcode)
static int match_inspect_name_iter(const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg0)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
struct rmatch_offset * char_offset
ONIG_EXTERN const OnigSyntaxType * OnigDefaultSyntax
unsigned long ruby_scan_hex(const char *, size_t, size_t *)
#define RREGEXP_SRC_LEN(r)
ONIG_EXTERN void onig_region_copy(OnigRegion *to, const OnigRegion *from)
static VALUE rb_reg_named_captures(VALUE re)
static int str_coderange(VALUE str)
#define StringValuePtr(v)
static VALUE rb_reg_s_try_convert(VALUE dummy, VALUE re)
rb_encoding * rb_ascii8bit_encoding(void)
#define rb_check_frozen(obj)
static VALUE rb_reg_names(VALUE re)
ONIG_EXTERN void onig_set_warn_func(OnigWarnFunc f)
static void rb_reg_check(VALUE re)
VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
VALUE rb_reg_nth_defined(int nth, VALUE match)
#define ARG_ENCODING_NONE
static VALUE rb_reg_init_copy(VALUE copy, VALUE re)
static VALUE rb_reg_init_str_enc(VALUE re, VALUE s, rb_encoding *enc, int options)
#define rb_enc_mbcput(c, buf, enc)
int rb_enc_str_asciionly_p(VALUE)
static long rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
VALUE rb_reg_new(const char *s, long len, int options)
VALUE rb_str_buf_new(long)
VALUE rb_reg_regcomp(VALUE str)
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)
VALUE rb_str_append(VALUE, VALUE)
VALUE rb_reg_match_pre(VALUE match)
void rb_warn(const char *fmt,...)
VALUE rb_str_to_str(VALUE)
static VALUE match_array(VALUE match, int start)
st_index_t rb_hash_start(st_index_t)
static VALUE match_offset(VALUE match, VALUE n)
unsigned long ruby_scan_oct(const char *, size_t, size_t *)
#define RB_OBJ_WRITE(a, slot, b)
VALUE rb_reg_check_preprocess(VALUE str)
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc)
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)
VALUE rb_obj_class(VALUE)
VALUE rb_str_new(const char *, long)