20 #define BEG(no) (regs->beg[(no)])
21 #define END(no) (regs->end[(no)])
30 #define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
32 #undef rb_str_new_cstr
33 #undef rb_tainted_str_new_cstr
34 #undef rb_usascii_str_new_cstr
35 #undef rb_external_str_new_cstr
36 #undef rb_locale_str_new_cstr
41 #undef rb_tainted_str_new2
42 #undef rb_usascii_str_new2
43 #undef rb_str_dup_frozen
44 #undef rb_str_buf_new_cstr
45 #undef rb_str_buf_new2
46 #undef rb_str_buf_cat2
54 #define RUBY_MAX_CHAR_LEN 16
55 #define STR_TMPLOCK FL_USER7
56 #define STR_NOEMBED FL_USER1
57 #define STR_SHARED FL_USER2
58 #define STR_ASSOC FL_USER3
59 #define STR_SHARED_P(s) FL_ALL((s), STR_NOEMBED|ELTS_SHARED)
60 #define STR_ASSOC_P(s) FL_ALL((s), STR_NOEMBED|STR_ASSOC)
61 #define STR_NOCAPA (STR_NOEMBED|ELTS_SHARED|STR_ASSOC)
62 #define STR_NOCAPA_P(s) (FL_TEST((s),STR_NOEMBED) && FL_ANY((s),ELTS_SHARED|STR_ASSOC))
63 #define STR_UNSET_NOCAPA(s) do {\
64 if (FL_TEST((s),STR_NOEMBED)) FL_UNSET((s),(ELTS_SHARED|STR_ASSOC));\
68 #define STR_SET_NOEMBED(str) do {\
69 FL_SET((str), STR_NOEMBED);\
70 STR_SET_EMBED_LEN((str), 0);\
72 #define STR_SET_EMBED(str) FL_UNSET((str), STR_NOEMBED)
73 #define STR_EMBED_P(str) (!FL_TEST((str), STR_NOEMBED))
74 #define STR_SET_EMBED_LEN(str, n) do { \
76 RBASIC(str)->flags &= ~RSTRING_EMBED_LEN_MASK;\
77 RBASIC(str)->flags |= (tmp_n) << RSTRING_EMBED_LEN_SHIFT;\
80 #define STR_SET_LEN(str, n) do { \
81 if (STR_EMBED_P(str)) {\
82 STR_SET_EMBED_LEN((str), (n));\
85 RSTRING(str)->as.heap.len = (n);\
89 #define STR_DEC_LEN(str) do {\
90 if (STR_EMBED_P(str)) {\
91 long n = RSTRING_LEN(str);\
93 STR_SET_EMBED_LEN((str), n);\
96 RSTRING(str)->as.heap.len--;\
100 #define RESIZE_CAPA(str,capacity) do {\
101 if (STR_EMBED_P(str)) {\
102 if ((capacity) > RSTRING_EMBED_LEN_MAX) {\
103 char *tmp = ALLOC_N(char, (capacity)+1);\
104 memcpy(tmp, RSTRING_PTR(str), RSTRING_LEN(str));\
105 RSTRING(str)->as.heap.ptr = tmp;\
106 RSTRING(str)->as.heap.len = RSTRING_LEN(str);\
107 STR_SET_NOEMBED(str);\
108 RSTRING(str)->as.heap.aux.capa = (capacity);\
112 REALLOC_N(RSTRING(str)->as.heap.ptr, char, (capacity)+1);\
113 if (!STR_NOCAPA_P(str))\
114 RSTRING(str)->as.heap.aux.capa = (capacity);\
118 #define is_ascii_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT)
119 #define is_broken_string(str) (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN)
121 #define STR_ENC_GET(str) rb_enc_from_index(ENCODING_GET(str))
143 static inline const char *
146 #if SIZEOF_VALUE == 8
147 # define NONASCII_MASK 0x8080808080808080ULL
148 #elif SIZEOF_VALUE == 4
149 # define NONASCII_MASK 0x80808080UL
152 if ((
int)
sizeof(
VALUE) * 2 < e - p) {
155 s = (
const VALUE*)(~lowbits & ((
VALUE)p + lowbits));
156 while (p < (
const char *)s) {
163 if (*s & NONASCII_MASK) {
183 const char *e = p +
len;
363 return RSTRING(str)->as.heap.len;
366 return RSTRING(str)->as.heap.aux.capa;
376 str->as.heap.ptr = 0;
377 str->as.heap.len = 0;
378 str->as.heap.aux.capa = 0;
441 #define rb_str_new2 rb_str_new_cstr
452 #define rb_usascii_str_new2 rb_usascii_str_new_cstr
473 #define rb_tainted_str_new2 rb_tainted_str_new_cstr
482 const unsigned char *sp;
486 if (from == to)
return str;
511 len = len < 2 ? 2 : len * 2;
615 RSTRING(str2)->as.heap.aux.shared = str;
645 #define rb_str_new3 rb_str_new_shared
660 RSTRING(str2)->as.heap.aux.shared = shared;
664 RSTRING(str)->as.heap.aux.shared = str2;
682 if ((ofs > 0) || (klass !=
RBASIC(str)->klass) ||
686 RSTRING(str)->as.heap.ptr += ofs;
687 RSTRING(str)->as.heap.len -= ofs;
700 str = str_new4(klass, orig);
702 RSTRING(str)->as.heap.aux.shared = assoc;
705 str = str_new4(klass, orig);
712 #define rb_str_new4 rb_str_new_frozen
722 #define rb_str_new5 rb_str_new_with_class
725 str_new_empty(
VALUE str)
733 #define STR_BUF_MIN_SIZE 128
744 RSTRING(str)->as.heap.aux.capa = capa;
746 RSTRING(str)->as.heap.ptr[0] =
'\0';
764 #define rb_str_buf_new2 rb_str_buf_new_cstr
800 return RSTRING(str)->as.heap.aux.capa;
820 if (str == str2)
return;
839 RSTRING(str)->as.heap.aux.shared =
RSTRING(str2)->as.heap.aux.shared;
885 RSTRING(str)->as.heap.aux.shared = shared;
928 if (argc > 0 &&
rb_scan_args(argc, argv,
"01", &orig) == 1)
973 for (c=0; p<e; c++) {
1023 for (c=0; p<e; c++) {
1041 #ifdef NONASCII_MASK
1042 #define is_utf8_lead_byte(c) (((c)&0xC0) != 0x80)
1057 count_utf8_lead_bytes_with_word(
const VALUE *s)
1064 d &= NONASCII_MASK >> 7;
1069 #if SIZEOF_VALUE == 8
1088 #ifdef NONASCII_MASK
1093 if ((
int)
sizeof(
VALUE) * 2 < e - p) {
1096 s = (
const VALUE*)(~lowbits & ((
VALUE)p + lowbits));
1098 while (p < (
const char *)s) {
1099 if (is_utf8_lead_byte(*p)) len++;
1103 len += count_utf8_lead_bytes_with_word(s);
1106 p = (
const char *)s;
1109 if (is_utf8_lead_byte(*p)) len++;
1237 while (n <= len/2) {
1238 memcpy(ptr2 + n, ptr2, n);
1241 memcpy(ptr2 + n, ptr2, len-n);
1301 long capa = len + expand;
1303 if (len > capa) len = capa;
1304 ptr =
ALLOC_N(
char, capa + 1);
1311 RSTRING(str)->as.heap.ptr = ptr;
1313 RSTRING(str)->as.heap.aux.capa = capa;
1316 #define str_make_independent(str) str_make_independent_expand((str), 0L)
1335 else if (expand > 0) {
1337 long capa = len + expand;
1341 RSTRING(str)->as.heap.aux.capa = capa;
1367 RSTRING(str)->as.heap.ptr = 0;
1368 RSTRING(str)->as.heap.len = 0;
1386 assoc =
RSTRING(assoc)->as.heap.aux.shared;
1408 return RSTRING(str)->as.heap.aux.shared;
1438 if (!s || memchr(s, 0, len)) {
1484 const char *p2, *e2;
1487 while (p < e && 0 < nth) {
1513 while (p < e && nth--) {
1545 const char *pp =
str_nth(p, e, nth, enc, singlebyte);
1546 if (!pp)
return e -
p;
1557 #ifdef NONASCII_MASK
1559 str_utf8_nth(
const char *
p,
const char *e,
long *nthp)
1565 s = (
const VALUE*)(~lowbits & ((
VALUE)p + lowbits));
1567 while (p < (
const char *)s) {
1568 if (is_utf8_lead_byte(*p)) nth--;
1572 nth -= count_utf8_lead_bytes_with_word(s);
1574 }
while (s < t && (
int)
sizeof(
VALUE) <= nth);
1578 if (is_utf8_lead_byte(*p)) {
1579 if (nth == 0)
break;
1589 str_utf8_offset(
const char *p,
const char *e,
long nth)
1591 const char *pp = str_utf8_nth(p, e, &nth);
1635 if (len < 0)
return Qnil;
1643 if (beg < 0)
return Qnil;
1656 if (len > -beg) len = -beg;
1661 if (!p)
return Qnil;
1663 if (!p)
return Qnil;
1669 if (beg < 0)
return Qnil;
1679 #ifdef NONASCII_MASK
1682 p = str_utf8_nth(s, e, &beg);
1683 if (beg > 0)
return Qnil;
1684 len = str_utf8_offset(p, e, len);
1690 p = s + beg * char_sz;
1694 else if (len * char_sz > e - p)
1699 else if ((p =
str_nth_len(s, e, &beg, enc)) == e) {
1700 if (beg > 0)
return Qnil;
1733 #define rb_str_dup_frozen rb_str_new_frozen
1772 rb_bug(
"probable buffer overflow: %ld for %ld", len, capa);
1802 char *ptr =
RSTRING(str)->as.heap.ptr;
1804 if (slen > len) slen =
len;
1805 if (slen > 0)
MEMCPY(
RSTRING(str)->as.ary, ptr,
char, slen);
1808 if (independent)
xfree(ptr);
1811 else if (!independent) {
1814 else if (slen < len || slen - len > 1024) {
1829 long capa, total, off = -1;
1835 if (len == 0)
return 0;
1844 capa =
RSTRING(str)->as.heap.aux.capa;
1850 if (capa <= total) {
1851 while (total > capa) {
1853 capa = (total + 4095) / 4096;
1856 capa = (capa + 1) * 2;
1870 #define str_buf_cat2(str, ptr) str_buf_cat((str), (ptr), strlen(ptr))
1875 if (len == 0)
return str;
1897 p =
RSTRING(str)->as.heap.ptr;
1898 memcpy(p +
RSTRING(str)->as.heap.len, ptr, len);
1915 int ptr_encindex,
int ptr_cr,
int *ptr_cr_ret)
1923 if (str_encindex == ptr_encindex) {
1953 *ptr_cr_ret = ptr_cr;
1955 if (str_encindex != ptr_encindex &&
1965 res_encindex = str_encindex;
1970 res_encindex = str_encindex;
1974 res_encindex = ptr_encindex;
1979 res_encindex = str_encindex;
1986 res_encindex = str_encindex;
2019 unsigned int c = (
unsigned char)*ptr;
2110 buf[0] = (char)code;
2206 #define lesser(a,b) (((a)>(b))?(b):(a))
2218 if (idx1 == idx2)
return TRUE;
2237 const char *ptr1, *ptr2;
2240 if (str1 == str2)
return 0;
2243 if (ptr1 == ptr2 || (retval =
memcmp(ptr1, ptr2,
lesser(len1, len2))) == 0) {
2252 if (len1 > len2)
return 1;
2255 if (retval > 0)
return 1;
2264 const char *ptr1, *ptr2;
2270 if (
memcmp(ptr1, ptr2, len) == 0)
2286 if (str1 == str2)
return Qtrue;
2306 if (str1 == str2)
return Qtrue;
2379 char *p1, *p1end, *p2, *p2end;
2390 while (p1 < p1end && p2 < p2end) {
2392 unsigned int c1 =
TOUPPER(*p1 & 0xff);
2393 unsigned int c2 =
TOUPPER(*p2 & 0xff);
2395 return INT2FIX(c1 < c2 ? -1 : 1);
2402 while (p1 < p1end && p2 < p2end) {
2406 if (0 <= c1 && 0 <= c2) {
2410 return INT2FIX(c1 < c2 ? -1 : 1);
2416 len = l1 < l2 ? l1 : l2;
2419 return INT2FIX(r < 0 ? -1 : 1);
2421 return INT2FIX(l1 < l2 ? -1 : 1);
2448 if (offset < 0)
return -1;
2450 if (len - offset < slen)
return -1;
2457 if (slen == 0)
return offset;
2465 if (pos < 0)
return pos;
2467 if (t == s + pos)
break;
2468 if ((len -= t - s) <= 0)
return -1;
2472 return pos + offset;
2500 if (
rb_scan_args(argc, argv,
"11", &sub, &initpos) == 2) {
2516 switch (
TYPE(sub)) {
2544 if (pos == -1)
return Qnil;
2552 char *s, *sbeg, *e, *t;
2563 if (len < slen)
return -1;
2564 if (len - pos < slen) {
2574 s =
str_nth(sbeg, e, pos, enc, singlebyte);
2576 if (
memcmp(s, t, slen) == 0) {
2579 if (pos == 0)
break;
2613 if (
rb_scan_args(argc, argv,
"11", &sub, &vpos) == 2) {
2624 if (pos > len) pos =
len;
2630 switch (
TYPE(sub)) {
2640 if (pos >= 0)
return LONG2NUM(pos);
2656 if (pos >= 0)
return LONG2NUM(pos);
2751 for (i = len-1; 0 <= i && (
unsigned char)p[i] == 0xff; i--)
2755 ++((
unsigned char*)p)[
i];
2763 memset(p+l, 0xff, len-l);
2769 for (len2 = len-1; 0 < len2; len2--) {
2774 memset(p+len2+1, 0xff, len-(len2+1));
2785 for (i = len-1; 0 <= i && (
unsigned char)p[i] == 0; i--)
2789 --((
unsigned char*)p)[
i];
2797 memset(p+l, 0, len-l);
2803 for (len2 = len-1; 0 < len2; len2--) {
2808 memset(p+len2+1, 0, len-(len2+1));
2839 MEMCPY(save, p,
char, len);
2846 MEMCPY(p, save,
char, len);
2849 MEMCPY(save, p,
char, len);
2854 MEMCPY(p, save,
char, len);
2859 MEMCPY(p, save,
char, len);
2869 MEMCPY(carry, p,
char, len);
2873 MEMCPY(carry, p,
char, len);
2909 char *sbeg, *s, *e, *last_alnum = 0;
2913 long carry_pos = 0, carry_len = 1;
2945 carry_pos = s - sbeg;
2961 MEMCPY(carry, s,
char, l);
2964 carry_pos = s - sbeg;
3031 VALUE end, exclusive;
3032 VALUE current, after_end;
3039 excl =
RTEST(exclusive);
3049 if (c > e || (excl && c == e))
return beg;
3052 if (!excl && c == e)
break;
3054 if (excl && c == e)
break;
3083 if (excl && bi == ei)
break;
3104 if (n > 0 || (excl && n == 0))
return beg;
3113 if (
NIL_P(next))
break;
3140 switch (
TYPE(indx)) {
3252 if (len > olen) len = olen;
3260 memmove(ptr, oldptr + len, nlen);
3266 RSTRING(str)->as.heap.len = nlen;
3331 if (slen < len || slen < beg + len) {
3360 long start, end,
len;
3398 switch (
TYPE(indx)) {
3534 if (argc < 1 || 2 < argc) {
3537 for (i=0; i<
argc; i++) {
3542 if (!
NIL_P(result)) {
3554 switch (
TYPE(pat)) {
3599 else if (argc == 2) {
3624 if (iter || !
NIL_P(hash)) {
3672 memmove(p + beg0 + rlen, p + beg0 + plen, len - beg0 - plen);
3674 memcpy(p + beg0, rp, rlen);
3743 long offset, blen, slen,
len,
last;
3769 if (bang)
return Qnil;
3790 if (iter || !
NIL_P(hash)) {
3826 offset = end0 +
len;
3865 return str_gsub(argc, argv, str, 1);
3915 return str_gsub(argc, argv, str, 0);
3934 if (str == str2)
return str;
4031 if (beg > n || len < 0)
return Qnil;
4034 if (beg < 0)
return Qnil;
4083 switch (
TYPE(indx)) {
4180 if (clen > 1 || (*s & 0x80)) single = 0;
4190 if (clen > 1 || (*s & 0x80)) single = 0;
4267 if (i == -1)
return Qfalse;
4298 if (argc == 0) base = 10;
4362 #define CHAR_ESC_LEN 13
4377 else if (c < 0x10000) {
4413 const char *
p, *pend, *prev;
4431 const unsigned char *q = (
const unsigned char *)p;
4432 if (q[0] == 0xFE && q[1] == 0xFF)
4434 else if (q[0] == 0xFF && q[1] == 0xFE)
4439 else if (enc == utf32) {
4440 const unsigned char *q = (
const unsigned char *)p;
4441 if (q[0] == 0 && q[1] == 0 && q[2] == 0xFE && q[3] == 0xFF)
4443 else if (q[3] == 0 && q[2] == 0 && q[1] == 0xFE && q[0] == 0xFF)
4454 if (p > prev)
str_buf_cat(result, prev, p - prev);
4457 n = (int)(pend - p);
4468 if ((asciicompat || unicode_p) &&
4469 (c ==
'"'|| c ==
'\\' ||
4474 (cc ==
'$' || cc ==
'@' || cc ==
'{'))))) {
4475 if (p - n > prev)
str_buf_cat(result, prev, p - n - prev);
4477 if (asciicompat || enc == resenc) {
4483 case '\n': cc =
'n';
break;
4484 case '\r': cc =
'r';
break;
4485 case '\t': cc =
't';
break;
4486 case '\f': cc =
'f';
break;
4487 case '\013': cc =
'v';
break;
4488 case '\010': cc =
'b';
break;
4489 case '\007': cc =
'a';
break;
4490 case 033: cc =
'e';
break;
4491 default: cc = 0;
break;
4494 if (p - n > prev)
str_buf_cat(result, prev, p - n - prev);
4506 if (p - n > prev)
str_buf_cat(result, prev, p - n - prev);
4512 if (p > prev)
str_buf_cat(result, prev, p - prev);
4519 #define IS_EVSTR(p,e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
4534 const char *
p, *pend;
4542 unsigned char c = *p++;
4544 case '"':
case '\\':
4545 case '\n':
case '\r':
4546 case '\t':
case '\f':
4547 case '\013':
case '\010':
case '\007':
case '\033':
4564 while (cc >>= 4) len++;
4586 unsigned char c = *p++;
4588 if (c ==
'"' || c ==
'\\') {
4592 else if (c ==
'#') {
4593 if (
IS_EVSTR(p, pend)) *q++ =
'\\';
4596 else if (c ==
'\n') {
4600 else if (c ==
'\r') {
4604 else if (c ==
'\t') {
4608 else if (c ==
'\f') {
4612 else if (c ==
'\013') {
4616 else if (c ==
'\010') {
4620 else if (c ==
'\007') {
4624 else if (c ==
'\033') {
4650 snprintf(q, qend-q,
".force_encoding(\"%s\")", enc->
name);
4693 unsigned int c = *(
unsigned char*)s;
4696 *s =
'A' + (c -
'a');
4708 if (ascompat && (c = *(
unsigned char*)s) < 0x80) {
4710 *s =
'A' + (c -
'a');
4727 if (modify)
return str;
4775 unsigned int c = *(
unsigned char*)s;
4778 *s =
'a' + (c -
'A');
4791 if (ascompat && (c = *(
unsigned char*)s) < 0x80) {
4793 *s =
'a' + (c -
'A');
4810 if (modify)
return str;
4880 if (modify)
return str;
4944 if (modify)
return str;
4984 if (t->
p == t->
pend)
return -1;
4985 if (t->
p < t->
pend - 1 && *t->
p ==
'\\') {
4990 if (t->
p < t->
pend - 1 && *t->
p ==
'-') {
4992 if (t->
p < t->
pend) {
4996 if (t->
now < 0x80 && c < 0x80) {
4998 "invalid range \"%c-%c\" in string transliteration",
5012 else if (++t->
now < t->
max) {
5027 const unsigned int errc = -1;
5028 unsigned int trans[256];
5030 struct tr trsrc, trrepl;
5032 unsigned int c, c0,
last = 0;
5033 int modify = 0,
i, l;
5039 #define CHECK_IF_ASCII(c) \
5040 (void)((cr == ENC_CODERANGE_7BIT && !rb_isascii(c)) ? \
5041 (cr = ENC_CODERANGE_VALID) : 0)
5062 trsrc.
p + l < trsrc.
pend) {
5068 trsrc.
gen = trrepl.
gen = 0;
5069 trsrc.
now = trrepl.
now = 0;
5070 trsrc.
max = trrepl.
max = 0;
5073 for (
i=0;
i<256;
i++) {
5076 while ((c =
trnext(&trsrc, enc)) != errc) {
5085 while ((c =
trnext(&trrepl, enc)) != errc)
5088 for (
i=0;
i<256;
i++) {
5089 if (trans[
i] != errc) {
5097 for (
i=0;
i<256;
i++) {
5100 while ((c =
trnext(&trsrc, enc)) != errc) {
5101 r =
trnext(&trrepl, enc);
5102 if (r == errc) r = trrepl.
now;
5121 unsigned int save = -1;
5137 if (cflag) c =
last;
5140 else if (cflag) c = errc;
5146 if (c != (
unsigned int)-1) {
5158 if (enc != e1) may_modify = 1;
5160 while (t - buf + tlen >= max) {
5167 if (may_modify &&
memcmp(s, t, tlen) != 0) {
5184 c = (
unsigned char)*s;
5185 if (trans[c] != errc) {
5216 if (cflag) c =
last;
5219 else if (cflag) c = errc;
5223 c = cflag ? last : errc;
5231 if (enc != e1) may_modify = 1;
5233 while (t - buf + tlen >= max) {
5241 if (may_modify &&
memcmp(s, t, tlen) != 0) {
5281 return tr_trans(str, src, repl, 0);
5313 #define TR_TABLE_SIZE 257
5318 const unsigned int errc = -1;
5322 VALUE table = 0, ptable = 0;
5323 int i, l, cflag = 0;
5333 for (i=0; i<256; i++) {
5336 stable[256] = cflag;
5338 else if (stable[256] && !cflag) {
5341 for (i=0; i<256; i++) {
5345 while ((c =
trnext(&tr, enc)) != errc) {
5347 buf[c & 0xff] = !cflag;
5368 for (i=0; i<256; i++) {
5369 stable[
i] = stable[
i] && buf[
i];
5378 return table[c] != 0;
5410 VALUE del = 0, nodel = 0;
5412 int i, ascompat, cr;
5418 for (i=0; i<
argc; i++) {
5435 if (ascompat && (c = *(
unsigned char*)s) < 0x80) {
5448 if (
tr_find(c, squeez, del, nodel)) {
5463 if (modify)
return str;
5504 VALUE del = 0, nodel = 0;
5514 for (i=0; i<
argc; i++) {
5534 unsigned int c = *(
unsigned char*)s++;
5535 if (c != save || (argc > 0 && !squeez[c])) {
5544 if (ascompat && (c = *(
unsigned char*)s) < 0x80) {
5545 if (c != save || (argc > 0 && !squeez[c])) {
5553 if (c != save || (argc > 0 && !
tr_find(c, squeez, del, nodel))) {
5569 if (modify)
return str;
5609 return tr_trans(str, src, repl, 1);
5656 VALUE del = 0, nodel = 0;
5664 for (i=0; i<
argc; i++) {
5678 if (*(
unsigned char*)s++ == c) n++;
5693 if (ascompat && (c = *(
unsigned char*)s) < 0x80) {
5702 if (
tr_find(c, table, del, nodel)) {
5713 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
5714 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5715 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5716 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5717 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5718 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5719 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5720 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5721 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5722 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5723 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5724 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5725 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5726 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5727 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5728 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
5731 #define ascii_isspace(c) isspacetable[(unsigned char)(c)]
5781 enum {awk, string, regexp} split_type;
5782 long beg, end,
i = 0;
5786 if (
rb_scan_args(argc, argv,
"02", &spat, &limit) == 2) {
5788 if (lim <= 0) limit =
Qnil;
5789 else if (lim == 1) {
5810 split_type = string;
5814 split_type = regexp;
5831 split_type = regexp;
5837 if (split_type == awk) {
5846 while (ptr < eptr) {
5847 c = (
unsigned char)*ptr++;
5855 if (!
NIL_P(limit) && lim <=
i)
break;
5870 while (ptr < eptr) {
5882 if (!
NIL_P(limit) && lim <= i)
break;
5897 else if (split_type ==
string) {
5911 while (ptr < eptr &&
5912 (end =
rb_memsearch(sptr, slen, ptr, eptr - ptr, enc)) >= 0) {
5915 if (t != ptr + end) {
5921 if (!
NIL_P(limit) && lim <= ++i)
break;
5935 if (start == end &&
BEG(0) ==
END(0)) {
5940 else if (last_null == 1) {
5948 if (ptr+start == ptr+len)
5958 beg = start =
END(0);
5962 for (idx=1; idx < regs->
num_regs; idx++) {
5963 if (
BEG(idx) == -1)
continue;
5964 if (
BEG(idx) ==
END(idx))
5965 tmp = str_new_empty(str);
5970 if (!
NIL_P(limit) && lim <= ++i)
break;
5975 tmp = str_new_empty(str);
5980 if (
NIL_P(limit) && lim == 0) {
6043 unsigned int newline;
6044 const char *
p, *pend, *s, *ptr;
6071 p = memchr(p,
'\n', pend - p);
6102 if (rslen == 0 && c == newline) {
6115 line =
rb_str_new5(str, s, p - s + (rslen ? rslen : n));
6120 s = p + (rslen ? rslen : n);
6202 for (i = 0; i <
len; i += n) {
6208 for (i = 0; i <
len; i += n) {
6243 const char *ptr, *
end;
6264 const char *
p, *p2, *
beg, *
end;
6268 if (beg > end)
return 0;
6351 if (len == 0)
return Qnil;
6403 while (len>0 && p[len-1] ==
'\n') {
6405 if (len>0 && p[len-1] ==
'\r')
6415 if (rslen > len)
return Qnil;
6417 if (rslen == 1 && newline ==
'\n')
6425 if (p[len-1] == newline &&
6558 while (s < t && ((c = *(t-1)) ==
'\0' ||
ascii_isspace(c))) t--;
6665 for (i=1; i < regs->
num_regs; i++) {
6711 long last = -1, prev = 0;
6803 extern char *
crypt(
const char *,
const char *);
6805 const char *s, *saltp;
6808 char salt_8bit_clean[3];
6819 if (!
ISASCII((
unsigned char)saltp[0]) || !
ISASCII((
unsigned char)saltp[1])) {
6820 salt_8bit_clean[0] = saltp[0] & 0x7f;
6821 salt_8bit_clean[1] = saltp[1] & 0x7f;
6822 salt_8bit_clean[2] =
'\0';
6823 saltp = salt_8bit_clean;
6826 res =
crypt(s, saltp);
6901 char *ptr, *
p, *pend;
6904 unsigned long sum0 = 0;
6923 sum0 += (
unsigned char)*p;
6934 if (bits < (
int)
sizeof(
long)*
CHAR_BIT) {
6935 sum0 &= (((
unsigned long)1)<<bits)-1;
6959 long width,
len, flen = 1, fclen = 1;
6962 const char *f =
" ";
6963 long n,
size, llen, rlen, llen2 = 0, rlen2 = 0;
6965 int singlebyte = 1, cr;
6977 if (flen == 0 || fclen == 0) {
6982 if (width < 0 || len >= width)
return rb_str_dup(str);
6984 llen = (jflag ==
'l') ? 0 : ((jflag ==
'r') ? n : n/2);
6988 llen2 =
str_offset(f, f + flen, llen % fclen, enc, singlebyte);
6989 rlen2 =
str_offset(f, f + flen, rlen % fclen, enc, singlebyte);
6992 if ((len = llen / fclen + rlen / fclen) >=
LONG_MAX / flen ||
6993 (len *= flen) >=
LONG_MAX - llen2 - rlen2 ||
6994 (len += llen2 + rlen2) >=
LONG_MAX - size) {
7001 memset(p, *f, llen);
7005 while (llen >= fclen) {
7011 memcpy(p, f, llen2);
7018 memset(p, *f, rlen);
7022 while (rlen >= fclen) {
7028 memcpy(p, f, rlen2);
7142 return rb_ary_new3(3, str, str_new_empty(str), str_new_empty(str));
7146 if (pos == 0 &&
RSTRING_LEN(sep) == 0)
goto failed;
7192 return rb_ary_new3(3, str_new_empty(str), str_new_empty(str), str);
7223 for (i=0; i<
argc; i++) {
7225 if (
NIL_P(tmp))
continue;
7248 for (i=0; i<
argc; i++) {
7250 if (
NIL_P(tmp))
continue;
7344 static const char ellipsis[] =
"...";
7345 const long ellipsislen =
sizeof(ellipsis) - 1;
7348 const char *
const p =
RSTRING_PTR(str), *e = p + blen;
7349 VALUE estr, ret = 0;
7353 (e =
rb_enc_nth(p, e, len, enc)) - p == blen) {
7356 else if (len <= ellipsislen ||
7423 if (sym1 == sym2)
return Qtrue;
7480 memcpy(dest + 1, ptr, len);
7547 enum {SYM_PROC_CACHE_SIZE = 67};
7552 if (!sym_proc_cache) {
7559 index = (
id % SYM_PROC_CACHE_SIZE) << 1;
7562 if (aryp[index] == sym) {
7563 return aryp[index + 1];
7568 aryp[index + 1] = proc;
7744 switch (
TYPE(name)) {
7780 #define rb_intern(str) rb_intern_const(str)
static int str_independent(VALUE str)
#define rb_usascii_str_new2
int rb_enc_str_asciionly_p(VALUE str)
static VALUE sym_upcase(VALUE sym)
#define RSTRING_LEN(string)
static long NUM2LONG(VALUE x)
static long chopped_length(VALUE str)
VALUE rb_str_resize(VALUE str, long len)
int rb_enc_codelen(int c, rb_encoding *enc)
static VALUE rb_str_bytesize(VALUE str)
int rb_reg_backref_number(VALUE match, VALUE backref)
#define rb_tainted_str_new2
static VALUE str_buf_cat(VALUE str, const char *ptr, long len)
#define MBCLEN_CHARFOUND_P(ret)
static long rb_str_rindex(VALUE str, VALUE sub, long pos)
rb_encoding * rb_enc_check(VALUE str1, VALUE str2)
static VALUE UINT2NUM(unsigned int v)
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)
void rb_enc_copy(VALUE obj1, VALUE obj2)
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE
size_t strlen(const char *)
#define CHECK_IF_ASCII(c)
void rb_backref_set(VALUE)
#define ENCODING_CODERANGE_SET(obj, encindex, cr)
static int sym_printable(const char *s, const char *send, rb_encoding *enc)
VALUE rb_str_equal(VALUE str1, VALUE str2)
VALUE rb_locale_str_new_cstr(const char *ptr)
VALUE rb_sym_to_s(VALUE sym)
static int coderange_scan(const char *p, long len, rb_encoding *enc)
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
void rb_undef_alloc_func(VALUE)
static int max(int a, int b)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static VALUE rb_str_to_f(VALUE str)
VALUE rb_str_new_frozen(VALUE orig)
static VALUE rb_str_oct(VALUE str)
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 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 VALUE rb_str_match(VALUE x, VALUE y)
RUBY_ALIAS_FUNCTION(rb_str_new2(const char *ptr), rb_str_new_cstr,(ptr))
void rb_str_set_len(VALUE str, long len)
static void rb_enc_cr_str_copy_for_substr(VALUE dest, VALUE src)
static unsigned int trnext(struct tr *t, rb_encoding *enc)
#define ENC_CODERANGE_SET(obj, cr)
#define is_broken_string(str)
static VALUE sym_swapcase(VALUE sym)
static VALUE rb_str_clear(VALUE str)
rb_encoding * rb_to_encoding(VALUE enc)
#define ENC_CODERANGE_CLEAR(obj)
void rb_econv_close(rb_econv_t *ec)
#define STR_UNSET_NOCAPA(s)
VALUE rb_enc_from_encoding(rb_encoding *encoding)
int rb_enc_tolower(int c, rb_encoding *enc)
VALUE rb_str_new_with_class(VALUE, const char *, long)
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_each_line(int argc, VALUE *argv, VALUE str)
rb_encoding * rb_default_internal_encoding(void)
VALUE rb_ary_push(VALUE ary, VALUE item)
static VALUE str_new3(VALUE klass, VALUE str)
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_prepend(VALUE str, VALUE str2)
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
static VALUE rb_str_gsub_bang(int argc, VALUE *argv, VALUE str)
VALUE rb_ary_tmp_new(long capa)
VALUE rb_str_export_to_enc(VALUE str, rb_encoding *enc)
static VALUE INT2NUM(int v)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
#define str_buf_cat2(str, ptr)
static VALUE rb_str_swapcase_bang(VALUE str)
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 RSTRING_PTR(string)
static VALUE rb_str_include(VALUE str, VALUE arg)
static void rb_str_check_dummy_enc(rb_encoding *enc)
VALUE rb_backref_get(void)
#define str_make_independent(str)
VALUE rb_str_freeze(VALUE str)
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)
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 sym_downcase(VALUE sym)
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)
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_str_intern(VALUE s)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
#define RARRAY_LEN(ARRAY)
VALUE rb_ary_new3(long n,...)
static VALUE rb_str_empty(VALUE str)
static VALUE rb_str_reverse_bang(VALUE str)
void rb_include_module(VALUE klass, VALUE module)
#define ONIGENC_CODE_TO_MBC_MAXLEN
static VALUE rb_str_center(int argc, VALUE *argv, VALUE str)
VALUE rb_range_beg_len(VALUE, long *, long *, long, int)
double rb_str_to_dbl(VALUE, int)
#define rb_enc_islower(c, enc)
RUBY_FUNC_EXPORTED size_t rb_str_memsize(VALUE str)
static VALUE rb_str_subpat(VALUE str, VALUE re, VALUE backref)
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 VALUE rb_str_upcase_bang(VALUE str)
static VALUE rb_str_format_m(VALUE str, VALUE arg)
#define STR_SET_NOEMBED(str)
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)
VALUE rb_str_tmp_new(long)
static VALUE sym_length(VALUE sym)
VALUE rb_str_new_shared(VALUE str)
void rb_undef_method(VALUE klass, const char *name)
VALUE rb_sym_all_symbols(void)
static VALUE rb_str_upcase(VALUE str)
#define ONIGENC_CTYPE_ALPHA
static VALUE rb_str_hash_m(VALUE str)
static int tr_find(unsigned int c, char table[TR_TABLE_SIZE], VALUE del, VALUE nodel)
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
static VALUE rb_str_aset(VALUE str, VALUE indx, VALUE val)
#define ENC_CODERANGE_7BIT
const char * rb_obj_classname(VALUE)
VALUE rb_enc_sprintf(rb_encoding *enc, const char *format,...)
RUBY_EXTERN void * memmove(void *, const void *, size_t)
int rb_enc_toupper(int c, rb_encoding *enc)
static VALUE rb_str_insert(VALUE str, VALUE idx, VALUE str2)
VALUE rb_str_append(VALUE str, VALUE str2)
static const signed char trans[][0x100]
static VALUE sym_equal(VALUE sym1, VALUE sym2)
static VALUE sym_inspect(VALUE sym)
int rb_str_hash_cmp(VALUE str1, VALUE str2)
static VALUE rb_str_partition(VALUE str, VALUE sep)
static long str_offset(const char *p, const char *e, long nth, rb_encoding *enc, int singlebyte)
#define rb_enc_isctype(c, t, enc)
static VALUE rb_str_ljust(int argc, VALUE *argv, VALUE str)
int rb_enc_str_coderange(VALUE str)
#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)
#define ONIGENC_CTYPE_DIGIT
static VALUE rb_str_capitalize_bang(VALUE str)
static VALUE rb_str_strip(VALUE str)
int rb_block_given_p(void)
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)
void * rb_alloc_tmp_buffer(volatile VALUE *store, long len)
VALUE rb_str_to_inum(VALUE str, int base, int badcheck)
static VALUE str_new_shared(VALUE klass, VALUE str)
VALUE rb_str_length(VALUE str)
static VALUE rb_str_rpartition(VALUE str, VALUE sep)
static VALUE rb_str_crypt(VALUE str, VALUE salt)
static VALUE rb_str_cmp_m(VALUE str1, VALUE str2)
VALUE rb_str_new_cstr(const char *ptr)
static void str_modify_keep_cr(VALUE str)
rb_econv_t * rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts)
#define STR_SET_EMBED(str)
static VALUE rb_str_tr_s(VALUE str, VALUE src, VALUE repl)
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)
void rb_enc_set_index(VALUE obj, int idx)
void rb_ary_store(VALUE ary, long idx, VALUE val)
static VALUE rb_str_tr_s_bang(VALUE str, VALUE src, VALUE repl)
VALUE rb_str_concat(VALUE str1, VALUE str2)
#define NEWOBJ(obj, type)
static VALUE rb_str_strip_bang(VALUE str)
long rb_str_offset(VALUE str, long pos)
#define STR_SET_EMBED_LEN(str, n)
#define ALLOCA_N(type, n)
#define range(low, item, hi)
#define ENC_CODERANGE_UNKNOWN
void rb_gc_register_mark_object(VALUE obj)
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
#define rb_enc_isupper(c, enc)
#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 sym_call(VALUE args, VALUE sym, int argc, VALUE *argv, VALUE passed_proc)
static VALUE rb_str_rjust(int argc, VALUE *argv, VALUE str)
#define ENC_CODERANGE_VALID
long rb_str_sublen(VALUE str, long pos)
static VALUE sym_capitalize(VALUE sym)
VALUE rb_str_times(VALUE str, VALUE times)
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 void rb_str_splice(VALUE str, long beg, long len, VALUE val)
static VALUE str_eql(const VALUE str1, const VALUE str2)
static VALUE sym_encoding(VALUE sym)
static VALUE rb_str_swapcase(VALUE str)
VALUE rb_obj_as_string(VALUE obj)
VALUE rb_str_subseq(VALUE str, long beg, long len)
#define REALLOC_N(var, type, n)
char * rb_string_value_cstr(volatile VALUE *ptr)
#define RUBY_MAX_CHAR_LEN
SSL_METHOD *(* func)(void)
static VALUE rb_str_byteslice(int argc, VALUE *argv, VALUE str)
VALUE rb_funcall2(VALUE, ID, int, const VALUE *)
Calls a method.
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)
#define RB_GC_GUARD(object)
#define RSTRING_EMBED_LEN_MAX
int rb_enc_symname_p(const char *name, rb_encoding *enc)
static VALUE rb_str_tr(VALUE str, VALUE src, VALUE repl)
static VALUE rb_str_chop_bang(VALUE str)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
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)
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)
static VALUE sym_to_proc(VALUE sym)
static VALUE rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
static VALUE get_pat(VALUE, int)
VALUE rb_str_buf_cat(VALUE str, const char *ptr, long len)
static enum neighbor_char enc_pred_char(char *p, long len, rb_encoding *enc)
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)
static VALUE rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
VALUE rb_str_buf_cat2(VALUE str, const char *ptr)
#define ENC_CODERANGE_AND(a, b)
static VALUE rb_str_is_ascii_only_p(VALUE str)
void rb_str_shared_replace(VALUE str, VALUE str2)
VALUE rb_obj_encoding(VALUE obj)
static int rb_enc_dummy_p(rb_encoding *enc)
register unsigned int len
#define RARRAY_PTR(ARRAY)
#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)
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 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_sys_fail(const char *mesg)
static VALUE rb_str_chr(VALUE str)
#define ENCODING_IS_ASCII8BIT(obj)
static const char * search_nonascii(const char *p, const char *e)
static void str_modifiable(VALUE str)
static VALUE rb_str_index_m(int argc, VALUE *argv, VALUE str)
VALUE rb_str_to_str(VALUE str)
static VALUE rb_str_match_m(int argc, VALUE *argv, VALUE str)
static void str_mod_check(VALUE s, const char *p, long len)
VALUE rb_string_value(volatile VALUE *ptr)
VALUE rb_tainted_str_new_cstr(const char *ptr)
static const char isspacetable[256]
int rb_respond_to(VALUE, ID)
static VALUE scan_once(VALUE str, VALUE pat, long *start)
static VALUE rb_str_sub(int argc, VALUE *argv, VALUE str)
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)
VALUE rb_filesystem_str_new_cstr(const char *ptr)
static VALUE rb_str_end_with(int argc, VALUE *argv, VALUE str)
#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)
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)
static VALUE rb_str_downcase(VALUE str)
VALUE rb_str_unlocktmp(VALUE str)
#define MBCLEN_INVALID_P(ret)
static VALUE rb_str_valid_encoding_p(VALUE str)
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 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)
ID rb_intern_str(VALUE str)
static long enc_strlen(const char *p, const char *e, rb_encoding *enc, int cr)
static VALUE rb_str_lstrip(VALUE str)
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)
VALUE rb_reg_quote(VALUE)
static long rb_str_index(VALUE str, VALUE sub, long offset)
#define ENC_CODERANGE(obj)
static VALUE rb_str_upto(int argc, VALUE *argv, VALUE beg)
static VALUE str_byte_substr(VALUE str, long beg, long len)
VALUE rb_str_cat(VALUE str, const char *ptr, long len)
long rb_str_strlen(VALUE str)
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)
VALUE rb_proc_new(VALUE(*)(ANYARGS), VALUE)
VALUE rb_str_locktmp(VALUE)
static VALUE rb_str_capitalize(VALUE str)
VALUE rb_str_drop_bytes(VALUE str, long len)
size_t rb_str_capacity(VALUE str)
rb_encoding * rb_filesystem_encoding(void)
static VALUE rb_str_init(int argc, VALUE *argv, VALUE str)
void rb_define_variable(const char *, VALUE *)
void rb_str_setter(VALUE val, ID id, VALUE *var)
static VALUE rb_str_rstrip_bang(VALUE str)
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_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
static void str_make_independent_expand(VALUE str, long expand)
VALUE rb_ary_concat(VALUE x, VALUE y)
static unsigned int hash(const char *str, unsigned int len)
#define RETURN_ENUMERATOR(obj, argc, argv)
static VALUE rb_str_start_with(int argc, VALUE *argv, VALUE str)
VALUE rb_ary_new2(long capa)
VALUE rb_str_substr(VALUE str, long beg, long len)
static void str_discard(VALUE str)
#define RREGEXP_SRC_LEN(r)
#define assert(condition)
VALUE rb_str_associated(VALUE str)
const char * rb_id2name(ID id)
static VALUE sym_empty(VALUE sym)
static VALUE rb_str_to_s(VALUE str)
static VALUE str_byte_aref(VALUE str, VALUE indx)
VALUE rb_external_str_new(const char *ptr, long len)
void rb_str_associate(VALUE str, VALUE add)
#define rb_enc_to_index(enc)
VALUE rb_str_succ(VALUE orig)
rb_encoding * rb_ascii8bit_encoding(void)
static VALUE rb_str_downcase_bang(VALUE str)
static VALUE rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len, int ptr_encindex, int ptr_cr, int *ptr_cr_ret)
#define rb_check_frozen(obj)
#define CONST_ID(var, str)
static VALUE rb_str_sum(int argc, VALUE *argv, VALUE str)
VALUE rb_str_inspect(VALUE str)
void rb_free_tmp_buffer(volatile VALUE *store)
static void tr_setup_table(VALUE str, char stable[TR_TABLE_SIZE], int first, VALUE *tablep, VALUE *ctablep, rb_encoding *enc)
VALUE rb_obj_freeze(VALUE)
#define is_ascii_string(str)
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)
VALUE rb_tainted_str_new(const char *, long)
static VALUE rb_str_casecmp(VALUE str1, VALUE str2)
#define ONIGERR_INVALID_CODE_POINT_VALUE
int rb_str_comparable(VALUE str1, VALUE str2)
#define rb_enc_mbcput(c, buf, enc)
VALUE rb_str_cat2(VALUE str, const char *ptr)
VALUE rb_str_ord(VALUE s)
VALUE rb_str_locktmp_ensure(VALUE str, VALUE(*func)(VALUE), VALUE arg)
#define rb_str_dup_frozen
static VALUE sym_aref(int argc, VALUE *argv, VALUE sym)
VALUE rb_str_resurrect(VALUE str)
static VALUE rb_str_aref(VALUE str, VALUE indx)
VALUE rb_check_string_type(VALUE str)
#define OBJSETUP(obj, c, t)
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)
static VALUE rb_str_delete_bang(int, VALUE *, VALUE)
VALUE rb_str_ellipsize(VALUE str, long len)
Shortens str and adds three dots, an ellipsis, if it is longer than len characters.
#define rb_enc_prev_char(s, p, e, enc)
static VALUE rb_str_force_encoding(VALUE str, VALUE enc)
rb_encoding * rb_enc_find(const char *name)
VALUE rb_str_dump(VALUE str)
static VALUE rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
VALUE rb_reg_nth_match(int, VALUE)
static VALUE rb_str_each_codepoint(VALUE str)
void rb_str_modify(VALUE str)
VALUE rb_usascii_str_new_cstr(const char *)
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)