22 #define BEG(no) (regs->beg[(no)]) 23 #define END(no) (regs->end[(no)]) 32 #if defined HAVE_CRYPT_R 33 # if defined HAVE_CRYPT_H 36 #elif !defined HAVE_CRYPT 38 # define HAVE_CRYPT_R 1 41 #define STRING_ENUMERATORS_WANTARRAY 0 44 #undef rb_usascii_str_new 45 #undef rb_utf8_str_new 47 #undef rb_str_new_cstr 48 #undef rb_tainted_str_new_cstr 49 #undef rb_usascii_str_new_cstr 50 #undef rb_utf8_str_new_cstr 51 #undef rb_enc_str_new_cstr 52 #undef rb_external_str_new_cstr 53 #undef rb_locale_str_new_cstr 54 #undef rb_str_dup_frozen 55 #undef rb_str_buf_new_cstr 57 #undef rb_str_buf_cat2 59 #undef rb_str_cat_cstr 60 #undef rb_fstring_cstr 61 #undef rb_fstring_enc_cstr 82 #define RUBY_MAX_CHAR_LEN 16 83 #define STR_IS_SHARED_M FL_USER6 84 #define STR_TMPLOCK FL_USER7 85 #define STR_NOFREE FL_USER18 86 #define STR_FAKESTR FL_USER19 88 #define STR_SET_NOEMBED(str) do {\ 89 FL_SET((str), STR_NOEMBED);\ 90 STR_SET_EMBED_LEN((str), 0);\ 92 #define STR_SET_EMBED(str) FL_UNSET((str), (STR_NOEMBED|STR_NOFREE)) 93 #define STR_SET_EMBED_LEN(str, n) do { \ 95 RBASIC(str)->flags &= ~RSTRING_EMBED_LEN_MASK;\ 96 RBASIC(str)->flags |= (tmp_n) << RSTRING_EMBED_LEN_SHIFT;\ 99 #define STR_SET_LEN(str, n) do { \ 100 if (STR_EMBED_P(str)) {\ 101 STR_SET_EMBED_LEN((str), (n));\ 104 RSTRING(str)->as.heap.len = (n);\ 108 #define STR_DEC_LEN(str) do {\ 109 if (STR_EMBED_P(str)) {\ 110 long n = RSTRING_LEN(str);\ 112 STR_SET_EMBED_LEN((str), n);\ 115 RSTRING(str)->as.heap.len--;\ 119 #define TERM_LEN(str) rb_enc_mbminlen(rb_enc_get(str)) 120 #define TERM_FILL(ptr, termlen) do {\ 121 char *const term_fill_ptr = (ptr);\ 122 const int term_fill_len = (termlen);\ 123 *term_fill_ptr = '\0';\ 124 if (UNLIKELY(term_fill_len > 1))\ 125 memset(term_fill_ptr, 0, term_fill_len);\ 128 #define RESIZE_CAPA(str,capacity) do {\ 129 const int termlen = TERM_LEN(str);\ 130 RESIZE_CAPA_TERM(str,capacity,termlen);\ 132 #define RESIZE_CAPA_TERM(str,capacity,termlen) do {\ 133 if (STR_EMBED_P(str)) {\ 134 if (!STR_EMBEDDABLE_P(capacity, termlen)) {\ 135 char *const tmp = ALLOC_N(char, (size_t)(capacity) + (termlen));\ 136 const long tlen = RSTRING_LEN(str);\ 137 memcpy(tmp, RSTRING_PTR(str), tlen);\ 138 RSTRING(str)->as.heap.ptr = tmp;\ 139 RSTRING(str)->as.heap.len = tlen;\ 140 STR_SET_NOEMBED(str);\ 141 RSTRING(str)->as.heap.aux.capa = (capacity);\ 145 assert(!FL_TEST((str), STR_SHARED)); \ 146 REALLOC_N(RSTRING(str)->as.heap.ptr, char, (size_t)(capacity) + (termlen));\ 147 RSTRING(str)->as.heap.aux.capa = (capacity);\ 151 #define STR_SET_SHARED(str, shared_str) do { \ 152 if (!FL_TEST(str, STR_FAKESTR)) { \ 153 RB_OBJ_WRITE((str), &RSTRING(str)->as.heap.aux.shared, (shared_str)); \ 154 FL_SET((str), STR_SHARED); \ 155 if (RBASIC_CLASS((shared_str)) == 0) \ 156 FL_SET_RAW((shared_str), STR_IS_SHARED_M); \ 160 #define STR_HEAP_PTR(str) (RSTRING(str)->as.heap.ptr) 161 #define STR_HEAP_SIZE(str) ((size_t)RSTRING(str)->as.heap.aux.capa + TERM_LEN(str)) 163 #define STR_ENC_GET(str) get_encoding(str) 165 #if !defined SHARABLE_MIDDLE_SUBSTRING 166 # define SHARABLE_MIDDLE_SUBSTRING 0 168 #if !SHARABLE_MIDDLE_SUBSTRING 169 #define SHARABLE_SUBSTRING_P(beg, len, end) ((beg) + (len) == (end)) 171 #define SHARABLE_SUBSTRING_P(beg, len, end) 1 174 #define STR_EMBEDDABLE_P(len, termlen) \ 175 ((len) <= RSTRING_EMBED_LEN_MAX + 1 - (termlen)) 199 const unsigned char *q;
205 if (q[0] == 0xFE && q[1] == 0xFF) {
208 if (q[0] == 0xFF && q[1] == 0xFE) {
215 if (q[0] == 0 && q[1] == 0 && q[2] == 0xFE && q[3] == 0xFF) {
218 if (q[3] == 0 && q[2] == 0 && q[1] == 0xFE && q[0] == 0xFF) {
258 #define BARE_STRING_P(str) (!FL_ANY_RAW(str, FL_TAINT|FL_EXIVAR) && RBASIC_CLASS(str) == rb_cString) 298 *key = *value = *fstr = str;
360 fake_str->as.heap.len =
len;
361 fake_str->as.heap.ptr = (
char *)name;
362 fake_str->as.heap.aux.capa =
len;
363 return (
VALUE)fake_str;
409 const char *aptr, *bptr;
412 return (alen != blen ||
414 memcmp(aptr, bptr, alen) != 0);
437 static inline const char *
441 #if SIZEOF_VOIDP == 8 442 # define NONASCII_MASK 0x8080808080808080ULL 443 #elif SIZEOF_VOIDP == 4 444 # define NONASCII_MASK 0x80808080UL 448 #if !UNALIGNED_WORD_ACCESS 450 int l = SIZEOF_VOIDP - (
uintptr_t)p % SIZEOF_VOIDP;
455 case 7:
if (p[-7]&0x80)
return p-7;
456 case 6:
if (p[-6]&0x80)
return p-6;
457 case 5:
if (p[-5]&0x80)
return p-5;
458 case 4:
if (p[-4]&0x80)
return p-4;
460 case 3:
if (p[-3]&0x80)
return p-3;
461 case 2:
if (p[-2]&0x80)
return p-2;
462 case 1:
if (p[-1]&0x80)
return p-1;
468 t = (
const uintptr_t *)(e - (SIZEOF_VOIDP-1));
470 if (*s & NONASCII_MASK) {
471 #ifdef WORDS_BIGENDIAN 472 return (
const char *)s + (
nlz_intptr(*s&NONASCII_MASK)>>3);
474 return (
const char *)s + (
ntz_intptr(*s&NONASCII_MASK)>>3);
484 case 7:
if (e[-7]&0x80)
return e-7;
485 case 6:
if (e[-6]&0x80)
return e-6;
486 case 5:
if (e[-5]&0x80)
return e-5;
487 case 4:
if (e[-4]&0x80)
return e-4;
489 case 3:
if (e[-3]&0x80)
return e-3;
490 case 2:
if (e[-2]&0x80)
return e-2;
491 case 1:
if (e[-1]&0x80)
return e-1;
499 const char *e = p +
len;
666 return RSTRING(str)->as.heap.len;
669 return RSTRING(str)->as.heap.aux.capa;
732 return str_new0(klass, ptr, len, 1);
819 RSTRING(str)->as.heap.ptr = (
char *)ptr;
881 int ecflags,
VALUE ecopts);
892 if (from == to)
return str;
904 from, to, ecflags, ecopts);
920 if (ofs < -olen || olen <= ofs)
922 if (ofs < 0) ofs += olen;
937 int ecflags,
VALUE ecopts)
943 const unsigned char *start, *sp;
944 unsigned char *dest, *
dp;
945 size_t converted_output = (size_t)ofs;
952 if (!ec)
return Qnil;
955 sp = (
unsigned char*)ptr;
957 while ((dest = (
unsigned char*)
RSTRING_PTR(newstr)),
958 (dp = dest + converted_output),
962 size_t converted_input = sp - start;
963 size_t rest = len - converted_input;
964 converted_output = dp - dest;
966 if (converted_input && converted_output &&
967 rest < (
LONG_MAX / converted_output)) {
968 rest = (rest * converted_output) / converted_input;
973 olen += rest < 2 ? 2 : rest;
1082 char *ptr2 =
RSTRING(str2)->as.ary;
1165 RSTRING(orig)->as.heap.aux.capa =
RSTRING(tmp)->as.heap.aux.capa;
1184 long ofs =
RSTRING(orig)->as.heap.ptr -
RSTRING(shared)->as.heap.ptr;
1185 long rest =
RSTRING(shared)->as.heap.len - ofs -
RSTRING(orig)->as.heap.len;
1189 if ((ofs > 0) || (rest > 0) ||
1190 (klass !=
RBASIC(shared)->klass) ||
1194 RSTRING(str)->as.heap.ptr += ofs;
1195 RSTRING(str)->as.heap.len -= ofs + rest;
1215 RSTRING(str)->as.heap.aux.capa =
RSTRING(orig)->as.heap.aux.capa;
1244 #define STR_BUF_MIN_SIZE 127 1257 RSTRING(str)->as.heap.ptr[0] =
'\0';
1351 RSTRING(str)->as.heap.aux.capa =
RSTRING(str2)->as.heap.aux.capa;
1407 const VALUE flag_mask =
1422 if (flags & STR_NOEMBED) {
1468 static ID keyword_ids[2];
1469 VALUE orig, opt, venc, vcapa;
1474 if (!keyword_ids[0]) {
1476 CONST_ID(keyword_ids[1],
"capacity");
1501 if (orig == str) n = 0;
1505 RSTRING(str)->as.heap.ptr =
ALLOC_N(
char, (
size_t)capa + termlen);
1533 #ifdef NONASCII_MASK 1534 #define is_utf8_lead_byte(c) (((c)&0xC0) != 0x80) 1550 count_utf8_lead_bytes_with_word(
const uintptr_t *s)
1555 d = (d>>6) | (~d>>7);
1556 d &= NONASCII_MASK >> 7;
1559 #if defined(HAVE_BUILTIN___BUILTIN_POPCOUNT) && defined(__POPCNT__) 1565 # if SIZEOF_VOIDP == 8 1580 long diff = (long)(e - p);
1583 #ifdef NONASCII_MASK 1586 if ((
int)
sizeof(
uintptr_t) * 2 < e - p) {
1591 while (p < (
const char *)s) {
1592 if (is_utf8_lead_byte(*p)) len++;
1596 len += count_utf8_lead_bytes_with_word(s);
1599 p = (
const char *)s;
1602 if (is_utf8_lead_byte(*p)) len++;
1639 for (c=0; p<e; c++) {
1663 long diff = (long)(e - p);
1693 for (c=0; p<e; c++) {
1804 char *ptr1, *ptr2, *ptr3;
1818 memcpy(ptr3, ptr1, len1);
1819 memcpy(ptr3+len1, ptr2, len2);
1873 while (n <= len/2) {
1874 memcpy(ptr2 + n, ptr2, n);
1877 memcpy(ptr2 + n, ptr2, len-n);
1953 long capa = len + expand;
1955 if (len > capa) len =
capa;
1958 ptr =
RSTRING(str)->as.heap.ptr;
1966 ptr =
ALLOC_N(
char, (
size_t)capa + termlen);
1969 memcpy(ptr, oldptr, len);
2003 else if (expand > 0) {
2026 RSTRING(str)->as.heap.ptr = 0;
2027 RSTRING(str)->as.heap.len = 0;
2061 for (; n > 0; --n) {
2070 const char *e = s +
len;
2109 if (capa - len < termlen) {
2114 if (termlen > oldtermlen)
2121 RSTRING(str)->as.heap.aux.capa = capa - termlen;
2123 if (termlen > oldtermlen) {
2146 if (!s || memchr(s, 0, len)) {
2198 const char *p2, *e2;
2201 while (p < e && 0 < nth) {
2228 while (p < e && nth--) {
2260 const char *pp =
str_nth(p, e, nth, enc, singlebyte);
2261 if (!pp)
return e - p;
2272 #ifdef NONASCII_MASK 2274 str_utf8_nth(
const char *p,
const char *e,
long *nthp)
2277 if ((
int)SIZEOF_VOIDP * 2 < e - p && (
int)SIZEOF_VOIDP * 2 < nth) {
2279 const uintptr_t lowbits = SIZEOF_VOIDP - 1;
2282 while (p < (
const char *)s) {
2283 if (is_utf8_lead_byte(*p)) nth--;
2287 nth -= count_utf8_lead_bytes_with_word(s);
2289 }
while (s < t && (
int)SIZEOF_VOIDP <= nth);
2293 if (is_utf8_lead_byte(*p)) {
2294 if (nth == 0)
break;
2304 str_utf8_offset(
const char *p,
const char *e,
long nth)
2306 const char *pp = str_utf8_nth(p, e, &nth);
2332 RSTRING(str2)->as.heap.ptr += beg;
2333 olen =
RSTRING(str2)->as.heap.len;
2334 if (olen > len)
RSTRING(str2)->as.heap.len =
len;
2356 if (len < 0)
return 0;
2361 if (beg > blen)
return 0;
2364 if (beg < 0)
return 0;
2366 if (len > blen - beg)
2368 if (len < 0)
return 0;
2373 if (len > -beg) len = -beg;
2387 if (beg < 0)
return 0;
2389 if (len == 0)
goto end;
2399 #ifdef NONASCII_MASK 2402 p = str_utf8_nth(s, e, &beg);
2403 if (beg > 0)
return 0;
2404 len = str_utf8_offset(p, e, len);
2410 p = s + beg * char_sz;
2414 else if (len * char_sz > e - p)
2419 else if ((p =
str_nth_len(s, e, &beg, enc)) == e) {
2420 if (beg > 0)
return 0;
2446 if (!p)
return Qnil;
2452 RSTRING(str2)->as.heap.ptr += ofs;
2456 if (!len && !empty)
return Qnil;
2515 #define rb_str_dup_frozen rb_str_new_frozen 2555 rb_bug(
"probable buffer overflow: %ld for %ld", len, capa);
2579 if (len == slen)
return str;
2590 if (slen > len) slen =
len;
2597 else if (!independent) {
2598 if (len == slen)
return str;
2601 else if ((capa =
RSTRING(str)->
as.heap.aux.capa) < len ||
2602 (capa - len) > (len < 1024 ? len : 1024)) {
2606 else if (len == slen)
return str;
2616 long capa, total, olen, off = -1;
2622 if (ptr >= sptr && ptr <= sptr + olen) {
2626 if (len == 0)
return 0;
2633 capa =
RSTRING(str)->as.heap.aux.capa;
2634 sptr =
RSTRING(str)->as.heap.ptr;
2635 olen =
RSTRING(str)->as.heap.len;
2645 while (total > capa) {
2646 capa = 2 * capa + termlen;
2654 memcpy(sptr + olen, ptr, len);
2661 #define str_buf_cat2(str, ptr) str_buf_cat((str), (ptr), strlen(ptr)) 2666 if (len == 0)
return str;
2685 rb_enc_cr_str_buf_cat(
VALUE str,
const char *ptr,
long len,
2686 int ptr_encindex,
int ptr_cr,
int *ptr_cr_ret)
2695 if (str_encindex == ptr_encindex) {
2723 *ptr_cr_ret = ptr_cr;
2725 if (str_encindex != ptr_encindex &&
2736 res_encindex = str_encindex;
2741 res_encindex = str_encindex;
2745 res_encindex = ptr_encindex;
2750 res_encindex = str_encindex;
2757 res_encindex = str_encindex;
2773 return rb_enc_cr_str_buf_cat(str, ptr, len,
2784 return rb_enc_cr_str_buf_cat(str, ptr,
strlen(ptr),
2790 unsigned int c = (
unsigned char)*ptr;
2793 rb_enc_cr_str_buf_cat(str, buf, len,
2832 for (i = 1; i < num; ++i) {
2833 const VALUE v = strary[i];
2880 for (i = 0; i <
argc; i++) {
2914 buf[0] = (char)code;
2975 for (i = 0; i <
argc; i++) {
2998 const char *ptr1, *ptr2;
3001 return (len1 != len2 ||
3003 memcmp(ptr1, ptr2, len1) != 0);
3022 #define lesser(a,b) (((a)>(b))?(b):(a)) 3034 if (idx1 == idx2)
return TRUE;
3053 const char *ptr1, *ptr2;
3056 if (str1 == str2)
return 0;
3059 if (ptr1 == ptr2 || (retval =
memcmp(ptr1, ptr2,
lesser(len1, len2))) == 0) {
3068 if (len1 > len2)
return 1;
3071 if (retval > 0)
return 1;
3080 const char *ptr1, *ptr2;
3086 if (
memcmp(ptr1, ptr2, len) == 0)
3107 if (str1 == str2)
return Qtrue;
3127 if (str1 == str2)
return Qtrue;
3197 char *p1, *p1end, *p2, *p2end;
3208 while (p1 < p1end && p2 < p2end) {
3210 unsigned int c1 =
TOUPPER(*p1 & 0xff);
3211 unsigned int c2 =
TOUPPER(*p2 & 0xff);
3213 return INT2FIX(c1 < c2 ? -1 : 1);
3220 while (p1 < p1end && p2 < p2end) {
3224 if (0 <= c1 && 0 <= c2) {
3228 return INT2FIX(c1 < c2 ? -1 : 1);
3234 len = l1 < l2 ? l1 : l2;
3237 return INT2FIX(r < 0 ? -1 : 1);
3239 return INT2FIX(l1 < l2 ? -1 : 1);
3268 VALUE folded_str1, folded_str2;
3283 #define rb_str_index(str, sub, offset) rb_strseq_index(str, sub, offset, 0) 3288 const char *s, *sptr, *e;
3289 long pos,
len, slen;
3300 if (offset < 0)
return -1;
3302 if (len - offset < slen)
return -1;
3307 if (!in_byte) offset =
str_offset(s, e, offset, enc, single_byte);
3310 if (slen == 0)
return offset;
3318 if (pos < 0)
return pos;
3320 if (t == s + pos)
break;
3322 if (len <= 0)
return -1;
3326 return pos + offset;
3354 if (
rb_scan_args(argc, argv,
"11", &sub, &initpos) == 2) {
3400 if (pos == -1)
return Qnil;
3408 char *hit, *adjusted;
3410 long slen, searchlen;
3414 if (slen == 0)
return pos;
3419 searchlen = s - sbeg + 1;
3422 hit = memrchr(sbeg, c, searchlen);
3425 if (hit != adjusted) {
3426 searchlen = adjusted - sbeg;
3429 if (
memcmp(hit, t, slen) == 0)
3431 searchlen = adjusted - sbeg;
3432 }
while (searchlen > 0);
3449 if (
memcmp(s, t, slen) == 0) {
3452 if (pos == 0)
break;
3476 if (len < slen)
return -1;
3477 if (len - pos < slen) pos = len - slen;
3478 if (len == 0)
return pos;
3520 if (
rb_scan_args(argc, argv,
"11", &sub, &vpos) == 2) {
3531 if (pos > len) pos =
len;
3546 if (pos >= 0)
return LONG2NUM(pos);
3563 if (pos >= 0)
return LONG2NUM(pos);
3708 for (i = len-1; 0 <= i && (
unsigned char)p[i] == 0xff; i--)
3712 ++((
unsigned char*)p)[i];
3720 memset(p+l, 0xff, len-l);
3726 for (len2 = len-1; 0 < len2; len2--) {
3731 memset(p+len2+1, 0xff, len-(len2+1));
3761 for (i = len-1; 0 <= i && (
unsigned char)p[i] == 0; i--)
3765 --((
unsigned char*)p)[i];
3773 memset(p+l, 0, len-l);
3779 for (len2 = len-1; 0 < len2; len2--) {
3784 memset(p+len2+1, 0, len-(len2+1));
3809 const int max_gaps = 1;
3819 MEMCPY(save, p,
char, len);
3820 for (
try = 0;
try <= max_gaps; ++
try) {
3828 MEMCPY(p, save,
char, len);
3831 MEMCPY(save, p,
char, len);
3836 MEMCPY(p, save,
char, len);
3841 MEMCPY(p, save,
char, len);
3851 MEMCPY(carry, p,
char, len);
3855 MEMCPY(carry, p,
char, len);
3902 char *sbeg, *s, *e, *last_alnum = 0;
3906 long carry_pos = 0, carry_len = 1;
3910 if (slen == 0)
return str;
3914 s = e = sbeg + slen;
3938 carry_pos = s - sbeg;
3967 MEMCPY(carry, s,
char, l);
3970 carry_pos = s - sbeg;
3975 s = sbeg + carry_pos;
3976 memmove(s + carry_len, s, slen - carry_pos);
4057 VALUE end, exclusive;
4067 VALUE current, after_end;
4081 if (c > e || (excl && c == e))
return beg;
4084 if (!excl && c == e)
break;
4086 if (excl && c == e)
break;
4106 if (excl && bi == ei)
break;
4107 if ((*each)(
rb_enc_sprintf(usascii,
"%.*ld", width, bi), arg))
break;
4112 ID op = excl ?
'<' :
idLE;
4126 if (n > 0 || (excl && n == 0))
return beg;
4134 if ((*each)(current, arg))
break;
4135 if (
NIL_P(next))
break;
4150 if (!
rb_equal(str, *argp))
return 0;
4179 if (b <= v && v < e)
return Qtrue;
4180 if (!
RTEST(exclusive) && v == e)
return Qtrue;
4337 if (len > olen) len = olen;
4345 memmove(ptr, oldptr + len, nlen);
4351 RSTRING(str)->as.heap.len = nlen;
4364 if (beg == 0 && vlen == 0) {
4381 slen - (beg + len));
4383 if (vlen < beg && len < 0) {
4384 MEMZERO(sptr + slen,
char, -len);
4415 if (beg + slen < 0) {
4422 if (len > slen - beg) {
4440 #define rb_str_splice(str, beg, len, val) rb_str_update(str, beg, len, val) 4447 long start, end,
len;
4493 switch (
TYPE(indx)) {
4623 for (i=0; i<
argc; i++) {
4628 if (!
NIL_P(result)) {
4692 if (set_backref_str) {
4772 if (iter || !
NIL_P(hash)) {
4820 memmove(p + beg0 + rlen, p + beg0 + plen, len - beg0 - plen);
4822 memcpy(p + beg0, rp, rlen);
4890 long beg, beg0, end0;
4891 long offset, blen, slen,
len,
last;
4892 enum {STR, ITER, MAP} mode = STR;
4895 int need_backref = -1;
4921 if (bang)
return Qnil;
4962 else if (need_backref) {
4964 if (need_backref < 0) {
4965 need_backref = val != repl;
4974 len = beg0 - offset;
4991 offset = end0 +
len;
5031 return str_gsub(argc, argv, str, 1);
5081 return str_gsub(argc, argv, str, 0);
5100 if (str == str2)
return str;
5178 char *head, *
ptr, *left = 0;
5182 if (pos < -len || len <= pos)
5231 if (beg > n || len < 0)
return Qnil;
5234 if (beg < 0)
return Qnil;
5239 if (!empty)
return Qnil;
5249 RSTRING(str2)->as.heap.ptr += beg;
5455 if (i == -1)
return Qfalse;
5486 if (argc == 0) base = 10;
5552 #define CHAR_ESC_LEN 13 5567 else if (c < 0x10000) {
5594 const char *prev = p;
5604 if (p > prev)
str_buf_cat(result, prev, p - prev);
5607 n = (int)(pend - p);
5619 case '\n': cc =
'n';
break;
5620 case '\r': cc =
'r';
break;
5621 case '\t': cc =
't';
break;
5622 case '\f': cc =
'f';
break;
5623 case '\013': cc =
'v';
break;
5624 case '\010': cc =
'b';
break;
5625 case '\007': cc =
'a';
break;
5626 case 033: cc =
'e';
break;
5627 default: cc = 0;
break;
5630 if (p - n > prev)
str_buf_cat(result, prev, p - n - prev);
5639 if (p - n > prev)
str_buf_cat(result, prev, p - n - prev);
5644 if (p > prev)
str_buf_cat(result, prev, p - prev);
5668 const char *p, *pend, *prev;
5683 if (actenc != enc) {
5693 if (p > prev)
str_buf_cat(result, prev, p - prev);
5696 n = (int)(pend - p);
5707 if ((asciicompat || unicode_p) &&
5708 (c ==
'"'|| c ==
'\\' ||
5713 (cc ==
'$' || cc ==
'@' || cc ==
'{'))))) {
5714 if (p - n > prev)
str_buf_cat(result, prev, p - n - prev);
5716 if (asciicompat || enc == resenc) {
5722 case '\n': cc =
'n';
break;
5723 case '\r': cc =
'r';
break;
5724 case '\t': cc =
't';
break;
5725 case '\f': cc =
'f';
break;
5726 case '\013': cc =
'v';
break;
5727 case '\010': cc =
'b';
break;
5728 case '\007': cc =
'a';
break;
5729 case 033: cc =
'e';
break;
5730 default: cc = 0;
break;
5733 if (p - n > prev)
str_buf_cat(result, prev, p - n - prev);
5745 if (p - n > prev)
str_buf_cat(result, prev, p - n - prev);
5751 if (p > prev)
str_buf_cat(result, prev, p - prev);
5758 #define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{')) 5776 const char *p, *pend;
5780 static const char nonascii_suffix[] =
".force_encoding(\"%s\")";
5791 unsigned char c = *p++;
5794 case '"':
case '\\':
5795 case '\n':
case '\r':
5796 case '\t':
case '\f':
5797 case '\013':
case '\010':
case '\007':
case '\033':
5810 if (u8 && c > 0x7F) {
5816 else if (cc <= 0xFFFFF)
5841 unsigned char c = *p++;
5843 if (c ==
'"' || c ==
'\\') {
5847 else if (c ==
'#') {
5848 if (
IS_EVSTR(p, pend)) *q++ =
'\\';
5851 else if (c ==
'\n') {
5855 else if (c ==
'\r') {
5859 else if (c ==
'\t') {
5863 else if (c ==
'\f') {
5867 else if (c ==
'\013') {
5871 else if (c ==
'\010') {
5875 else if (c ==
'\007') {
5879 else if (c ==
'\033') {
5969 #define CASE_MAPPING_ADDITIONAL_LENGTH 20 5970 #ifndef CASEMAP_DEBUG 5971 # define CASEMAP_DEBUG 0 5988 int target_length = 0;
5990 *current_buffer = &pre_buffer;
5991 size_t buffer_count = 0;
5992 int buffer_length_or_invalid;
5999 while (source_current < source_end) {
6003 fprintf(stderr,
"Buffer allocation, capa is %"PRIuSIZE"\n", capa);
6006 current_buffer = current_buffer->
next;
6009 buffer_length_or_invalid = enc->
case_map(flags,
6010 (
const OnigUChar**)&source_current, source_end,
6011 current_buffer->
space,
6012 current_buffer->
space+current_buffer->
capa,
6014 if (buffer_length_or_invalid < 0) {
6017 current_buffer = pre_buffer.
next;
6018 while (current_buffer) {
6019 previous_buffer = current_buffer;
6020 current_buffer = current_buffer->
next;
6021 xfree(previous_buffer);
6025 target_length += current_buffer->
used = buffer_length_or_invalid;
6028 fprintf(stderr,
"Buffer count is %"PRIuSIZE"\n", buffer_count);
6031 if (buffer_count==1) {
6033 xfree(current_buffer);
6036 char *target_current;
6041 current_buffer=pre_buffer.
next;
6042 while (current_buffer) {
6044 target_current += current_buffer->
used;
6045 previous_buffer = current_buffer;
6046 current_buffer = current_buffer->
next;
6047 xfree(previous_buffer);
6064 int length_or_invalid;
6066 if (old_length == 0)
return;
6072 (
const OnigUChar**)&source_current, source_end,
6073 source_current, source_end, enc);
6074 if (length_or_invalid < 0)
6077 fprintf(stderr,
"problem with rb_str_ascii_casemap" 6078 "; old_length=%ld, new_length=%d\n", old_length, length_or_invalid);
6080 "; old_length=%ld, new_length=%d\n", old_length, length_or_invalid);
6110 unsigned int c = *(
unsigned char*)s;
6113 *s =
'A' + (c -
'a');
6119 else if (flags&ONIGENC_CASE_ASCII_ONLY)
6176 unsigned int c = *(
unsigned char*)s;
6179 *s =
'a' + (c -
'A');
6185 else if (flags&ONIGENC_CASE_ASCII_ONLY)
6384 if (t->
p == t->
pend)
return -1;
6392 if (t->
p < t->
pend) {
6396 if (t->
now < 0x80 && c < 0x80) {
6398 "invalid range \"%c-%c\" in string transliteration",
6435 const unsigned int errc = -1;
6436 unsigned int trans[256];
6438 struct tr trsrc, trrepl;
6440 unsigned int c, c0,
last = 0;
6441 int modify = 0, i, l;
6448 #define CHECK_IF_ASCII(c) \ 6449 (void)((cr == ENC_CODERANGE_7BIT && !rb_isascii(c)) ? \ 6450 (cr = ENC_CODERANGE_VALID) : 0) 6471 trsrc.
p + l < trsrc.
pend) {
6477 trsrc.
gen = trrepl.
gen = 0;
6478 trsrc.
now = trrepl.
now = 0;
6479 trsrc.
max = trrepl.
max = 0;
6482 for (i=0; i<256; i++) {
6485 while ((c =
trnext(&trsrc, enc)) != errc) {
6494 while ((c =
trnext(&trrepl, enc)) != errc)
6497 for (i=0; i<256; i++) {
6498 if (trans[i] != errc) {
6506 for (i=0; i<256; i++) {
6509 while ((c =
trnext(&trsrc, enc)) != errc) {
6510 r =
trnext(&trrepl, enc);
6511 if (r == errc) r = trrepl.
now;
6531 unsigned int save = -1;
6547 if (cflag) c =
last;
6550 else if (cflag) c = errc;
6556 if (c != (
unsigned int)-1) {
6568 if (enc != e1) may_modify = 1;
6570 if ((offset = t - buf) + tlen > max) {
6571 max = offset + tlen + (send - s);
6576 if (may_modify &&
memcmp(s, t, tlen) != 0) {
6593 c = (
unsigned char)*s;
6594 if (trans[c] != errc) {
6611 long offset,
max = (long)((send - s) * 1.2);
6625 if (cflag) c =
last;
6628 else if (cflag) c = errc;
6632 c = cflag ?
last : errc;
6640 if (enc != e1) may_modify = 1;
6642 if ((offset = t - buf) + tlen > max) {
6643 max = offset + tlen + (long)((send - s) * 1.2);
6649 if (may_modify &&
memcmp(s, t, tlen) != 0) {
6689 return tr_trans(str, src, repl, 0);
6736 #define TR_TABLE_SIZE 257 6741 const unsigned int errc = -1;
6745 VALUE table = 0, ptable = 0;
6746 int i, l, cflag = 0;
6756 for (i=0; i<256; i++) {
6759 stable[256] = cflag;
6761 else if (stable[256] && !cflag) {
6764 for (i=0; i<256; i++) {
6768 while ((c =
trnext(&tr, enc)) != errc) {
6770 buf[c & 0xff] = !cflag;
6775 if (!table && (first || *tablep || stable[256])) {
6792 for (i=0; i<256; i++) {
6793 stable[i] = stable[i] && buf[i];
6795 if (!table && !cflag) {
6805 return table[c] != 0;
6837 VALUE del = 0, nodel = 0;
6839 int i, ascompat, cr;
6843 for (i=0; i<
argc; i++) {
6860 if (ascompat && (c = *(
unsigned char*)s) < 0x80) {
6873 if (
tr_find(c, squeez, del, nodel)) {
6888 if (modify)
return str;
6929 VALUE del = 0, nodel = 0;
6939 for (i=0; i<
argc; i++) {
6959 unsigned int c = *(
unsigned char*)s++;
6960 if (c != save || (argc > 0 && !squeez[c])) {
6970 if (ascompat && (c = *(
unsigned char*)s) < 0x80) {
6971 if (c != save || (argc > 0 && !squeez[c])) {
6979 if (c != save || (argc > 0 && !
tr_find(c, squeez, del, nodel))) {
6995 if (modify)
return str;
7035 return tr_trans(str, src, repl, 1);
7093 VALUE del = 0, nodel = 0, tstr;
7117 if (*(
unsigned char*)s++ == c) n++;
7124 for (i=1; i<
argc; i++) {
7139 if (ascompat && (c = *(
unsigned char*)s) < 0x80) {
7148 if (
tr_find(c, table, del, nodel)) {
7163 if (
NIL_P(val))
return 0;
7169 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
7170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7171 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7172 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7176 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7178 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7181 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7182 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7183 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
7187 #define ascii_isspace(c) isspacetable[(unsigned char)(c)] 7246 enum {awk, string, regexp} split_type;
7247 long beg, end, i = 0;
7251 if (
rb_scan_args(argc, argv,
"02", &spat, &limit) == 2) {
7253 if (lim <= 0) limit =
Qnil;
7254 else if (lim == 1) {
7263 split_type = regexp;
7273 if (split_type != awk) {
7278 split_type = string;
7282 split_type = regexp;
7301 if (split_type == awk) {
7310 while (ptr < eptr) {
7311 c = (
unsigned char)*ptr++;
7319 if (!
NIL_P(limit) && lim <= i)
break;
7326 if (!
NIL_P(limit)) ++i;
7334 while (ptr < eptr) {
7346 if (!
NIL_P(limit) && lim <= i)
break;
7353 if (!
NIL_P(limit)) ++i;
7361 else if (split_type ==
string) {
7370 while (ptr < eptr &&
7371 (end =
rb_memsearch(sptr, slen, ptr, eptr - ptr, enc)) >= 0) {
7374 if (t != ptr + end) {
7380 if (!
NIL_P(limit) && lim <= ++i)
break;
7394 if (start == end &&
BEG(0) ==
END(0)) {
7399 else if (last_null == 1) {
7417 beg = start =
END(0);
7421 for (idx=1; idx < regs->
num_regs; idx++) {
7422 if (
BEG(idx) == -1)
continue;
7423 if (
BEG(idx) ==
END(idx))
7429 if (!
NIL_P(limit) && lim <= ++i)
break;
7439 if (
NIL_P(limit) && lim == 0) {
7477 const char *
ptr, *pend, *subptr, *subend, *rsptr, *hit, *adjusted;
7478 long pos,
len, rslen;
7479 int paragraph_mode = 0;
7487 static ID keywords[1];
7497 #if STRING_ENUMERATORS_WANTARRAY 7498 rb_warn(
"given block not used");
7501 rb_warning(
"passing a block to String#lines is deprecated");
7557 while (subptr < pend) {
7558 pos =
rb_memsearch(rsptr, rslen, subptr, pend - subptr, enc);
7562 if (hit != adjusted) {
7566 subend = hit + rslen;
7567 if (paragraph_mode) {
7568 while (subend < pend) {
7597 if (subptr != pend) {
7598 if (chomp && paragraph_mode) {
7688 #if STRING_ENUMERATORS_WANTARRAY 7689 rb_warn(
"given block not used");
7692 rb_warning(
"passing a block to String#bytes is deprecated");
7777 #if STRING_ENUMERATORS_WANTARRAY 7778 rb_warn(
"given block not used");
7781 rb_warning(
"passing a block to String#chars is deprecated");
7794 for (i = 0; i <
len; i += n) {
7804 for (i = 0; i <
len; i += n) {
7865 const char *
ptr, *end;
7879 #if STRING_ENUMERATORS_WANTARRAY 7880 rb_warn(
"given block not used");
7883 rb_warning(
"passing a block to String#codepoints is deprecated");
7957 const char *p, *p2, *beg, *end;
7961 if (beg > end)
return 0;
8027 char *pp, *e, *rsptr;
8032 if (len == 0)
return 0;
8053 if (--e > p && *(e-1) ==
'\r') {
8083 while (e > p && *(e-1) ==
'\n') {
8085 if (e > p && *(e-1) ==
'\r')
8091 if (rslen > len)
return len;
8094 newline = rsptr[rslen-1];
8097 if (newline ==
'\n')
8111 if (p[len-1] == newline &&
8113 memcmp(rsptr, pp, rslen) == 0)) {
8140 if (len >= olen)
return Qnil;
8202 const char *
const start = s;
8204 if (!s || s >= e)
return 0;
8249 long len = olen-loffset;
8250 s = start + loffset;
8253 #if !SHARABLE_MIDDLE_SUBSTRING 8292 if (!s || s >= e)
return 0;
8298 while (s < t && ((c = *(t-1)) ==
'\0' ||
ascii_isspace(c))) t--;
8339 long len = olen - roffset;
8342 #if !SHARABLE_MIDDLE_SUBSTRING 8394 long olen, loffset, roffset;
8401 roffset =
rstrip_offset(str, start+loffset, start+olen, enc);
8403 if (loffset > 0 || roffset > 0) {
8404 long len = olen-roffset;
8407 memmove(start, start + loffset, len);
8410 #if !SHARABLE_MIDDLE_SUBSTRING 8437 long olen, loffset, roffset;
8442 roffset =
rstrip_offset(str, start+loffset, start+olen, enc);
8444 if (loffset <= 0 && roffset <= 0)
return rb_str_dup(str);
8476 for (i=1; i < regs->
num_regs; i++) {
8522 long last = -1, prev = 0;
8618 extern char *
crypt(
const char *,
const char *);
8621 const char *s, *saltp;
8624 char salt_8bit_clean[3];
8637 if (!saltp[0] || !saltp[1])
goto short_salt;
8639 if (!
ISASCII((
unsigned char)saltp[0]) || !
ISASCII((
unsigned char)saltp[1])) {
8640 salt_8bit_clean[0] = saltp[0] & 0x7f;
8641 salt_8bit_clean[1] = saltp[1] & 0x7f;
8642 salt_8bit_clean[2] =
'\0';
8643 saltp = salt_8bit_clean;
8647 # ifdef HAVE_STRUCT_CRYPT_DATA_INITIALIZED 8648 data.initialized = 0;
8650 res =
crypt_r(s, saltp, &data);
8652 res =
crypt(s, saltp);
8696 char *
ptr, *p, *pend;
8699 unsigned long sum0 = 0;
8720 sum0 += (
unsigned char)*p;
8731 if (bits < (
int)
sizeof(
long)*
CHAR_BIT) {
8732 sum0 &= (((
unsigned long)1)<<bits)-1;
8756 long width,
len, flen = 1, fclen = 1;
8759 const char *
f =
" ";
8760 long n,
size, llen, rlen, llen2 = 0, rlen2 = 0;
8762 int singlebyte = 1, cr;
8776 if (flen == 0 || fclen == 0) {
8781 if (width < 0 || len >= width)
return rb_str_dup(str);
8783 llen = (jflag ==
'l') ? 0 : ((jflag ==
'r') ? n : n/2);
8787 llen2 =
str_offset(f, f + flen, llen % fclen, enc, singlebyte);
8788 rlen2 =
str_offset(f, f + flen, rlen % fclen, enc, singlebyte);
8791 if ((len = llen / fclen + rlen / fclen) >=
LONG_MAX / flen ||
8792 (len *= flen) >=
LONG_MAX - llen2 - rlen2 ||
8793 (len += llen2 + rlen2) >=
LONG_MAX - size) {
8800 memset(p, *f, llen);
8804 while (llen >= fclen) {
8817 memset(p, *f, rlen);
8821 while (rlen >= fclen) {
8933 if (pos == 0 &&
RSTRING_LEN(sep) == 0)
goto failed;
8937 if (pos < 0)
goto failed;
9015 for (i=0; i<
argc; i++) {
9016 VALUE tmp = argv[i];
9046 for (i=0; i<
argc; i++) {
9047 VALUE tmp = argv[i];
9077 "value of %"PRIsVALUE" must be String or Regexp",
9171 static const char ellipsis[] =
"...";
9172 const long ellipsislen =
sizeof(ellipsis) - 1;
9175 const char *
const p =
RSTRING_PTR(str), *e = p + blen;
9176 VALUE estr, ret = 0;
9180 (e =
rb_enc_nth(p, e, len, enc)) - p == blen) {
9183 else if (len <= ellipsislen ||
9278 #define DEFAULT_REPLACE_CHAR(str) do { \ 9279 static const char replace[sizeof(str)-1] = str; \ 9280 rep = replace; replen = (int)sizeof(replace); \ 9292 else if (!
NIL_P(repl)) {
9331 if (e - p < clen) clen = e - p;
9338 for (; clen > 1; clen--) {
9403 else if (!
NIL_P(repl)) {
9437 if (e - p < clen) clen = e - p;
9438 if (clen <= mbminlen * 2) {
9443 for (; clen > mbminlen; clen-=mbminlen) {
9581 #define sym_equal rb_obj_equal 9674 memcpy(dest + 1, ptr, len);
10015 #define rb_intern(str) rb_intern_const(str) static int str_independent(VALUE str)
static VALUE rb_str_casecmp_p(VALUE str1, VALUE str2)
static VALUE str_uminus(VALUE str)
static VALUE rb_str_upcase_bang(int argc, VALUE *argv, VALUE str)
#define RBASIC_CLEAR_CLASS(obj)
int rb_enc_str_asciionly_p(VALUE str)
VALUE rb_utf8_str_new(const char *ptr, long len)
static long chopped_length(VALUE str)
VALUE rb_str_resize(VALUE str, long len)
#define ENCINDEX_US_ASCII
VALUE rb_external_str_with_enc(VALUE str, rb_encoding *eenc)
static VALUE str_replace_shared_without_enc(VALUE str2, VALUE str)
int rb_enc_codelen(int c, rb_encoding *enc)
int rb_enc_get_index(VALUE obj)
static VALUE rb_str_bytesize(VALUE str)
static void str_make_independent(VALUE str)
int rb_reg_backref_number(VALUE match, VALUE backref)
#define BARE_STRING_P(str)
static VALUE str_buf_cat(VALUE str, const char *ptr, long len)
#define ONIGENC_CODE_TO_MBCLEN(enc, code)
#define is_broken_string(str)
#define MBCLEN_CHARFOUND_P(ret)
static long rb_str_rindex(VALUE str, VALUE sub, long pos)
static OnigCaseFoldType check_case_options(int argc, VALUE *argv, OnigCaseFoldType flags)
rb_encoding * rb_enc_check(VALUE str1, VALUE str2)
VALUE rb_ary_pop(VALUE ary)
#define MBCLEN_CHARFOUND_LEN(ret)
#define RESIZE_CAPA(str, capacity)
void rb_bug(const char *fmt,...)
#define rb_enc_mbc_to_codepoint(p, e, enc)
VALUE rb_ary_new_capa(long capa)
VALUE rb_usascii_str_new_static(const char *ptr, long len)
void rb_enc_copy(VALUE obj1, VALUE obj2)
size_t strlen(const char *)
static VALUE str_upto_each(VALUE beg, VALUE end, int excl, int(*each)(VALUE, VALUE), VALUE)
VALUE rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl)
#define CHECK_IF_ASCII(c)
void rb_backref_set(VALUE)
#define ENCODING_CODERANGE_SET(obj, encindex, cr)
RUBY_FUNC_EXPORTED VALUE rb_str_locktmp_ensure(VALUE str, VALUE(*func)(VALUE), VALUE arg)
static int sym_printable(const char *s, const char *send, rb_encoding *enc)
VALUE rb_str_equal(VALUE str1, VALUE str2)
VALUE rb_str_new_static(const char *ptr, long len)
static rb_encoding * get_actual_encoding(const int encidx, VALUE str)
static int max(int a, int b)
VALUE rb_locale_str_new_cstr(const char *ptr)
#define ENCINDEX_UTF_16LE
VALUE rb_sym_to_s(VALUE sym)
static int coderange_scan(const char *p, long len, rb_encoding *enc)
static unsigned int hash(str, len) register const char *str
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
void rb_undef_alloc_func(VALUE)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb_encoding *enc)
static VALUE rb_str_to_f(VALUE str)
VALUE rb_str_new_frozen(VALUE orig)
static VALUE rb_str_oct(VALUE str)
static VALUE str_compat_and_valid(VALUE str, rb_encoding *enc)
st_index_t rb_str_hash(VALUE str)
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *ptr_enc)
static long rb_strseq_index(VALUE str, VALUE sub, long offset, int in_byte)
static VALUE rb_str_scan(VALUE str, VALUE pat)
VALUE rb_locale_str_new(const char *ptr, long len)
static VALUE rb_str_gsub(int argc, VALUE *argv, VALUE str)
static int ntz_intptr(uintptr_t x)
static VALUE rb_str_match(VALUE x, VALUE y)
static VALUE rb_str_capitalize(int argc, VALUE *argv, VALUE str)
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
VALUE rb_reg_check_preprocess(VALUE)
void rb_str_set_len(VALUE str, long len)
static void rb_enc_cr_str_copy_for_substr(VALUE dest, VALUE src)
#define is_ascii_string(str)
static unsigned int trnext(struct tr *t, rb_encoding *enc)
#define ONIGERR_INVALID_CODE_POINT_VALUE
#define ENC_CODERANGE_SET(obj, cr)
VALUE rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc)
static VALUE rb_str_b(VALUE str)
VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc)
static VALUE rb_str_clear(VALUE str)
#define OBJ_FREEZE_RAW(x)
void rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen)
rb_encoding * rb_to_encoding(VALUE enc)
int rb_enc_dummy_p(rb_encoding *enc)
#define ENC_CODERANGE_CLEAR(obj)
void rb_econv_close(rb_econv_t *ec)
#define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc, s, end)
static VALUE sym_match_m(int argc, VALUE *argv, VALUE sym)
VALUE rb_enc_from_encoding(rb_encoding *encoding)
static VALUE str_gsub(int argc, VALUE *argv, VALUE str, int bang)
VALUE rb_reg_match(VALUE, VALUE)
long rb_memsearch(const void *, long, const void *, long, rb_encoding *)
static VALUE rb_str_succ_bang(VALUE str)
static VALUE rb_str_enumerate_bytes(VALUE str, int wantarray)
static VALUE rb_str_each_line(int argc, VALUE *argv, VALUE str)
rb_encoding * rb_default_internal_encoding(void)
VALUE rb_ary_push(VALUE ary, VALUE item)
SSL_METHOD *(* func)(void)
VALUE rb_reg_regsub(VALUE, VALUE, struct re_registers *, VALUE)
RUBY_EXTERN char * crypt(const char *, const char *)
st_index_t rb_memhash(const void *ptr, long len)
int rb_usascii_encindex(void)
VALUE rb_str_split(VALUE str, const char *sep0)
static VALUE rb_str_each_byte_size(VALUE str, VALUE args, VALUE eobj)
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
static VALUE rb_str_gsub_bang(int argc, VALUE *argv, VALUE str)
VALUE rb_str_export_to_enc(VALUE str, rb_encoding *enc)
#define ONIGENC_CTYPE_ALPHA
static int fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
void ruby_sized_xfree(void *x, size_t size)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
static VALUE rb_str_codepoints(VALUE str)
#define str_buf_cat2(str, ptr)
#define ENCINDEX_UTF_16BE
static VALUE rb_str_rstrip(VALUE str)
VALUE rb_filesystem_str_new(const char *ptr, long len)
VALUE rb_str_export(VALUE str)
static VALUE rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
#define RGENGC_WB_PROTECTED_STRING
unsigned int OnigCaseFoldType
static VALUE rb_str_include(VALUE str, VALUE arg)
static VALUE str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
static void rb_str_check_dummy_enc(rb_encoding *enc)
#define RBASIC_SET_CLASS(obj, cls)
VALUE rb_backref_get(void)
VALUE rb_str_freeze(VALUE str)
#define ENCODING_GET_INLINED(obj)
long rb_enc_strlen(const char *p, const char *e, rb_encoding *enc)
unsigned int rb_enc_codepoint_len(const char *p, const char *e, int *len_p, rb_encoding *enc)
static VALUE str_new0(VALUE klass, const char *ptr, long len, int termlen)
long rb_enc_strlen_cr(const char *p, const char *e, rb_encoding *enc, int *cr)
void rb_raise(VALUE exc, const char *fmt,...)
static VALUE str_replace(VALUE str, VALUE str2)
#define RSTRING_GETMEM(str, ptrvar, lenvar)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE *, VALUE)
static VALUE rb_str_to_i(int argc, VALUE *argv, VALUE str)
int rb_objspace_garbage_object_p(VALUE obj)
char * rb_string_value_ptr(volatile VALUE *ptr)
VALUE rb_convert_type(VALUE, int, const char *, const char *)
static VALUE rb_str_slice_bang(int argc, VALUE *argv, VALUE str)
VALUE rb_utf8_str_new_static(const char *ptr, long len)
static void mustnot_wchar(VALUE str)
VALUE rb_str_concat_literals(size_t num, const VALUE *strary)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
static VALUE rb_str_match_m_p(int argc, VALUE *argv, VALUE str)
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
static rb_encoding * get_encoding(VALUE str)
static VALUE rb_str_empty(VALUE str)
static VALUE rb_str_chars(VALUE str)
static VALUE rb_str_reverse_bang(VALUE str)
#define ENC_CODERANGE_MASK
void rb_include_module(VALUE klass, VALUE module)
static VALUE rb_str_center(int argc, VALUE *argv, VALUE str)
VALUE rb_hash_lookup(VALUE hash, VALUE key)
VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, VALUE passed_proc)
VALUE rb_range_beg_len(VALUE, long *, long *, long, int)
static VALUE sym_upcase(int argc, VALUE *argv, VALUE sym)
#define DEFAULT_REPLACE_CHAR(str)
double rb_str_to_dbl(VALUE, int)
RUBY_FUNC_EXPORTED size_t rb_str_memsize(VALUE str)
int st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg)
static VALUE rb_str_subpat(VALUE str, VALUE re, VALUE backref)
static int include_range_i(VALUE str, VALUE arg)
VALUE rb_str_new(const char *ptr, long len)
static VALUE rb_str_aset_m(int argc, VALUE *argv, VALUE str)
#define rb_enc_mbmaxlen(enc)
static const char * str_null_char(const char *s, long len, const int minlen, rb_encoding *enc)
static VALUE rb_str_format_m(VALUE str, VALUE arg)
#define STR_SET_NOEMBED(str)
void rb_gc_force_recycle(VALUE obj)
static long str_strlen(VALUE str, rb_encoding *enc)
static VALUE rb_str_chomp(int argc, VALUE *argv, VALUE str)
rb_encoding * rb_utf8_encoding(void)
VALUE rb_str_export_locale(VALUE str)
static VALUE sym_length(VALUE sym)
VALUE rb_str_new_shared(VALUE str)
void rb_undef_method(VALUE klass, const char *name)
static VALUE rb_tainted_str_new_with_enc(const char *ptr, long len, rb_encoding *enc)
static VALUE empty_str_alloc(VALUE klass)
static VALUE rb_str_hash_m(VALUE str)
static void mustnot_broken(VALUE str)
static int fstring_cmp(VALUE a, VALUE b)
static VALUE rb_str_aset(VALUE str, VALUE indx, VALUE val)
#define ONIGENC_CASE_MODIFIED
#define ENC_CODERANGE_7BIT
const char * rb_obj_classname(VALUE)
int rb_enc_symname_p(const char *, rb_encoding *)
VALUE rb_enc_sprintf(rb_encoding *enc, const char *format,...)
RUBY_EXTERN void * memmove(void *, const void *, size_t)
#define ONIGENC_CASE_FOLD_LITHUANIAN
static long lstrip_offset(VALUE str, const char *s, const char *e, rb_encoding *enc)
#define ONIGENC_CODE_TO_MBC_MAXLEN
static VALUE rb_str_insert(VALUE str, VALUE idx, VALUE str2)
VALUE rb_str_append(VALUE str, VALUE str2)
char * crypt_r(const char *key, const char *setting, struct crypt_data *data)
VALUE rb_str_buf_cat(VALUE, const char *, long)
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
static void str_make_independent_expand(VALUE str, long len, long expand, const int termlen)
VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc)
#define NEWOBJ_OF(obj, type, klass, flags)
static VALUE register_fstring(VALUE str)
void rb_exc_raise(VALUE mesg)
static VALUE sym_inspect(VALUE sym)
int rb_str_hash_cmp(VALUE str1, VALUE str2)
#define OBJ_INFECT_RAW(x, s)
static VALUE rb_str_partition(VALUE str, VALUE sep)
static VALUE rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
static long str_offset(const char *p, const char *e, long nth, rb_encoding *enc, int singlebyte)
#define STR_EMBEDDABLE_P(len, termlen)
#define rb_enc_isctype(c, t, enc)
#define RBASIC_SET_CLASS_RAW(obj, cls)
static VALUE rb_str_ljust(int argc, VALUE *argv, VALUE str)
#define RB_TYPE_P(obj, type)
static void str_shared_replace(VALUE str, VALUE str2)
int rb_enc_str_coderange(VALUE str)
static VALUE sym_match_m_p(int argc, VALUE *argv, VALUE sym)
static int fstring_set_class_i(st_data_t key, st_data_t val, st_data_t arg)
#define MEMZERO(p, type, n)
VALUE rb_str_plus(VALUE str1, VALUE str2)
static VALUE rb_str_setbyte(VALUE str, VALUE index, VALUE value)
rb_encoding * rb_default_external_encoding(void)
int rb_enc_to_index(rb_encoding *enc)
static VALUE str_new_frozen(VALUE klass, VALUE orig)
static long chompped_length(VALUE str, VALUE rs)
static void rb_str_ascii_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc)
static VALUE rb_str_strip(VALUE str)
#define rb_intern_str(string)
int rb_block_given_p(void)
static int all_digits_p(const char *s, long len)
static VALUE chomp_rs(int argc, const VALUE *argv)
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static VALUE rb_str_split_m(int argc, VALUE *argv, VALUE str)
static int single_byte_optimizable(VALUE str)
int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc)
static void rb_str_splice_0(VALUE str, long beg, long len, VALUE val)
RUBY_EXTERN VALUE rb_cObject
static VALUE sym_to_sym(VALUE sym)
#define rb_enc_isascii(c, enc)
VALUE rb_str_to_inum(VALUE str, int base, int badcheck)
static VALUE str_new_shared(VALUE klass, VALUE str)
#define MBCLEN_NEEDMORE_P(ret)
VALUE rb_str_length(VALUE str)
static VALUE rb_str_rpartition(VALUE str, VALUE sep)
VALUE rb_str_cat_cstr(VALUE str, const char *ptr)
static VALUE rb_str_crypt(VALUE str, VALUE salt)
VALUE rb_str_cat2(VALUE, const char *)
static VALUE rb_str_cmp_m(VALUE str1, VALUE str2)
static int str_dependent_p(VALUE str)
int rb_str_symname_p(VALUE sym)
#define OBJ_FROZEN_RAW(x)
static VALUE rb_str_prepend_multi(int argc, VALUE *argv, VALUE str)
static void rb_check_lockedtmp(VALUE str)
VALUE rb_str_new_cstr(const char *ptr)
static void str_modify_keep_cr(VALUE str)
VALUE rb_str_buf_cat2(VALUE, const char *)
rb_econv_t * rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts)
int rb_ascii8bit_encindex(void)
#define STR_SET_EMBED(str)
static VALUE rb_str_tr_s(VALUE str, VALUE src, VALUE repl)
static void rb_fs_setter(VALUE val, ID id, VALUE *var)
static VALUE rb_str_delete(int argc, VALUE *argv, VALUE str)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
#define rb_enc_step_back(s, p, e, n, enc)
#define ENC_CODERANGE_CLEAN_P(cr)
static VALUE rb_str_downcase_bang(int argc, VALUE *argv, VALUE str)
void rb_enc_set_index(VALUE obj, int idx)
static VALUE rb_str_enumerate_chars(VALUE str, int wantarray)
static VALUE rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, int wantarray)
static VALUE rb_str_tr_s_bang(VALUE str, VALUE src, VALUE repl)
VALUE rb_str_concat(VALUE str1, VALUE str2)
static VALUE rb_str_capitalize_bang(int argc, VALUE *argv, VALUE str)
static VALUE str_byte_substr(VALUE str, long beg, long len, int empty)
static VALUE get_pat(VALUE)
#define offsetof(p_type, field)
static size_t str_capacity(VALUE str, const int termlen)
static VALUE rb_fs_check(VALUE val)
st_table * rb_vm_fstring_table(void)
RUBY_ALIAS_FUNCTION(rb_str_dup_frozen(VALUE str), rb_str_new_frozen,(str))
static VALUE rb_str_strip_bang(VALUE str)
VALUE rb_str_scrub(VALUE str, VALUE repl)
char ary[RSTRING_EMBED_LEN_MAX+1]
long rb_str_offset(VALUE str, long pos)
#define STR_SET_EMBED_LEN(str, n)
#define ALLOCA_N(type, n)
static long rb_pat_search(VALUE pat, VALUE str, long pos, int set_backref_str)
#define range(low, item, hi)
#define ENC_CODERANGE_UNKNOWN
static const char * chomp_newline(const char *p, const char *e, rb_encoding *enc)
static VALUE rb_str_tr_bang(VALUE str, VALUE src, VALUE repl)
#define rb_enc_isprint(c, enc)
#define RUBY_FUNC_EXPORTED
#define MEMCPY(p1, p2, type, n)
#define ENC_CODERANGE_BROKEN
static int rb_isspace(int c)
VALUE rb_enc_associate_index(VALUE obj, int idx)
#define rb_str_index(str, sub, offset)
VALUE rb_obj_alloc(VALUE)
#define rb_enc_codepoint(p, e, enc)
void rb_str_update(VALUE str, long beg, long len, VALUE val)
#define rb_enc_mbminlen(enc)
static VALUE rb_str_each_char_size(VALUE str, VALUE args, VALUE eobj)
static VALUE rb_str_rjust(int argc, VALUE *argv, VALUE str)
VALUE rb_utf8_str_new_cstr(const char *ptr)
#define ENC_CODERANGE_VALID
#define RUBY_DTRACE_CREATE_HOOK(name, arg)
long rb_str_sublen(VALUE str, long pos)
RUBY_FUNC_EXPORTED VALUE rb_fstring(VALUE str)
VALUE rb_str_times(VALUE str, VALUE times)
static VALUE sym_lithuanian
VALUE rb_str_tmp_frozen_acquire(VALUE orig)
struct mapping_buffer mapping_buffer
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc)
static VALUE sym_cmp(VALUE sym, VALUE other)
void rb_str_modify_expand(VALUE str, long expand)
static VALUE str_eql(const VALUE str1, const VALUE str2)
static VALUE sym_encoding(VALUE sym)
VALUE rb_obj_as_string(VALUE obj)
#define RARRAY_CONST_PTR(a)
VALUE rb_str_subseq(VALUE str, long beg, long len)
#define REALLOC_N(var, type, n)
char * rb_string_value_cstr(volatile VALUE *ptr)
static VALUE sym_downcase(int argc, VALUE *argv, VALUE sym)
#define RUBY_MAX_CHAR_LEN
static void must_not_null(const char *ptr)
long rb_reg_search0(VALUE, VALUE, long, int, int)
static VALUE rb_str_byteslice(int argc, VALUE *argv, VALUE str)
static long str_rindex(VALUE str, VALUE sub, const char *s, long pos, rb_encoding *enc)
int(* case_map)(OnigCaseFoldType *flagP, const OnigUChar **pp, const OnigUChar *end, OnigUChar *to, OnigUChar *to_end, const struct OnigEncodingTypeST *enc)
static VALUE setup_fake_str(struct RString *fake_str, const char *name, long len, int encidx)
static VALUE str_succ(VALUE str)
VALUE rb_str_format(int, const VALUE *, VALUE)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
int rb_enc_unicode_p(rb_encoding *enc)
static VALUE string_for_symbol(VALUE name)
#define rb_strlen_lit(str)
#define ONIGENC_CASE_UPCASE
static VALUE rb_str_tr(VALUE str, VALUE src, VALUE repl)
static VALUE rb_str_chop_bang(VALUE str)
static VALUE str_new_empty(VALUE str)
static unsigned int nlz_intptr(uintptr_t x)
VALUE rb_str_escape(VALUE str)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static VALUE rb_str_enumerate_codepoints(VALUE str, int wantarray)
static VALUE rb_str_squeeze(int argc, VALUE *argv, VALUE str)
long rb_reg_search(VALUE, VALUE, long, int)
static VALUE str_duplicate(VALUE klass, VALUE str)
VALUE rb_check_hash_type(VALUE hash)
#define ONIGENC_CASE_FOLD
int rb_str_cmp(VALUE str1, VALUE str2)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_str_buf_new_cstr(const char *ptr)
rb_encoding * rb_usascii_encoding(void)
static VALUE rb_str_aref_m(int argc, VALUE *argv, VALUE str)
#define STRING(string, length)
static VALUE str_scrub_bang(int argc, VALUE *argv, VALUE str)
static VALUE rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
VALUE rb_sym_to_proc(VALUE sym)
#define FL_TEST_RAW(x, f)
static VALUE str_substr(VALUE str, long beg, long len, int empty)
static enum neighbor_char enc_pred_char(char *p, long len, rb_encoding *enc)
static int tr_find(unsigned int c, const char table[TR_TABLE_SIZE], VALUE del, VALUE nodel)
rb_encoding * rb_locale_encoding(void)
VALUE rb_str_replace(VALUE str, VALUE str2)
static VALUE rb_str_lstrip_bang(VALUE str)
#define rb_enc_is_newline(p, end, enc)
static VALUE str_new(VALUE klass, const char *ptr, long len)
static VALUE str_alloc(VALUE klass)
#define ONIGENC_CASE_DOWNCASE
static VALUE rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
#define ENC_CODERANGE_AND(a, b)
static VALUE rb_str_is_ascii_only_p(VALUE str)
int rb_utf8_encindex(void)
void rb_str_shared_replace(VALUE str, VALUE str2)
#define ENCODING_SET_INLINED(obj, i)
VALUE rb_obj_encoding(VALUE obj)
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
#define TERM_FILL(ptr, termlen)
#define ONIGENC_CASE_ASCII_ONLY
#define ONIGENC_CASE_TITLECASE
#define rb_enc_asciicompat(enc)
static VALUE rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
VALUE rb_str_buf_cat_ascii(VALUE str, const char *ptr)
int memcmp(const void *s1, const void *s2, size_t len)
VALUE rb_str_quote_unprintable(VALUE str)
static VALUE sym_casecmp(VALUE sym, VALUE other)
long rb_str_coderange_scan_restartable(const char *s, const char *e, rb_encoding *enc, int *cr)
static int zero_filled(const char *s, int n)
static char * str_nth_len(const char *p, const char *e, long *nthp, rb_encoding *enc)
#define RARRAY_LENINT(ary)
static VALUE rb_str_getbyte(VALUE str, VALUE index)
static void rb_enc_cr_str_exact_copy(VALUE dest, VALUE src)
void rb_str_tmp_frozen_release(VALUE orig, VALUE tmp)
void rb_sys_fail(const char *mesg)
static VALUE rb_str_chr(VALUE str)
#define ENCODING_IS_ASCII8BIT(obj)
static VALUE enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr)
static const char * search_nonascii(const char *p, const char *e)
static VALUE str_scrub(int argc, VALUE *argv, VALUE str)
static void str_modifiable(VALUE str)
VALUE rb_cEncodingConverter
static VALUE rb_str_bytes(VALUE str)
static VALUE rb_str_index_m(int argc, VALUE *argv, VALUE str)
VALUE rb_str_to_str(VALUE str)
VALUE rb_str_chomp_string(VALUE str, VALUE rs)
void rb_define_hooked_variable(const char *, VALUE *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
static VALUE rb_str_match_m(int argc, VALUE *argv, VALUE str)
static void str_mod_check(VALUE s, const char *p, long len)
static int rb_popcount_intptr(uintptr_t x)
VALUE rb_string_value(volatile VALUE *ptr)
static VALUE rb_str_lines(int argc, VALUE *argv, VALUE str)
VALUE rb_tainted_str_new_cstr(const char *ptr)
static const char isspacetable[256]
int rb_respond_to(VALUE, ID)
register unsigned int len
static VALUE scan_once(VALUE str, VALUE pat, long *start)
static VALUE rb_str_sub(int argc, VALUE *argv, VALUE str)
#define StringValueCStr(v)
VALUE rb_usascii_str_new(const char *ptr, long len)
VALUE rb_str_buf_append(VALUE str, VALUE str2)
static VALUE rb_str_s_try_convert(VALUE dummy, VALUE str)
RUBY_EXTERN VALUE rb_default_rs
static VALUE sym_succ(VALUE sym)
void rb_str_free(VALUE str)
static VALUE sym_swapcase(int argc, VALUE *argv, VALUE sym)
VALUE rb_filesystem_str_new_cstr(const char *ptr)
static VALUE rb_str_end_with(int argc, VALUE *argv, VALUE str)
struct mapping_buffer * next
#define rb_enc_right_char_head(s, p, e, enc)
static void str_enc_copy(VALUE str1, VALUE str2)
#define ENCODING_GET(obj)
VALUE rb_equal(VALUE, VALUE)
rb_encoding * rb_enc_get(VALUE obj)
#define STR_SET_SHARED(str, shared_str)
#define STR_HEAP_PTR(str)
static VALUE rb_str_hex(VALUE str)
char * rb_enc_nth(const char *p, const char *e, long nth, rb_encoding *enc)
static char * str_nth(const char *p, const char *e, long nth, rb_encoding *enc, int singlebyte)
static VALUE rb_str_reverse(VALUE str)
#define UNLIMITED_ARGUMENTS
char * rb_str_subpos(VALUE str, long beg, long *lenp)
VALUE rb_str_unlocktmp(VALUE str)
VALUE rb_tainted_str_new(const char *ptr, long len)
#define CASE_MAPPING_ADDITIONAL_LENGTH
#define MBCLEN_INVALID_P(ret)
static VALUE rb_str_valid_encoding_p(VALUE str)
#define RARRAY_AREF(a, i)
static VALUE rb_str_each_byte(VALUE str)
static VALUE rb_str_chop(VALUE str)
rb_econv_result_t rb_econv_convert(rb_econv_t *ec, const unsigned char **source_buffer_ptr, const unsigned char *source_buffer_end, unsigned char **destination_buffer_ptr, unsigned char *destination_buffer_end, int flags)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
static VALUE get_pat_quoted(VALUE pat, int check)
static long rstrip_offset(VALUE str, const char *s, const char *e, rb_encoding *enc)
static VALUE rb_str_count(int argc, VALUE *argv, VALUE str)
#define STR_SET_LEN(str, n)
static VALUE rb_str_eql(VALUE str1, VALUE str2)
static void rb_str_subpat_set(VALUE str, VALUE re, VALUE backref, VALUE val)
static VALUE rb_str_swapcase_bang(int argc, VALUE *argv, VALUE str)
#define RBASIC_CLASS(obj)
#define ONIGENC_MBCLEN_CHARFOUND_LEN(r)
static long enc_strlen(const char *p, const char *e, rb_encoding *enc, int cr)
static VALUE rb_str_lstrip(VALUE str)
#define RESIZE_CAPA_TERM(str, capacity, termlen)
VALUE rb_check_array_type(VALUE ary)
VALUE rb_hash_aref(VALUE hash, VALUE key)
static enum neighbor_char enc_succ_alnum_char(char *p, long len, rb_encoding *enc, char *carry)
static VALUE sym_match(VALUE sym, VALUE other)
#define UNALIGNED_WORD_ACCESS
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE
#define ENC_CODERANGE(obj)
static VALUE rb_str_upto(int argc, VALUE *argv, VALUE beg)
VALUE rb_to_symbol(VALUE name)
VALUE rb_str_cat(VALUE str, const char *ptr, long len)
long rb_str_strlen(VALUE str)
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
static VALUE tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p)
#define ONIGENC_CASE_FOLD_TURKISH_AZERI
VALUE rb_str_locktmp(VALUE)
static VALUE rb_str_swapcase(int argc, VALUE *argv, VALUE str)
static Bigint * diff(Bigint *a, Bigint *b)
const struct st_hash_type rb_fstring_hash_type
VALUE rb_str_drop_bytes(VALUE str, long len)
size_t rb_str_capacity(VALUE str)
VALUE rb_fstring_new(const char *ptr, long len)
VALUE rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc)
rb_encoding * rb_filesystem_encoding(void)
static VALUE rb_str_init(int argc, VALUE *argv, VALUE str)
rb_encoding * rb_enc_get_from_index(int index)
void rb_str_setter(VALUE val, ID id, VALUE *var)
static VALUE rb_str_rstrip_bang(VALUE str)
VALUE rb_str_tmp_new(long len)
static VALUE rb_str_each_char(VALUE str)
#define rb_enc_left_char_head(s, p, e, enc)
static VALUE str_replace_shared(VALUE str2, VALUE str)
VALUE rb_reg_match_p(VALUE re, VALUE str, long pos)
static VALUE rb_str_upcase(int argc, VALUE *argv, VALUE str)
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
void rb_backref_set_string(VALUE string, long pos, long len)
#define rb_str_splice(str, beg, len, val)
#define SHARABLE_SUBSTRING_P(beg, len, end)
#define RETURN_ENUMERATOR(obj, argc, argv)
#define FL_UNSET_RAW(x, f)
static VALUE rb_str_start_with(int argc, VALUE *argv, VALUE str)
VALUE rb_fstring_cstr(const char *ptr)
VALUE rb_str_substr(VALUE str, long beg, long len)
static void str_discard(VALUE str)
void rb_must_asciicompat(VALUE str)
VALUE rb_sym_all_symbols(void)
VALUE rb_str_cat_conv_enc_opts(VALUE newstr, long ofs, const char *ptr, long len, rb_encoding *from, int ecflags, VALUE ecopts)
static VALUE sym_empty(VALUE sym)
static VALUE rb_str_to_s(VALUE str)
static VALUE sym_casecmp_p(VALUE sym, VALUE other)
static VALUE str_byte_aref(VALUE str, VALUE indx)
VALUE rb_external_str_new(const char *ptr, long len)
VALUE rb_str_include_range_p(VALUE beg, VALUE end, VALUE val, VALUE exclusive)
VALUE rb_str_succ(VALUE orig)
rb_encoding * rb_ascii8bit_encoding(void)
void rb_warning(const char *fmt,...)
#define RSTRING_LENINT(str)
ONIG_EXTERN int onigenc_ascii_only_case_map(OnigCaseFoldType *flagP, const OnigUChar **pp, const OnigUChar *end, OnigUChar *to, OnigUChar *to_end, const struct OnigEncodingTypeST *enc)
rb_encoding * rb_enc_check_str(VALUE str1, VALUE str2)
#define rb_check_frozen(obj)
#define CONST_ID(var, str)
#define SIZED_ENUMERATOR(obj, argc, argv, size_fn)
static VALUE rb_str_sum(int argc, VALUE *argv, VALUE str)
VALUE rb_str_intern(VALUE)
VALUE rb_str_inspect(VALUE str)
static void tr_setup_table(VALUE str, char stable[TR_TABLE_SIZE], int first, VALUE *tablep, VALUE *ctablep, rb_encoding *enc)
#define rb_intern_const(str)
VALUE rb_obj_freeze(VALUE)
#define RSTRING_EMBED_LEN(str)
static char * str_fill_term(VALUE str, char *s, long len, int termlen)
#define SPECIAL_CONST_P(x)
VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
VALUE rb_str_buf_new(long capa)
int rb_num_to_uint(VALUE val, unsigned int *ret)
static VALUE str_uplus(VALUE str)
static VALUE rb_str_casecmp(VALUE str1, VALUE str2)
int rb_str_comparable(VALUE str1, VALUE str2)
#define rb_enc_mbcput(c, buf, enc)
static int str_upto_i(VALUE str, VALUE arg)
VALUE rb_str_ord(VALUE s)
#define RB_INTEGER_TYPE_P(obj)
#define rb_str_dup_frozen
static VALUE sym_capitalize(int argc, VALUE *argv, VALUE sym)
static VALUE sym_aref(int argc, VALUE *argv, VALUE sym)
#define ONIGENC_CTYPE_DIGIT
#define OBJ_TAINTED_RAW(x)
VALUE rb_invcmp(VALUE x, VALUE y)
VALUE rb_str_resurrect(VALUE str)
static VALUE rb_str_aref(VALUE str, VALUE indx)
VALUE rb_check_string_type(VALUE str)
static VALUE rb_str_downcase(int argc, VALUE *argv, VALUE str)
VALUE rb_usascii_str_new_cstr(const char *ptr)
VALUE rb_id_quote_unprintable(ID id)
VALUE rb_reg_regcomp(VALUE)
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 ENCINDEX_UTF_32LE
static VALUE rb_str_delete_bang(int, VALUE *, VALUE)
static VALUE rb_str_concat_multi(int argc, VALUE *argv, VALUE str)
void rb_warn(const char *fmt,...)
VALUE rb_str_ellipsize(VALUE str, long len)
Shortens str and adds three dots, an ellipsis, if it is longer than len characters.
#define ENCINDEX_UTF_32BE
#define rb_enc_prev_char(s, p, e, enc)
static VALUE rb_str_force_encoding(VALUE str, VALUE enc)
#define STR_HEAP_SIZE(str)
VALUE rb_str_dump(VALUE str)
static VALUE rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
#define RB_OBJ_WRITE(a, slot, b)
VALUE rb_reg_nth_match(int, VALUE)
static VALUE str_new_static(VALUE klass, const char *ptr, long len, int encindex)
#define rb_enc_code_to_mbclen(c, enc)
static VALUE rb_str_each_codepoint(VALUE str)
void rb_str_modify(VALUE str)
#define ONIGENC_MBCLEN_CHARFOUND_P(r)
VALUE rb_enc_str_new(const char *ptr, long len, rb_encoding *enc)
static enum neighbor_char enc_succ_char(char *p, long len, rb_encoding *enc)
VALUE rb_external_str_new_cstr(const char *ptr)
rb_encoding * rb_enc_from_index(int index)
VALUE rb_obj_class(VALUE)
VALUE rb_str_dup(VALUE str)
VALUE rb_str_new_with_class(VALUE obj, const char *ptr, long len)
char * rb_str_fill_terminator(VALUE str, const int newminlen)