Ruby: string.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
string.c File Reference
`#include "ruby/internal/config.h"`
`#include <ctype.h>`
`#include <errno.h>`
`#include <math.h>`
`#include "missing/crypt.h"`
`#include "debug_counter.h"`
`#include "encindex.h"`
`#include "gc.h"`
`#include "id.h"`
`#include "internal.h"`
`#include "internal/array.h"`
`#include "internal/compar.h"`
`#include "internal/compilers.h"`
`#include "internal/encoding.h"`
`#include "internal/error.h"`
`#include "internal/gc.h"`
`#include "internal/numeric.h"`
`#include "internal/object.h"`
`#include "internal/proc.h"`
`#include "internal/re.h"`
`#include "internal/sanitizers.h"`
`#include "internal/string.h"`
`#include "internal/transcode.h"`
`#include "probes.h"`
`#include "ruby/encoding.h"`
`#include "ruby/re.h"`
`#include "ruby/util.h"`
`#include "ruby_assert.h"`
`#include "vm_sync.h"`

Go to the source code of this file.

## Data Structures
struct | fstr_update_arg
struct | mapping_buffer
struct | tr

## Macros
#define | HAVE_CRYPT_R 1
#define | BEG(no) (regs->beg[(no)])
#define | END(no) (regs->end[(no)])
#define | RUBY_MAX_CHAR_LEN 16
#define | STR_SHARED_ROOT FL_USER5
#define | STR_BORROWED FL_USER6
#define | STR_TMPLOCK FL_USER7
#define | STR_NOFREE FL_USER18
#define | STR_FAKESTR FL_USER19
#define | STR_SET_NOEMBED(str)
#define | STR_SET_EMBED(str) FL_UNSET((str), (STR_NOEMBED|STR_NOFREE))
#define | STR_SET_EMBED_LEN(str, n)
#define | STR_SET_LEN(str, n)
#define | STR_DEC_LEN(str)
#define | TERM_LEN(str) rb_enc_mbminlen(rb_enc_get(str))
#define | TERM_FILL(ptr, termlen)
#define | RESIZE_CAPA(str, capacity)
#define | RESIZE_CAPA_TERM(str, capacity, termlen)
#define | STR_SET_SHARED(str, shared_str)
#define | STR_HEAP_PTR(str) (RSTRING(str)->as.heap.ptr)
#define | STR_HEAP_SIZE(str) ((size_t)RSTRING(str)->as.heap.aux.capa + TERM_LEN(str))
#define | STR_ENC_GET(str) get_encoding(str)
#define | SHARABLE_MIDDLE_SUBSTRING 0
#define | SHARABLE_SUBSTRING_P(beg, len, end) ((beg) + (len) == (end))
#define | STR_EMBEDDABLE_P(len, termlen) ((len) <= RSTRING_EMBED_LEN_MAX + 1 - (termlen))
#define | BARE_STRING_P(str) (!FL_ANY_RAW(str, FL_EXIVAR) && RBASIC_CLASS(str) == rb_cString)
#define | aligned_ptr(value) (uintptr_t *)(value)
#define | STR_BUF_MIN_SIZE 63
#define | rb_str_dup_frozen rb_str_new_frozen
#define | str_buf_cat2(str, ptr) str_buf_cat((str), (ptr), strlen(ptr))
#define | MIN_PRE_ALLOC_SIZE 48
#define | lesser(a, b) (((a)>(b))?(b):(a))
#define | rb_str_index(str, sub, offset) rb_strseq_index(str, sub, offset, 0)
#define | rb_str_splice(str, beg, len, val) rb_str_update(str, beg, len, val)
#define | CHAR_ESC_LEN 13 /* sizeof(\x{ hex of 32bit unsigned int } \0) */
#define | IS_EVSTR(p, e) ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
#define | CASE_MAPPING_ADDITIONAL_LENGTH 20
#define | CASEMAP_DEBUG 0
#define | CHECK_IF_ASCII(c)
#define | TR_TABLE_MAX (UCHAR_MAX+1)
#define | TR_TABLE_SIZE (TR_TABLE_MAX+1)
#define | ascii_isspace(c) isspacetable[(unsigned char)(c)]
#define | SPLIT_STR(beg, len) (empty_count = split_string(result, str, beg, len, empty_count))
#define | WANTARRAY(m, size) (!rb_block_given_p() ? rb_ary_new_capa(size) : 0)
#define | ENUM_ELEM(ary, e) enumerator_element(ary, e)
#define | rb_rs get_rs()
#define | CHARS_16BE(x) (OnigUChar)((x)>>8), (OnigUChar)(x)
#define | CHARS_16LE(x) (OnigUChar)(x), (OnigUChar)((x)>>8)
#define | CHARS_32BE(x) CHARS_16BE((x)>>16), CHARS_16BE(x)
#define | CHARS_32LE(x) CHARS_16LE(x), CHARS_16LE((x)>>16)
#define | CASE_UTF(e)
#define | CRYPT_END() ALLOCV_END(databuf)
#define | DEFAULT_REPLACE_CHAR(str)
#define | sym_equal rb_obj_equal

## Typedefs
typedef struct mapping_buffer | mapping_buffer
typedef unsigned char * | USTR

## Enumerations
enum | neighbor_char { NEIGHBOR_NOT_CHAR , NEIGHBOR_FOUND , NEIGHBOR_WRAPPED }
enum | split_type_t { SPLIT_TYPE_AWK , SPLIT_TYPE_STRING , SPLIT_TYPE_REGEXP , SPLIT_TYPE_CHARS }

## Functions
void | rb_str_make_independent (VALUE str)
VALUE | rb_fstring (VALUE str)
VALUE | rb_setup_fake_str (struct RString *fake_str, const char *name, long len, rb_encoding *enc)
VALUE | rb_fstring_new (const char *ptr, long len)
VALUE | rb_fstring_enc_new (const char *ptr, long len, rb_encoding *enc)
VALUE | rb_fstring_cstr (const char *ptr)
long | rb_str_coderange_scan_restartable (const char *s, const char *e, rb_encoding *enc, int *cr)
int | rb_enc_str_coderange_scan (VALUE str, rb_encoding *enc)
int | rb_enc_str_coderange (VALUE str)
int | rb_enc_str_asciionly_p (VALUE str)
size_t | rb_str_capacity (VALUE str)
VALUE | rb_str_new (const char *ptr, long len)
VALUE | rb_usascii_str_new (const char *ptr, long len)
VALUE | rb_utf8_str_new (const char *ptr, long len)
VALUE | rb_enc_str_new (const char *ptr, long len, rb_encoding *enc)
VALUE | rb_str_new_cstr (const char *ptr)
VALUE | rb_usascii_str_new_cstr (const char *ptr)
VALUE | rb_utf8_str_new_cstr (const char *ptr)
VALUE | rb_enc_str_new_cstr (const char *ptr, rb_encoding *enc)
VALUE | rb_str_new_static (const char *ptr, long len)
| *_str_new_static functions are intended for C string literals. More...
VALUE | rb_usascii_str_new_static (const char *ptr, long len)
VALUE | rb_utf8_str_new_static (const char *ptr, long len)
VALUE | rb_enc_str_new_static (const char *ptr, long len, rb_encoding *enc)
VALUE | rb_tainted_str_new (const char *ptr, long len)
VALUE | rb_tainted_str_new_cstr (const char *ptr)
VALUE | rb_str_conv_enc_opts (VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
VALUE | rb_str_cat_conv_enc_opts (VALUE newstr, long ofs, const char *ptr, long len, rb_encoding *from, int ecflags, VALUE ecopts)
VALUE | rb_str_initialize (VALUE str, const char *ptr, long len, rb_encoding *enc)
VALUE | rb_str_conv_enc (VALUE str, rb_encoding *from, rb_encoding *to)
VALUE | rb_external_str_new_with_enc (const char *ptr, long len, rb_encoding *eenc)
VALUE | rb_external_str_with_enc (VALUE str, rb_encoding *eenc)
VALUE | rb_external_str_new (const char *ptr, long len)
VALUE | rb_external_str_new_cstr (const char *ptr)
VALUE | rb_locale_str_new (const char *ptr, long len)
VALUE | rb_locale_str_new_cstr (const char *ptr)
VALUE | rb_filesystem_str_new (const char *ptr, long len)
VALUE | rb_filesystem_str_new_cstr (const char *ptr)
VALUE | rb_str_export (VALUE str)
VALUE | rb_str_export_locale (VALUE str)
VALUE | rb_str_export_to_enc (VALUE str, rb_encoding *enc)
VALUE | rb_str_new_shared (VALUE str)
VALUE | rb_str_new_frozen (VALUE orig)
VALUE | rb_str_tmp_frozen_acquire (VALUE orig)
void | rb_str_tmp_frozen_release (VALUE orig, VALUE tmp)
VALUE | rb_str_new_with_class (VALUE obj, const char *ptr, long len)
| STATIC_ASSERT (STR_BUF_MIN_SIZE, STR_BUF_MIN_SIZE > RSTRING_EMBED_LEN_MAX)
VALUE | rb_str_buf_new (long capa)
VALUE | rb_str_buf_new_cstr (const char *ptr)
VALUE | rb_str_tmp_new (long len)
void | rb_str_free (VALUE str)
size_t | rb_str_memsize (VALUE str)
VALUE | rb_str_to_str (VALUE str)
void | rb_str_shared_replace (VALUE str, VALUE str2)
VALUE | rb_obj_as_string (VALUE obj)
VALUE | rb_obj_as_string_result (VALUE str, VALUE obj)
VALUE | rb_str_dup (VALUE str)
VALUE | rb_str_resurrect (VALUE str)
VALUE | rb_ec_str_resurrect (struct rb_execution_context_struct *ec, VALUE str)
long | rb_enc_strlen (const char *p, const char *e, rb_encoding *enc)
long | rb_enc_strlen_cr (const char *p, const char *e, rb_encoding *enc, int *cr)
long | rb_str_strlen (VALUE str)
VALUE | rb_str_length (VALUE str)
VALUE | rb_str_plus (VALUE str1, VALUE str2)
VALUE | rb_str_opt_plus (VALUE str1, VALUE str2)
VALUE | rb_str_times (VALUE str, VALUE times)
void | rb_str_modify (VALUE str)
void | rb_str_modify_expand (VALUE str, long expand)
void | rb_must_asciicompat (VALUE str)
VALUE | rb_string_value (volatile VALUE *ptr)
char * | rb_string_value_ptr (volatile VALUE *ptr)
void | rb_str_change_terminator_length (VALUE str, const int oldtermlen, const int termlen)
char * | rb_str_to_cstr (VALUE str)
char * | rb_string_value_cstr (volatile VALUE *ptr)
char * | rb_str_fill_terminator (VALUE str, const int newminlen)
VALUE | rb_check_string_type (VALUE str)
char * | rb_enc_nth (const char *p, const char *e, long nth, rb_encoding *enc)
long | rb_str_offset (VALUE str, long pos)
long | rb_str_sublen (VALUE str, long pos)
VALUE | rb_str_subseq (VALUE str, long beg, long len)
char * | rb_str_subpos (VALUE str, long beg, long *lenp)
VALUE | rb_str_substr (VALUE str, long beg, long len)
VALUE | rb_str_freeze (VALUE str)
| RUBY_ALIAS_FUNCTION (rb_str_dup_frozen(VALUE str), rb_str_new_frozen,(str))
VALUE | rb_str_unlocktmp (VALUE str)
VALUE | rb_str_locktmp_ensure (VALUE str, VALUE(*func)(VALUE), VALUE arg)
void | rb_str_set_len (VALUE str, long len)
VALUE | rb_str_resize (VALUE str, long len)
VALUE | rb_str_cat (VALUE str, const char *ptr, long len)
VALUE | rb_str_cat_cstr (VALUE str, const char *ptr)
| RUBY_ALIAS_FUNCTION (rb_str_buf_cat(VALUE str, const char *ptr, long len), rb_str_cat,(str, ptr, len))
VALUE | rb_enc_str_buf_cat (VALUE str, const char *ptr, long len, rb_encoding *ptr_enc)
VALUE | rb_str_buf_cat_ascii (VALUE str, const char *ptr)
VALUE | rb_str_buf_append (VALUE str, VALUE str2)
VALUE | rb_str_append (VALUE str, VALUE str2)
VALUE | rb_str_concat_literals (size_t num, const VALUE *strary)
VALUE | rb_str_concat (VALUE str1, VALUE str2)
st_index_t | rb_str_hash (VALUE str)
int | rb_str_hash_cmp (VALUE str1, VALUE str2)
int | rb_str_comparable (VALUE str1, VALUE str2)
int | rb_str_cmp (VALUE str1, VALUE str2)
VALUE | rb_str_equal (VALUE str1, VALUE str2)
VALUE | rb_str_eql (VALUE str1, VALUE str2)
VALUE | rb_str_succ (VALUE orig)
VALUE | rb_str_upto_each (VALUE beg, VALUE end, int excl, int(*each)(VALUE, VALUE), VALUE arg)
VALUE | rb_str_upto_endless_each (VALUE beg, int(*each)(VALUE, VALUE), VALUE arg)
VALUE | rb_str_include_range_p (VALUE beg, VALUE end, VALUE val, VALUE exclusive)
VALUE | rb_str_drop_bytes (VALUE str, long len)
void | rb_str_update (VALUE str, long beg, long len, VALUE val)
VALUE | rb_str_replace (VALUE str, VALUE str2)
int | rb_str_buf_cat_escaped_char (VALUE result, unsigned int c, int unicode_p)
const char * | ruby_escaped_char (int c)
VALUE | rb_str_escape (VALUE str)
VALUE | rb_str_inspect (VALUE str)
VALUE | rb_str_dump (VALUE str)
VALUE | rb_str_split (VALUE str, const char *sep0)
VALUE | rb_str_chomp_string (VALUE str, VALUE rs)
void | rb_str_setter (VALUE val, ID id, VALUE *var)
VALUE | rb_str_ellipsize (VALUE str, long len)
| Shortens str and adds three dots, an ellipsis, if it is longer than len characters. More...
VALUE | rb_str_scrub (VALUE str, VALUE repl)
VALUE | rb_enc_str_scrub (rb_encoding *enc, VALUE str, VALUE repl)
int | rb_str_symname_p (VALUE sym)
VALUE | rb_str_quote_unprintable (VALUE str)
VALUE | rb_id_quote_unprintable (ID id)
VALUE | rb_sym_to_s (VALUE sym)
VALUE | rb_sym_proc_call (ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc)
ID | rb_to_id (VALUE name)
VALUE | rb_to_symbol (VALUE name)
VALUE | rb_str_to_interned_str (VALUE str)
VALUE | rb_interned_str (const char *ptr, long len)
VALUE | rb_interned_str_cstr (const char *ptr)
VALUE | rb_enc_interned_str (const char *ptr, long len, rb_encoding *enc)
VALUE | rb_enc_interned_str_cstr (const char *ptr, rb_encoding *enc)
void | Init_String (void)

## Variables
VALUE | rb_cString
VALUE | rb_cSymbol
const struct st_hash_type | rb_fstring_hash_type
VALUE | rb_fs

## Macro Definition Documentation

## ◆ aligned_ptr

#define aligned_ptr | ( |  | value | ) | (uintptr_t *)(value)

## ◆ ascii_isspace

#define ascii_isspace | ( |  | c | ) | isspacetable[(unsigned char)(c)]

Definition at line 8077 of file string.c.

## ◆ BARE_STRING_P

#define BARE_STRING_P | ( |  | str | ) | (!FL_ANY_RAW(str, FL_EXIVAR) && RBASIC_CLASS(str) == rb_cString)

Definition at line 292 of file string.c.

## ◆ BEG

#define BEG | ( |  | no | ) | (regs->beg[(no)])

Definition at line 58 of file string.c.

## ◆ CASE_MAPPING_ADDITIONAL_LENGTH

#define CASE_MAPPING_ADDITIONAL_LENGTH 20

Definition at line 6755 of file string.c.

## ◆ CASE_UTF

#define CASE_UTF | ( |  | e | ) |

Value:
case ENCINDEX_UTF_##e: { \
static const OnigUChar source_UTF_##e[] = {CHARS_##e('\\'), CHARS_##e('X')}; \
source = source_UTF_##e; \
source_len = sizeof(source_UTF_##e); \
break; \
}
OnigUChar
unsigned char OnigUChar
Definition: onigmo.h:79

## ◆ CASEMAP_DEBUG

#define CASEMAP_DEBUG 0

Definition at line 6757 of file string.c.

## ◆ CHAR_ESC_LEN

#define CHAR_ESC_LEN 13 /* sizeof(\x{ hex of 32bit unsigned int } \0) */

Definition at line 6081 of file string.c.

## ◆ CHARS_16BE

#define CHARS_16BE | ( |  | x | ) | (OnigUChar)((x)>>8), (OnigUChar)(x)

## ◆ CHARS_16LE

#define CHARS_16LE | ( |  | x | ) | (OnigUChar)(x), (OnigUChar)((x)>>8)

## ◆ CHARS_32BE

#define CHARS_32BE | ( |  | x | ) | CHARS_16BE((x)>>16), CHARS_16BE(x)

## ◆ CHARS_32LE

#define CHARS_32LE | ( |  | x | ) | CHARS_16LE(x), CHARS_16LE((x)>>16)

## ◆ CHECK_IF_ASCII

#define CHECK_IF_ASCII | ( |  | c | ) |

Value:
(void)((cr == ENC_CODERANGE_7BIT && !rb_isascii(c)) ? \
(cr = ENC_CODERANGE_VALID) : 0)
ENC_CODERANGE_7BIT
#define ENC_CODERANGE_7BIT
Definition: encoding.h:93
ENC_CODERANGE_VALID
#define ENC_CODERANGE_VALID
Definition: encoding.h:94

## ◆ CRYPT_END

#define CRYPT_END | ( |  | ) | ALLOCV_END(databuf)

## ◆ DEFAULT_REPLACE_CHAR

#define DEFAULT_REPLACE_CHAR | ( |  | str | ) |

Value:
do { \
static const char replace[sizeof(str)-1] = str; \
rep = replace; replen = (int)sizeof(replace); \
} while (0)
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
int
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

## ◆ END

#define END | ( |  | no | ) | (regs->end[(no)])

Definition at line 59 of file string.c.

## ◆ ENUM_ELEM

#define ENUM_ELEM | ( |  | ary,
|  |  | e
| ) |  | enumerator_element(ary, e)

Definition at line 8436 of file string.c.

## ◆ HAVE_CRYPT_R

#define HAVE_CRYPT_R 1

Definition at line 30 of file string.c.

## ◆ IS_EVSTR

#define IS_EVSTR | ( |  | p,
|  |  | e
| ) |  | ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))

Definition at line 6292 of file string.c.

## ◆ lesser

#define lesser | ( |  | a,
|  |  | b
| ) |  | (((a)>(b))?(b):(a))

Definition at line 3350 of file string.c.

## ◆ MIN_PRE_ALLOC_SIZE

#define MIN_PRE_ALLOC_SIZE 48

Definition at line 3124 of file string.c.

## ◆ rb_rs

#define rb_rs get_rs()

Definition at line 8464 of file string.c.

## ◆ rb_str_dup_frozen

#define rb_str_dup_frozen rb_str_new_frozen

## ◆ rb_str_index

#define rb_str_index | ( |  | str,
|  |  | sub,
|  |  | offset
| ) |  | rb_strseq_index(str, sub, offset, 0)

Definition at line 3643 of file string.c.

## ◆ rb_str_splice

#define rb_str_splice | ( |  | str,
|  |  | beg,
|  |  | len,
|  |  | val
| ) |  | rb_str_update(str, beg, len, val)

Definition at line 4905 of file string.c.

## ◆ RESIZE_CAPA

#define RESIZE_CAPA | ( |  | str,
|  |  | capacity
| ) |  |

Value:
do {\
const int termlen = TERM_LEN(str);\
RESIZE_CAPA_TERM(str,capacity,termlen);\
} while (0)
TERM_LEN
#define TERM_LEN(str)
Definition: string.c:138

Definition at line 147 of file string.c.

## ◆ RESIZE_CAPA_TERM

#define RESIZE_CAPA_TERM | ( |  | str,
|  |  | capacity,
|  |  | termlen
| ) |  |

Value:
do {\
if (STR_EMBED_P(str)) {\
if (!STR_EMBEDDABLE_P(capacity, termlen)) {\
char *const tmp = ALLOC_N(char, (size_t)(capacity) + (termlen));\
const long tlen = RSTRING_LEN(str);\
memcpy(tmp, RSTRING_PTR(str), tlen);\
RSTRING(str)->as.heap.ptr = tmp;\
RSTRING(str)->as.heap.len = tlen;\
STR_SET_NOEMBED(str);\
RSTRING(str)->as.heap.aux.capa = (capacity);\
}\
}\
else {\
assert(!FL_TEST((str), STR_SHARED)); \
SIZED_REALLOC_N(RSTRING(str)->as.heap.ptr, char, \
(size_t)(capacity) + (termlen), STR_HEAP_SIZE(str)); \
RSTRING(str)->as.heap.aux.capa = (capacity);\
}\
} while (0)
RSTRING_LEN
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
RSTRING_PTR
#define RSTRING_PTR(string)
Definition: fbuffer.h:19
FL_TEST
#define FL_TEST
Definition: fl_type.h:130
STR_SHARED
#define STR_SHARED
Definition: string.h:20
ALLOC_N
#define ALLOC_N
Definition: memory.h:133
RSTRING
#define RSTRING(obj)
Definition: rstring.h:35
STR_EMBEDDABLE_P
#define STR_EMBEDDABLE_P(len, termlen)
Definition: string.c:196
STR_HEAP_SIZE
#define STR_HEAP_SIZE(str)
Definition: string.c:182

Definition at line 151 of file string.c.

## ◆ RUBY_MAX_CHAR_LEN

#define RUBY_MAX_CHAR_LEN 16

Definition at line 100 of file string.c.

## ◆ SHARABLE_MIDDLE_SUBSTRING

#define SHARABLE_MIDDLE_SUBSTRING 0

Definition at line 188 of file string.c.

## ◆ SHARABLE_SUBSTRING_P

#define SHARABLE_SUBSTRING_P | ( |  | beg,
|  |  | len,
|  |  | end
| ) |  | ((beg) + (len) == (end))

Definition at line 191 of file string.c.

## ◆ SPLIT_STR

#define SPLIT_STR | ( |  | beg,
|  |  | len
| ) |  | (empty_count = split_string(result, str, beg, len, empty_count))

## ◆ STR_BORROWED

#define STR_BORROWED FL_USER6

Definition at line 102 of file string.c.

## ◆ str_buf_cat2

#define str_buf_cat2 | ( |  | str,
|  |  | ptr
| ) |  | str_buf_cat((str), (ptr), strlen(ptr))

Definition at line 2959 of file string.c.

## ◆ STR_BUF_MIN_SIZE

#define STR_BUF_MIN_SIZE 63

Definition at line 1394 of file string.c.

## ◆ STR_DEC_LEN

#define STR_DEC_LEN | ( |  | str | ) |

Value:
do {\
if (STR_EMBED_P(str)) {\
long n = RSTRING_LEN(str);\
n--;\
STR_SET_EMBED_LEN((str), n);\
}\
else {\
RSTRING(str)->as.heap.len--;\
}\
} while (0)

Definition at line 127 of file string.c.

## ◆ STR_EMBEDDABLE_P

#define STR_EMBEDDABLE_P | ( |  | len,
|  |  | termlen
| ) |  | ((len) <= RSTRING_EMBED_LEN_MAX + 1 - (termlen))

Definition at line 196 of file string.c.

## ◆ STR_ENC_GET

#define STR_ENC_GET | ( |  | str | ) | get_encoding(str)

Definition at line 185 of file string.c.

## ◆ STR_FAKESTR

#define STR_FAKESTR FL_USER19

Definition at line 105 of file string.c.

## ◆ STR_HEAP_PTR

#define STR_HEAP_PTR | ( |  | str | ) | (RSTRING(str)->as.heap.ptr)

Definition at line 181 of file string.c.

## ◆ STR_HEAP_SIZE

#define STR_HEAP_SIZE | ( |  | str | ) | ((size_t)RSTRING(str)->as.heap.aux.capa + TERM_LEN(str))

Definition at line 182 of file string.c.

## ◆ STR_NOFREE

#define STR_NOFREE FL_USER18

Definition at line 104 of file string.c.

## ◆ STR_SET_EMBED

#define STR_SET_EMBED | ( |  | str | ) | FL_UNSET((str), (STR_NOEMBED|STR_NOFREE))

Definition at line 111 of file string.c.

## ◆ STR_SET_EMBED_LEN

#define STR_SET_EMBED_LEN | ( |  | str,
|  |  | n
| ) |  |

Value:
do { \
long tmp_n = (n);\
RBASIC(str)->flags &= ~RSTRING_EMBED_LEN_MASK;\
RBASIC(str)->flags |= (tmp_n) << RSTRING_EMBED_LEN_SHIFT;\
} while (0)
RSTRING_EMBED_LEN_SHIFT
#define RSTRING_EMBED_LEN_SHIFT
Definition: rstring.h:38

Definition at line 112 of file string.c.

## ◆ STR_SET_LEN

#define STR_SET_LEN | ( |  | str,
|  |  | n
| ) |  |

Value:
do { \
if (STR_EMBED_P(str)) {\
STR_SET_EMBED_LEN((str), (n));\
}\
else {\
RSTRING(str)->as.heap.len = (n);\
}\
} while (0)

Definition at line 118 of file string.c.

## ◆ STR_SET_NOEMBED

#define STR_SET_NOEMBED | ( |  | str | ) |

Value:
do {\
FL_SET((str), STR_NOEMBED);\
STR_SET_EMBED_LEN((str), 0);\
} while (0)
STR_NOEMBED
#define STR_NOEMBED
Definition: string.h:19

Definition at line 107 of file string.c.

## ◆ STR_SET_SHARED

#define STR_SET_SHARED | ( |  | str,
|  |  | shared_str
| ) |  |

Value:
do { \
if (!FL_TEST(str, STR_FAKESTR)) { \
RB_OBJ_WRITE((str), &RSTRING(str)->as.heap.aux.shared, (shared_str)); \
FL_SET((str), STR_SHARED); \
FL_SET((shared_str), STR_SHARED_ROOT); \
if (RBASIC_CLASS((shared_str)) == 0) /* for CoW-friendliness */ \
FL_SET_RAW((shared_str), STR_BORROWED); \
} \
} while (0)
RBASIC_CLASS
#define RBASIC_CLASS
Definition: rbasic.h:35
STR_SHARED_ROOT
#define STR_SHARED_ROOT
Definition: string.c:101
STR_BORROWED
#define STR_BORROWED
Definition: string.c:102
STR_FAKESTR
#define STR_FAKESTR
Definition: string.c:105

Definition at line 171 of file string.c.

## ◆ STR_SHARED_ROOT

#define STR_SHARED_ROOT FL_USER5

Definition at line 101 of file string.c.

## ◆ STR_TMPLOCK

#define STR_TMPLOCK FL_USER7

Definition at line 103 of file string.c.

## ◆ sym_equal

#define sym_equal rb_obj_equal

Definition at line 11008 of file string.c.

## ◆ TERM_FILL

#define TERM_FILL | ( |  | ptr,
|  |  | termlen
| ) |  |

Value:
do {\
char *const term_fill_ptr = (ptr);\
const int term_fill_len = (termlen);\
*term_fill_ptr = '\0';\
if (UNLIKELY(term_fill_len > 1))\
memset(term_fill_ptr, 0, term_fill_len);\
} while (0)
ptr
struct RIMemo * ptr
Definition: debug.c:88
UNLIKELY
#define UNLIKELY(x)
Definition: ffi_common.h:126

Definition at line 139 of file string.c.

## ◆ TERM_LEN

#define TERM_LEN | ( |  | str | ) | rb_enc_mbminlen(rb_enc_get(str))

Definition at line 138 of file string.c.

## ◆ TR_TABLE_MAX

#define TR_TABLE_MAX (UCHAR_MAX+1)

Definition at line 7625 of file string.c.

## ◆ TR_TABLE_SIZE

#define TR_TABLE_SIZE (TR_TABLE_MAX+1)

Definition at line 7626 of file string.c.

## ◆ WANTARRAY

#define WANTARRAY | ( |  | m,
|  |  | size
| ) |  | (!rb_block_given_p() ? rb_ary_new_capa(size) : 0)

Definition at line 8421 of file string.c.

## Typedef Documentation

## ◆ mapping_buffer

typedef struct mapping_buffer mapping_buffer

## ◆ USTR

typedef unsigned char* USTR

Definition at line 7255 of file string.c.

## Enumeration Type Documentation

## ◆ neighbor_char

enum neighbor_char

Enumerator
NEIGHBOR_NOT_CHAR |
NEIGHBOR_FOUND |
NEIGHBOR_WRAPPED |

Definition at line 4076 of file string.c.

## ◆ split_type_t

enum split_type_t

Enumerator
SPLIT_TYPE_AWK |
SPLIT_TYPE_STRING |
SPLIT_TYPE_REGEXP |
SPLIT_TYPE_CHARS |

Definition at line 8108 of file string.c.

## Function Documentation

## ◆ Init_String()

void Init_String | ( | void |  | ) |

Definition at line 11592 of file string.c.

References assert, CLASS_OF, ID2SYM, Qnil, rb_cObject, rb_cString, rb_cSymbol, rb_define_alloc_func(), rb_define_class(), ruby::backward::cxxanyargs::rb_define_hooked_variable(), rb_define_method, rb_define_module(), rb_define_singleton_method, rb_fs, rb_gc_register_address(), rb_include_module(), rb_mComparable, rb_obj_encoding(), rb_str_concat(), rb_str_dump(), rb_str_eql(), rb_str_equal(), rb_str_freeze(), rb_str_inspect(), rb_str_intern(), rb_str_length(), rb_str_plus(), rb_str_replace(), rb_str_succ(), rb_str_times(), rb_sym2str(), rb_sym_to_proc(), rb_sym_to_s(), rb_undef_alloc_func(), rb_undef_method(), rb_vm_fstring_table(), st_foreach, and sym_equal.

## ◆ rb_check_string_type()

VALUE rb_check_string_type | ( | VALUE | str | ) |

Definition at line 2462 of file string.c.

References rb_check_convert_type_with_id(), str, and T_STRING.

Referenced by rb_ary_join(), rb_check_id(), rb_check_sockaddr_string_type(), rb_check_symbol(), rb_fiddle_type_ensure(), rb_get_message(), rb_io_extract_encoding_option(), rb_num_get_rounding_option(), rb_str_format(), rb_str_include_range_p(), rb_String(), rb_time_zone_abbreviation(), and rb_to_encoding_index().

## ◆ rb_ec_str_resurrect()

VALUE rb_ec_str_resurrect | ( | struct rb_execution_context_struct * | ec,
|  | VALUE | str
| ) |  |

Definition at line 1644 of file string.c.

References rb_cString, RSTRING_LEN, RUBY_DTRACE_CREATE_HOOK, and str.

## ◆ rb_enc_interned_str()

VALUE rb_enc_interned_str | ( | const char * | ptr,
|  | long | len,
|  | rb_encoding * | enc
| ) |  |

Definition at line 11562 of file string.c.

References len, ptr, rb_enc_autoload(), rb_enc_autoload_p, rb_setup_fake_str(), TRUE, and UNLIKELY.

Referenced by rb_enc_interned_str_cstr().

## ◆ rb_enc_interned_str_cstr()

VALUE rb_enc_interned_str_cstr | ( | const char * | ptr,
|  | rb_encoding * | enc
| ) |  |

Definition at line 11573 of file string.c.

References ptr, rb_enc_interned_str(), and strlen().

## ◆ rb_enc_nth()

char * rb_enc_nth | ( | const char * | p,
|  | const char * | e,
|  | long | nth,
|  | rb_encoding * | enc
| ) |  |

Definition at line 2538 of file string.c.

Referenced by rb_str_ellipsize(), and rb_str_format().

## ◆ rb_enc_str_asciionly_p()

int rb_enc_str_asciionly_p | ( | VALUE | str | ) |

Definition at line 739 of file string.c.

References ENC_CODERANGE_7BIT, FALSE, rb_enc_asciicompat, rb_enc_str_coderange(), str, STR_ENC_GET, and TRUE.

Referenced by rb_file_expand_path_internal(), rb_inspect(), and rb_reg_quote().

## ◆ rb_enc_str_buf_cat()

VALUE rb_enc_str_buf_cat | ( | VALUE | str,
|  | const char * | ptr,
|  | long | len,
|  | rb_encoding * | ptr_enc
| ) |  |

Definition at line 3072 of file string.c.

References ENC_CODERANGE_UNKNOWN, len, NULL, ptr, rb_enc_to_index(), and str.

Referenced by rb_reg_regsub().

## ◆ rb_enc_str_coderange()

int rb_enc_str_coderange | ( | VALUE | str | ) |

Definition at line 725 of file string.c.

References ENC_CODERANGE, ENC_CODERANGE_SET, ENC_CODERANGE_UNKNOWN, ENCODING_GET, rb_enc_from_index(), and str.

Referenced by rb_econv_prepare_options(), rb_enc_str_asciionly_p(), rb_external_str_with_enc(), rb_file_expand_path_internal(), rb_reg_fragment_setenc(), rb_str_comparable(), rb_str_hash(), and RUBY_ALIAS_FUNCTION().

## ◆ rb_enc_str_coderange_scan()

int rb_enc_str_coderange_scan | ( | VALUE | str,
|  | rb_encoding * | enc
| ) |  |

Definition at line 719 of file string.c.

References rb_enc_to_index(), and str.

## ◆ rb_enc_str_new()

VALUE rb_enc_str_new | ( | const char * | ptr,
|  | long | len,
|  | rb_encoding * | enc
| ) |  |

Definition at line 857 of file string.c.

References len, ptr, rb_cString, rb_enc_associate(), rb_enc_mbminlen, rb_str_new, and str.

Referenced by rb_enc_reg_new(), rb_enc_str_new_cstr(), rb_enc_uint_chr(), rb_external_str_new_with_enc(), rb_intern3(), rb_readlink(), rb_str_upto_each(), rb_strftime(), rb_strftime_timespec(), rb_syntax_error_append(), and rb_w32_conv_from_wchar().

## ◆ rb_enc_str_new_cstr()

VALUE rb_enc_str_new_cstr | ( | const char * | ptr,
|  | rb_encoding * | enc
| ) |  |

Definition at line 897 of file string.c.

References ptr, rb_eArgError, rb_enc_mbminlen, rb_enc_str_new(), rb_raise(), and strlen().

## ◆ rb_enc_str_new_static()

VALUE rb_enc_str_new_static | ( | const char * | ptr,
|  | long | len,
|  | rb_encoding * | enc
| ) |  |

Definition at line 951 of file string.c.

References len, ptr, rb_cString, and rb_enc_to_index().

## ◆ rb_enc_str_scrub()

VALUE rb_enc_str_scrub | ( | rb_encoding * | enc,
|  | VALUE | str,
|  | VALUE | repl
| ) |  |

Definition at line 10587 of file string.c.

References ENC_CODERANGE, ENC_CODERANGE_UNKNOWN, str, and STR_ENC_GET.

## ◆ rb_enc_strlen()

long rb_enc_strlen | ( | const char * | p,
|  | const char * | e,
|  | rb_encoding * | enc
| ) |  |

Definition at line 1887 of file string.c.

References ENC_CODERANGE_UNKNOWN.

Referenced by rb_str_format().

## ◆ rb_enc_strlen_cr()

long rb_enc_strlen_cr | ( | const char * | p,
|  | const char * | e,
|  | rb_encoding * | enc,
|  | int * | cr
| ) |  |

Definition at line 1896 of file string.c.

References ENC_CODERANGE_7BIT, ENC_CODERANGE_BROKEN, ENC_CODERANGE_VALID, ISASCII, long(), MBCLEN_CHARFOUND_LEN, MBCLEN_CHARFOUND_P, rb_enc_asciicompat, rb_enc_mbmaxlen, rb_enc_mbminlen, and rb_enc_precise_mbclen().

## ◆ rb_external_str_new()

VALUE rb_external_str_new | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 1157 of file string.c.

References len, ptr, rb_default_external_encoding(), and rb_external_str_new_with_enc().

## ◆ rb_external_str_new_cstr()

VALUE rb_external_str_new_cstr | ( | const char * | ptr | ) |

Definition at line 1163 of file string.c.

References ptr, rb_default_external_encoding(), rb_external_str_new_with_enc(), and strlen().

## ◆ rb_external_str_new_with_enc()

VALUE rb_external_str_new_with_enc | ( | const char * | ptr,
|  | long | len,
|  | rb_encoding * | eenc
| ) |  |

Definition at line 1106 of file string.c.

References len, NIL_P, NULL, ptr, Qnil, rb_ascii8bit_encindex, rb_default_internal_encoding(), rb_enc_asciicompat, rb_enc_str_new(), rb_enc_to_index(), rb_str_cat_conv_enc_opts(), rb_str_initialize(), rb_str_new, rb_usascii_encindex, and str.

Referenced by rb_external_str_new(), rb_external_str_new_cstr(), rb_filesystem_str_new(), rb_filesystem_str_new_cstr(), rb_locale_str_new(), and rb_locale_str_new_cstr().

## ◆ rb_external_str_with_enc()

VALUE rb_external_str_with_enc | ( | VALUE | str,
|  | rb_encoding * | eenc
| ) |  |

Definition at line 1144 of file string.c.

References ENC_CODERANGE_7BIT, rb_ascii8bit_encindex, rb_default_internal_encoding(), rb_enc_associate_index(), rb_enc_str_coderange(), rb_enc_to_index(), rb_str_conv_enc(), rb_usascii_encindex, and str.

## ◆ rb_filesystem_str_new()

VALUE rb_filesystem_str_new | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 1181 of file string.c.

References len, ptr, rb_external_str_new_with_enc(), and rb_filesystem_encoding().

## ◆ rb_filesystem_str_new_cstr()

VALUE rb_filesystem_str_new_cstr | ( | const char * | ptr | ) |

Definition at line 1187 of file string.c.

References ptr, rb_external_str_new_with_enc(), rb_filesystem_encoding(), and strlen().

Referenced by rb_parser_compile_string().

## ◆ rb_fstring()

VALUE rb_fstring | ( | VALUE | str | ) |

Definition at line 353 of file string.c.

References assert, BARE_STRING_P, FALSE, FL_TEST, FL_TEST_RAW, fstr_update_arg::fstr, OBJ_FREEZE_RAW, OBJ_FROZEN, rb_str_resize(), RSTRING_FSTR, RSTRING_LEN, str, STR_NOEMBED, STR_SHARED, STR_SHARED_ROOT, and T_STRING.

Referenced by rb_autoload_str(), rb_enc_reg_new(), rb_hash_key_str(), rb_iseq_pathobj_new(), rb_node_case_when_optimizable_literal(), rb_parser_lex_state_name(), rb_str_intern(), rb_str_to_interned_str(), and yyparse().

## ◆ rb_fstring_cstr()

VALUE rb_fstring_cstr | ( | const char * | ptr | ) |

Definition at line 460 of file string.c.

References ptr, rb_fstring_new(), and strlen().

## ◆ rb_fstring_enc_new()

VALUE rb_fstring_enc_new | ( | const char * | ptr,
|  | long | len,
|  | rb_encoding * | enc
| ) |  |

Definition at line 453 of file string.c.

References FALSE, len, ptr, and rb_setup_fake_str().

## ◆ rb_fstring_new()

VALUE rb_fstring_new | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 446 of file string.c.

References ENCINDEX_US_ASCII, FALSE, len, and ptr.

Referenced by rb_deprecate_constant(), and rb_fstring_cstr().

## ◆ rb_id_quote_unprintable()

VALUE rb_id_quote_unprintable | ( | ID | id | ) |

Definition at line 11067 of file string.c.

References rb_id2str, rb_str_inspect(), rb_str_symname_p(), and str.

## ◆ rb_interned_str()

VALUE rb_interned_str | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 11549 of file string.c.

References ENCINDEX_US_ASCII, len, ptr, and TRUE.

Referenced by rb_interned_str_cstr().

## ◆ rb_interned_str_cstr()

VALUE rb_interned_str_cstr | ( | const char * | ptr | ) |

Definition at line 11556 of file string.c.

References ptr, rb_interned_str(), and strlen().

## ◆ rb_locale_str_new()

VALUE rb_locale_str_new | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 1169 of file string.c.

References len, ptr, rb_external_str_new_with_enc(), and rb_locale_encoding().

## ◆ rb_locale_str_new_cstr()

VALUE rb_locale_str_new_cstr | ( | const char * | ptr | ) |

Definition at line 1175 of file string.c.

References ptr, rb_external_str_new_with_enc(), rb_locale_encoding(), and strlen().

## ◆ rb_must_asciicompat()

void rb_must_asciicompat | ( | VALUE | str | ) |

Definition at line 2314 of file string.c.

References rb_eEncCompatError, rb_enc_asciicompat, rb_enc_get(), rb_enc_name, rb_raise(), and str.

Referenced by rb_num_get_rounding_option(), rb_str2big_karatsuba(), rb_str2big_normal(), rb_str2big_poweroftwo(), and rb_str_convert_to_inum().

## ◆ rb_obj_as_string()

VALUE rb_obj_as_string | ( | VALUE | obj | ) |

Definition at line 1529 of file string.c.

References rb_funcall(), rb_obj_as_string_result(), str, and T_STRING.

Referenced by rb_inspect(), rb_io_puts(), rb_p(), rb_str_format(), and rb_time_zone_abbreviation().

## ◆ rb_obj_as_string_result()

VALUE rb_obj_as_string_result | ( | VALUE | str,
|  | VALUE | obj
| ) |  |

Definition at line 1541 of file string.c.

References rb_any_to_s(), str, and T_STRING.

Referenced by rb_obj_as_string().

## ◆ rb_setup_fake_str()

VALUE rb_setup_fake_str | ( | struct RString * | fake_str,
|  | const char * | name,
|  | long | len,
|  | rb_encoding * | enc
| ) |  |

Definition at line 435 of file string.c.

References len, name, and rb_enc_to_index().

Referenced by rb_check_id_cstr(), rb_check_symbol_cstr(), rb_enc_interned_str(), rb_fstring_enc_new(), rb_intern3(), rb_sym_intern(), and ruby_require_internal().

## ◆ rb_str_append()

VALUE rb_str_append | ( | VALUE | str,
|  | VALUE | str2
| ) |  |

Definition at line 3118 of file string.c.

References rb_str_buf_append(), str, and StringValue.

Referenced by ole_raise(), rb_keyword_error_new(), rb_load_fail(), rb_str_concat(), and rb_str_ellipsize().

## ◆ rb_str_buf_append()

VALUE rb_str_buf_append | ( | VALUE | str,
|  | VALUE | str2
| ) |  |

Definition at line 3103 of file string.c.

References ENC_CODERANGE, ENC_CODERANGE_SET, ENCODING_GET, RSTRING_LEN, RSTRING_PTR, and str.

Referenced by rb_str_append().

## ◆ rb_str_buf_cat_ascii()

VALUE rb_str_buf_cat_ascii | ( | VALUE | str,
|  | const char * | ptr
| ) |  |

Definition at line 3079 of file string.c.

References ALLOCA_N, ENC_CODERANGE_7BIT, ENC_CODERANGE_VALID, ENCODING_GET, len, ptr, rb_enc_asciicompat, rb_enc_codelen(), rb_enc_from_index(), rb_enc_mbcput, rb_enc_mbmaxlen, str, and strlen().

## ◆ rb_str_buf_cat_escaped_char()

int rb_str_buf_cat_escaped_char | ( | VALUE | result,
|  | unsigned int | c,
|  | int | unicode_p
| ) |  |

Definition at line 6084 of file string.c.

References CHAR_ESC_LEN, int(), ISPRINT, rb_str_buf_cat, snprintf, and strlen().

Referenced by rb_str_escape(), and rb_str_inspect().

## ◆ rb_str_buf_new()

VALUE rb_str_buf_new | ( | long | capa | ) |

Definition at line 1398 of file string.c.

References ALLOC_N, RString::capa, FL_SET, rb_cString, RSTRING, RSTRING_EMBED_LEN_MAX, str, STR_BUF_MIN_SIZE, and STR_NOEMBED.

Referenced by rb_ary_join(), rb_econv_append(), rb_enc_vsprintf(), rb_reg_regsub(), rb_str_buf_new_cstr(), rb_str_concat_literals(), rb_str_conv_enc_opts(), rb_str_escape(), rb_str_format(), and rb_str_inspect().

## ◆ rb_str_buf_new_cstr()

VALUE rb_str_buf_new_cstr | ( | const char * | ptr | ) |

Definition at line 1415 of file string.c.

References len, ptr, rb_str_buf_cat, rb_str_buf_new(), str, and strlen().

## ◆ rb_str_capacity()

size_t rb_str_capacity | ( | VALUE | str | ) |

Definition at line 773 of file string.c.

References str, and TERM_LEN.

Referenced by rb_econv_append(), rb_str_format(), and rb_str_vcatf().

## ◆ rb_str_cat()

VALUE rb_str_cat | ( | VALUE | str,
|  | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 2962 of file string.c.

References len, ptr, rb_eArgError, rb_raise(), and str.

Referenced by rb_file_dirname(), rb_id_attrset(), rb_str_cat_conv_enc_opts(), rb_str_concat(), rb_str_ellipsize(), rb_str_initialize(), and rsock_inspect_sockaddr().

## ◆ rb_str_cat_conv_enc_opts()

VALUE rb_str_cat_conv_enc_opts | ( | VALUE | newstr,
|  | long | ofs,
|  | const char * | ptr,
|  | long | len,
|  | rb_encoding * | from,
|  | int | ecflags,
|  | VALUE | ecopts
| ) |  |

Definition at line 1013 of file string.c.

References len, ptr, rb_eIndexError, rb_enc_get(), rb_raise(), rb_str_cat(), rb_str_modify(), RSTRING_LEN, and STR_SET_LEN.

Referenced by rb_external_str_new_with_enc(), and rb_file_expand_path_internal().

## ◆ rb_str_cat_cstr()

VALUE rb_str_cat_cstr | ( | VALUE | str,
|  | const char * | ptr
| ) |  |

Definition at line 2972 of file string.c.

References ptr, rb_str_buf_cat, str, and strlen().

## ◆ rb_str_change_terminator_length()

void rb_str_change_terminator_length | ( | VALUE | str,
|  | const int | oldtermlen,
|  | const int | termlen
| ) |  |

Definition at line 2378 of file string.c.

References assert, RString::capa, FL_TEST, L, len, RSTRING, RSTRING_LEN, RSTRING_PTR, str, STR_SHARED, and TERM_FILL.

Referenced by rb_enc_associate_index().

## ◆ rb_str_chomp_string()

VALUE rb_str_chomp_string | ( | VALUE | str,
|  | VALUE | rs
| ) |  |

Definition at line 9236 of file string.c.

References ENC_CODERANGE, ENC_CODERANGE_7BIT, ENC_CODERANGE_CLEAR, len, Qnil, RSTRING_LEN, RSTRING_PTR, str, STR_SET_LEN, TERM_FILL, and TERM_LEN.

## ◆ rb_str_cmp()

int rb_str_cmp | ( | VALUE | str1,
|  | VALUE | str2
| ) |  |

Definition at line 3378 of file string.c.

References ENCODING_GET, lesser, memcmp(), rb_str_comparable(), and RSTRING_GETMEM.

Referenced by rb_iseq_pathobj_new(), and rb_str_upto_each().

## ◆ rb_str_coderange_scan_restartable()

long rb_str_coderange_scan_restartable | ( | const char * | s,
|  | const char * | e,
|  | rb_encoding * | enc,
|  | int * | cr
| ) |  |

Definition at line 617 of file string.c.

References ENC_CODERANGE_7BIT, ENC_CODERANGE_BROKEN, ENC_CODERANGE_UNKNOWN, ENC_CODERANGE_VALID, MBCLEN_CHARFOUND_LEN, MBCLEN_CHARFOUND_P, MBCLEN_INVALID_P, rb_ascii8bit_encindex, rb_enc_asciicompat, rb_enc_precise_mbclen(), and rb_enc_to_index().

Referenced by rb_str_format().

## ◆ rb_str_comparable()

int rb_str_comparable | ( | VALUE | str1,
|  | VALUE | str2
| ) |  |

Definition at line 3353 of file string.c.

References ENC_CODERANGE_7BIT, ENCODING_GET, FALSE, rb_enc_asciicompat, rb_enc_from_index(), rb_enc_str_coderange(), RSTRING_LEN, and TRUE.

Referenced by rb_str_cmp(), and rb_str_hash_cmp().

## ◆ rb_str_concat()

VALUE rb_str_concat | ( | VALUE | str1,
|  | VALUE | str2
| ) |  |

Definition at line 3217 of file string.c.

References ALLOCA_N, ENC_CODERANGE, ENC_CODERANGE_7BIT, ENC_CODERANGE_SET, ENC_CODERANGE_VALID, ENCINDEX_ASCII, ENCINDEX_US_ASCII, FIX2LONG, FIXNUM_P, len, memcpy, ONIGERR_INVALID_CODE_POINT_VALUE, ONIGERR_TOO_BIG_WIDE_CHAR_VALUE, rb_enc_associate_index(), rb_enc_codelen(), rb_enc_mbcput, rb_enc_name, rb_enc_precise_mbclen(), rb_enc_to_index(), rb_eRangeError, RB_INTEGER_TYPE_P, rb_num_to_uint(), rb_raise(), rb_str_append(), rb_str_cat(), rb_str_resize(), RSTRING_LEN, RSTRING_PTR, and STR_ENC_GET.

Referenced by Init_String(), make_inspect(), ole_typedesc2val(), rb_iseq_disasm_insn(), and rsock_raise_socket_error().

## ◆ rb_str_concat_literals()

VALUE rb_str_concat_literals | ( | size_t | num,
|  | const VALUE * | strary
| ) |  |

Definition at line 3127 of file string.c.

References ENC_CODERANGE, ENCINDEX_US_ASCII, ENCODING_GET, ENCODING_GET_INLINED, len, LIKELY, MIN_PRE_ALLOC_SIZE, NULL, num, rb_enc_copy(), rb_enc_set_index(), rb_str_buf_new(), rb_str_new, rb_str_resurrect(), RSTRING_LEN, RSTRING_PTR, str, and UNLIKELY.

## ◆ rb_str_conv_enc()

VALUE rb_str_conv_enc | ( | VALUE | str,
|  | rb_encoding * | from,
|  | rb_encoding * | to
| ) |  |

Definition at line 1100 of file string.c.

References Qnil, rb_str_conv_enc_opts(), and str.

Referenced by rb_dir_getwd(), rb_external_str_with_enc(), rb_home_dir_of(), rb_str_encode_ospath(), rb_str_export(), rb_str_export_locale(), rb_str_export_to_enc(), and rb_w32_set_thread_description_str().

## ◆ rb_str_conv_enc_opts()

VALUE rb_str_conv_enc_opts | ( | VALUE | str,
|  | rb_encoding * | from,
|  | rb_encoding * | to,
|  | int | ecflags,
|  | VALUE | ecopts
| ) |  |

Definition at line 984 of file string.c.

References len, NIL_P, ptr, rb_ascii8bit_encoding(), rb_enc_asciicompat, rb_enc_associate(), rb_enc_get(), rb_str_buf_new(), rb_str_dup(), RSTRING_GETMEM, str, and STR_ENC_GET.

Referenced by rb_str_conv_enc(), rb_w32_conv_from_wchar(), and rb_w32_write_console().

## ◆ rb_str_drop_bytes()

VALUE rb_str_drop_bytes | ( | VALUE | str,
|  | long | len
| ) |  |

Definition at line 4795 of file string.c.

References ENC_CODERANGE_CLEAR, int(), len, memmove(), ptr, rb_str_new_frozen(), RBASIC, RSTRING, RSTRING_LEN, RSTRING_PTR, str, STR_EMBEDDABLE_P, STR_NOEMBED, STR_NOFREE, STR_SET_EMBED, STR_SET_EMBED_LEN, STR_SHARED, TERM_LEN, and xfree.

## ◆ rb_str_dump()

VALUE rb_str_dump | ( | VALUE | str | ) |

Definition at line 6311 of file string.c.

References ENC_CODERANGE_7BIT, ENC_CODERANGE_SET, IS_EVSTR, ISPRINT, len, LONG_MAX, MBCLEN_CHARFOUND_LEN, MBCLEN_CHARFOUND_P, OnigEncodingTypeST::name, rb_ascii8bit_encindex, rb_enc_asciicompat, rb_enc_associate_index(), rb_enc_from_index(), rb_enc_get_index(), rb_enc_mbc_to_codepoint, rb_enc_precise_mbclen(), rb_eRuntimeError, rb_raise(), rb_str_new, rb_strlen_lit, rb_utf8_encindex, RSTRING_LEN, RSTRING_PTR, snprintf, str, and strlen().

Referenced by Init_String(), and rb_econv_prepare_options().

## ◆ rb_str_dup()

VALUE rb_str_dup | ( | VALUE | str | ) |

Definition at line 1631 of file string.c.

References rb_obj_class(), and str.

Referenced by date__parse(), rb_class_path(), rb_find_file_ext(), rb_id_attrset(), rb_str_conv_enc_opts(), rb_str_intern(), rb_vm_set_progname(), rsock_ipaddr(), and ruby_set_script_name().

## ◆ rb_str_ellipsize()

VALUE rb_str_ellipsize | ( | VALUE | str,
|  | long | len
| ) |  |

Shortens str and adds three dots, an ellipsis, if it is longer than len characters.

Parameters

  str | the string to ellipsize.
  len | the maximum string length.

Returns
  the ellipsized string.

Precondition
  len must not be negative.

Postcondition
  the length of the returned string in characters is less than or equal to len.
  If the length of str is less than or equal len, returns str itself.
  the encoding of returned string is equal to the encoding of str.
  the class of returned string is equal to the class of str.

Note
  the length is counted in characters.

Definition at line 10517 of file string.c.

References len, Qnil, rb_eIndexError, rb_enc_asciicompat, rb_enc_associate(), rb_enc_from_encoding(), rb_enc_get(), rb_enc_mbminlen, rb_enc_nth(), rb_enc_step_back, rb_raise(), rb_str_append(), rb_str_cat(), rb_str_encode(), rb_str_new, rb_str_subseq(), rb_usascii_str_new, RSTRING_LEN, RSTRING_PTR, and str.

## ◆ rb_str_eql()

VALUE rb_str_eql | ( | VALUE | str1,
|  | VALUE | str2
| ) |  |

Definition at line 3451 of file string.c.

References Qfalse, Qtrue, and T_STRING.

Referenced by Init_String().

## ◆ rb_str_equal()

VALUE rb_str_equal | ( | VALUE | str1,
|  | VALUE | str2
| ) |  |

Definition at line 3423 of file string.c.

References Qfalse, Qtrue, rb_equal(), rb_respond_to(), and T_STRING.

Referenced by Init_String(), rb_get_expanded_load_path(), and rb_str_upto_each().

## ◆ rb_str_export()

VALUE rb_str_export | ( | VALUE | str | ) |

Definition at line 1193 of file string.c.

References rb_default_external_encoding(), rb_str_conv_enc(), str, and STR_ENC_GET.

## ◆ rb_str_export_locale()

VALUE rb_str_export_locale | ( | VALUE | str | ) |

Definition at line 1199 of file string.c.

References rb_locale_encoding(), rb_str_conv_enc(), str, and STR_ENC_GET.

## ◆ rb_str_export_to_enc()

VALUE rb_str_export_to_enc | ( | VALUE | str,
|  | rb_encoding * | enc
| ) |  |

Definition at line 1205 of file string.c.

References rb_str_conv_enc(), str, and STR_ENC_GET.

## ◆ rb_str_fill_terminator()

char * rb_str_fill_terminator | ( | VALUE | str,
|  | const int | newminlen
| ) |  |

Definition at line 2454 of file string.c.

References len, RSTRING_LEN, RSTRING_PTR, and str.

## ◆ rb_str_free()

void rb_str_free | ( | VALUE | str | ) |

Definition at line 1433 of file string.c.

References FL_TEST, NULL, RB_DEBUG_COUNTER_INC, RB_DEBUG_COUNTER_INC_IF, rb_vm_fstring_table(), RB_VM_LOCK_ENTER, RB_VM_LOCK_LEAVE, RSTRING_FSTR, ruby_sized_xfree, st_delete, str, STR_HEAP_PTR, STR_HEAP_SIZE, STR_NOFREE, and STR_SHARED.

## ◆ rb_str_freeze()

VALUE rb_str_freeze | ( | VALUE | str | ) |

Definition at line 2766 of file string.c.

References OBJ_FROZEN, rb_obj_freeze(), rb_str_resize(), RSTRING_LEN, and str.

Referenced by Init_String().

## ◆ rb_str_hash()

st_index_t rb_str_hash | ( | VALUE | str | ) |

Definition at line 3314 of file string.c.

References ENC_CODERANGE_7BIT, ENCODING_GET, rb_enc_str_coderange(), rb_memhash(), RSTRING_LEN, RSTRING_PTR, and str.

## ◆ rb_str_hash_cmp()

int rb_str_hash_cmp | ( | VALUE | str1,
|  | VALUE | str2
| ) |  |

Definition at line 3324 of file string.c.

References memcmp(), rb_str_comparable(), and RSTRING_GETMEM.

## ◆ rb_str_include_range_p()

VALUE rb_str_include_range_p | ( | VALUE | beg,
|  | VALUE | end,
|  | VALUE | val,
|  | VALUE | exclusive
| ) |  |

Definition at line 4618 of file string.c.

References re_registers::beg, bp, re_registers::end, ISASCII, ISDIGIT, NIL_P, Qfalse, Qtrue, rb_check_string_type(), rb_enc_asciicompat, rb_str_new_frozen(), rb_str_upto_each(), RSTRING_LEN, RSTRING_PTR, RTEST, STR_ENC_GET, and StringValue.

## ◆ rb_str_initialize()

VALUE rb_str_initialize | ( | VALUE | str,
|  | const char * | ptr,
|  | long | len,
|  | rb_encoding * | enc
| ) |  |

Definition at line 1034 of file string.c.

References len, ptr, rb_enc_associate(), rb_str_cat(), str, and STR_SET_LEN.

Referenced by rb_external_str_new_with_enc().

## ◆ rb_str_inspect()

VALUE rb_str_inspect | ( | VALUE | str | ) |

Definition at line 6199 of file string.c.

References CHAR_ESC_LEN, ENCODING_GET, int(), ISPRINT, MBCLEN_CHARFOUND_LEN, MBCLEN_CHARFOUND_P, NULL, rb_default_external_encoding(), rb_default_internal_encoding(), rb_enc_asciicompat, rb_enc_associate(), rb_enc_codepoint, rb_enc_from_index(), rb_enc_isascii, rb_enc_isprint, rb_enc_mbc_to_codepoint, rb_enc_mbminlen, rb_enc_precise_mbclen(), rb_enc_unicode_p(), rb_str_buf_cat_escaped_char(), rb_str_buf_new(), rb_usascii_encoding(), RSTRING_PTR, snprintf, str, str_buf_cat2, and strlen().

Referenced by Init_String(), rb_id_quote_unprintable(), and rb_str_quote_unprintable().

## ◆ rb_str_length()

VALUE rb_str_length | ( | VALUE | str | ) |

Definition at line 1995 of file string.c.

References LONG2NUM, NULL, and str.

Referenced by Init_String(), and rb_reg_match_p().

## ◆ rb_str_locktmp_ensure()

VALUE rb_str_locktmp_ensure | ( | VALUE | str,
|  | VALUE(*)(VALUE) | func,
|  | VALUE | arg
| ) |  |

Definition at line 2835 of file string.c.

References rb_ensure(), rb_str_locktmp(), rb_str_unlocktmp(), and str.

Referenced by rsock_s_recvfrom().

## ◆ rb_str_make_independent()

void rb_str_make_independent | ( | VALUE | str | ) |

Definition at line 220 of file string.c.

References str.

## ◆ rb_str_memsize()

size_t rb_str_memsize | ( | VALUE | str | ) |

Definition at line 1460 of file string.c.

References FL_TEST, str, STR_HEAP_SIZE, STR_NOEMBED, STR_NOFREE, and STR_SHARED.

## ◆ rb_str_modify()

void rb_str_modify | ( | VALUE | str | ) |

Definition at line 2262 of file string.c.

References ENC_CODERANGE_CLEAR, and str.

Referenced by rb_str_cat_conv_enc_opts(), and rb_str_vcatf().

## ◆ rb_str_modify_expand()

void rb_str_modify_expand | ( | VALUE | str,
|  | long | expand
| ) |  |

Definition at line 2270 of file string.c.

References ENC_CODERANGE_CLEAR, len, LONG_MAX, rb_eArgError, rb_raise(), RESIZE_CAPA_TERM, RSTRING_LEN, str, and TERM_LEN.

Referenced by rb_file_expand_path_internal().

## ◆ rb_str_new()

VALUE rb_str_new | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 835 of file string.c.

References len, ptr, and rb_cString.

## ◆ rb_str_new_cstr()

VALUE rb_str_new_cstr | ( | const char * | ptr | ) |

Definition at line 869 of file string.c.

References ptr, rb_str_new, and strlen().

## ◆ rb_str_new_frozen()

VALUE rb_str_new_frozen | ( | VALUE | orig | ) |

Definition at line 1273 of file string.c.

References OBJ_FROZEN, and rb_obj_class().

Referenced by rb_econv_prepare_options(), rb_econv_substr_append(), rb_hash_key_str(), rb_set_class_path_string(), rb_str_drop_bytes(), and rb_str_include_range_p().

## ◆ rb_str_new_shared()

VALUE rb_str_new_shared | ( | VALUE | str | ) |

Definition at line 1267 of file string.c.

References rb_obj_class(), and str.

Referenced by rb_str_subseq().

## ◆ rb_str_new_static()

VALUE rb_str_new_static | ( | const char * | ptr,
|  | long | len
| ) |  |

*_str_new_static functions are intended for C string literals.

They require memory in the range [ptr, ptr+len] to always be readable. Note that this range covers a total of len + 1 bytes.

Definition at line 933 of file string.c.

References len, ptr, and rb_cString.

## ◆ rb_str_new_with_class()

VALUE rb_str_new_with_class | ( | VALUE | obj,
|  | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 1381 of file string.c.

References len, ptr, rb_obj_class(), and TERM_LEN.

## ◆ rb_str_offset()

long rb_str_offset | ( | VALUE | str,
|  | long | pos
| ) |  |

Definition at line 2566 of file string.c.

References RSTRING_PTR, str, and STR_ENC_GET.

## ◆ rb_str_opt_plus()

VALUE rb_str_opt_plus | ( | VALUE | str1,
|  | VALUE | str2
| ) |  |

Definition at line 2075 of file string.c.

References assert, LONG_MAX, MAYBE_UNUSED, Qundef, rb_cString, rb_enc_get_index(), rb_str_plus(), RBASIC_CLASS, and RSTRING_GETMEM.

## ◆ rb_str_plus()

VALUE rb_str_plus | ( | VALUE | str1,
|  | VALUE | str2
| ) |  |

Definition at line 2044 of file string.c.

References ENC_CODERANGE, ENC_CODERANGE_AND, ENCODING_CODERANGE_SET, LONG_MAX, memcpy, rb_cString, rb_eArgError, rb_enc_check_str(), rb_enc_mbminlen, rb_enc_to_index(), RB_GC_GUARD, rb_raise(), RSTRING_GETMEM, RSTRING_PTR, StringValue, and TERM_FILL.

Referenced by Init_String(), and rb_str_opt_plus().

## ◆ rb_str_quote_unprintable()

VALUE rb_str_quote_unprintable | ( | VALUE | str | ) |

Definition at line 11046 of file string.c.

References len, NULL, ptr, rb_default_external_encoding(), rb_default_internal_encoding(), rb_str_inspect(), RSTRING_LEN, RSTRING_PTR, str, STR_ENC_GET, and T_STRING.

## ◆ rb_str_replace()

VALUE rb_str_replace | ( | VALUE | str,
|  | VALUE | str2
| ) |  |

Definition at line 5632 of file string.c.

References str, and StringValue.

Referenced by Init_String().

## ◆ rb_str_resize()

VALUE rb_str_resize | ( | VALUE | str,
|  | long | len
| ) |  |

Definition at line 2859 of file string.c.

References RString::as, RString::capa, ENC_CODERANGE_CLEAR, len, MEMCPY, ptr, rb_eArgError, rb_raise(), RSTRING, RSTRING_LEN, ruby_xfree(), SIZED_REALLOC_N, str, STR_EMBEDDABLE_P, STR_HEAP_PTR, STR_HEAP_SIZE, STR_SET_EMBED, STR_SET_EMBED_LEN, TERM_FILL, and TERM_LEN.

Referenced by rb_default_home_dir(), rb_econv_append(), rb_enc_vsprintf(), rb_file_expand_path_internal(), rb_find_file(), rb_find_file_ext(), rb_fstring(), rb_iseq_disasm(), rb_parser_fatal(), rb_reg_quote(), rb_str_concat(), rb_str_format(), rb_str_freeze(), rb_str_vcatf(), ruby_init_loadpath(), and VpAlloc().

## ◆ rb_str_resurrect()

VALUE rb_str_resurrect | ( | VALUE | str | ) |

Definition at line 1637 of file string.c.

References rb_cString, RSTRING_LEN, RUBY_DTRACE_CREATE_HOOK, and str.

Referenced by rb_str_concat_literals().

## ◆ rb_str_scrub()

VALUE rb_str_scrub | ( | VALUE | str,
|  | VALUE | repl
| ) |  |

Parameters

  str | the string to be scrubbed
  repl | the replacement character

Returns
  If given string is invalid, returns a new string. Otherwise, returns Qnil.

Definition at line 10580 of file string.c.

References ENC_CODERANGE, str, and STR_ENC_GET.

## ◆ rb_str_set_len()

void rb_str_set_len | ( | VALUE | str,
|  | long | len
| ) |  |

Definition at line 2842 of file string.c.

References RString::capa, len, rb_bug(), rb_eRuntimeError, rb_raise(), RSTRING_PTR, str, STR_SET_LEN, TERM_FILL, and TERM_LEN.

Referenced by ole_wc2vstr(), rb_ary_join(), rb_econv_append(), rb_file_expand_path_internal(), rb_find_file_ext(), rb_str_format(), rb_warn_deprecated(), rb_warn_deprecated_to_remove(), rsock_s_recvfrom(), and rsock_s_recvfrom_nonblock().

## ◆ rb_str_setter()

void rb_str_setter | ( | VALUE | val,
|  | ID | id,
|  | VALUE * | var
| ) |  |

Definition at line 10409 of file string.c.

References NIL_P, PRIsVALUE, rb_eTypeError, rb_id2str, rb_raise(), and T_STRING.

## ◆ rb_str_shared_replace()

void rb_str_shared_replace | ( | VALUE | str,
|  | VALUE | str2
| ) |  |

Definition at line 1480 of file string.c.

References str.

## ◆ rb_str_split()

VALUE rb_str_split | ( | VALUE | str,
|  | const char * | sep0
| ) |  |

Definition at line 8412 of file string.c.

References rb_str_new_cstr, str, and StringValue.

## ◆ rb_str_strlen()

long rb_str_strlen | ( | VALUE | str | ) |

Definition at line 1976 of file string.c.

References NULL, and str.

## ◆ rb_str_sublen()

long rb_str_sublen | ( | VALUE | str,
|  | long | pos
| ) |  |

Definition at line 2613 of file string.c.

References ENC_CODERANGE, RSTRING_PTR, str, and STR_ENC_GET.

Referenced by rb_reg_match(), and rb_reg_match2().

## ◆ rb_str_subpos()

char * rb_str_subpos | ( | VALUE | str,
|  | long | beg,
|  | long * | lenp
| ) |  |

Definition at line 2647 of file string.c.

References ENC_CODERANGE, ENC_CODERANGE_VALID, len, rb_enc_mbmaxlen, rb_enc_mbminlen, rb_enc_prev_char, RB_GC_GUARD, rb_utf8_encoding(), RSTRING_LEN, RSTRING_PTR, str, and STR_ENC_GET.

Referenced by rb_reg_match_p().

## ◆ rb_str_subseq()

VALUE rb_str_subseq | ( | VALUE | str,
|  | long | beg,
|  | long | len
| ) |  |

Definition at line 2624 of file string.c.

References len, RB_GC_GUARD, rb_str_new, rb_str_new_shared(), RSTRING, RSTRING_LEN, RSTRING_PTR, SHARABLE_SUBSTRING_P, str, STR_EMBEDDABLE_P, and TERM_LEN.

Referenced by rb_path_to_class(), rb_reg_match_post(), rb_reg_match_pre(), rb_reg_nth_match(), rb_reg_regsub(), rb_str_ellipsize(), and ruby_init_loadpath().

## ◆ rb_str_substr()

VALUE rb_str_substr | ( | VALUE | str,
|  | long | beg,
|  | long | len
| ) |  |

Definition at line 2734 of file string.c.

References len, str, and TRUE.

## ◆ rb_str_succ()

VALUE rb_str_succ | ( | VALUE | orig | ) |

Definition at line 4315 of file string.c.

References rb_str_new, RSTRING_LEN, RSTRING_PTR, and str.

Referenced by Init_String().

## ◆ rb_str_symname_p()

int rb_str_symname_p | ( | VALUE | sym | ) |

Definition at line 11027 of file string.c.

References FALSE, len, NULL, ptr, rb_default_external_encoding(), rb_default_internal_encoding(), rb_enc_symname2_p(), RSTRING_LEN, RSTRING_PTR, STR_ENC_GET, strlen(), sym, and TRUE.

Referenced by rb_id_quote_unprintable().

## ◆ rb_str_times()

VALUE rb_str_times | ( | VALUE | str,
|  | VALUE | times
| ) |  |

Definition at line 2114 of file string.c.

References INT2FIX, len, LONG_MAX, memcpy, NUM2LONG, rb_cString, rb_eArgError, rb_enc_copy(), rb_raise(), RSTRING, RSTRING_LEN, RSTRING_PTR, str, STR_EMBEDDABLE_P, STR_SET_LEN, STR_SET_NOEMBED, TERM_FILL, TERM_LEN, and ZALLOC_N.

Referenced by Init_String().

## ◆ rb_str_tmp_frozen_acquire()

VALUE rb_str_tmp_frozen_acquire | ( | VALUE | orig | ) |

Definition at line 1287 of file string.c.

References FALSE, and OBJ_FROZEN_RAW.

Referenced by rb_str_format().

## ◆ rb_str_tmp_frozen_release()

void rb_str_tmp_frozen_release | ( | VALUE | orig,
|  | VALUE | tmp
| ) |  |

Definition at line 1294 of file string.c.

References RString::as, assert, FL_TEST_RAW, FL_UNSET_RAW, OBJ_FROZEN_RAW, rb_gc_force_recycle(), RBASIC, RBASIC_CLASS, RSTRING, RUBY_FL_FREEZE, RString::shared, STR_BORROWED, STR_NOFREE, STR_SHARED, and STR_TMPLOCK.

Referenced by rb_str_format().

## ◆ rb_str_tmp_new()

VALUE rb_str_tmp_new | ( | long | len | ) |

Definition at line 1427 of file string.c.

References len.

Referenced by rb_find_file(), rb_find_file_ext(), and VpAlloc().

## ◆ rb_str_to_cstr()

char * rb_str_to_cstr | ( | VALUE | str | ) |

Definition at line 2432 of file string.c.

References str.

Referenced by rb_get_path_check_convert(), and rb_to_encoding_index().

## ◆ rb_str_to_interned_str()

VALUE rb_str_to_interned_str | ( | VALUE | str | ) |

Definition at line 11543 of file string.c.

References rb_fstring(), and str.

## ◆ rb_str_to_str()

VALUE rb_str_to_str | ( | VALUE | str | ) |

Definition at line 1471 of file string.c.

References rb_convert_type_with_id(), str, and T_STRING.

Referenced by rb_string_value().

## ◆ rb_str_unlocktmp()

VALUE rb_str_unlocktmp | ( | VALUE | str | ) |

Definition at line 2825 of file string.c.

References FL_TEST, FL_UNSET, rb_eRuntimeError, rb_raise(), str, and STR_TMPLOCK.

Referenced by rb_str_locktmp_ensure().

## ◆ rb_str_update()

void rb_str_update | ( | VALUE | str,
|  | long | beg,
|  | long | len,
|  | VALUE | val
| ) |  |

Definition at line 4865 of file string.c.

References assert, re_registers::beg, ENC_CODERANGE, ENC_CODERANGE_AND, ENC_CODERANGE_BROKEN, ENC_CODERANGE_SET, len, rb_eIndexError, rb_enc_associate(), rb_enc_check(), rb_raise(), RSTRING_PTR, str, and StringValue.

## ◆ rb_str_upto_each()

VALUE rb_str_upto_each | ( | VALUE | beg,
|  | VALUE | end,
|  | int | excl,
|  | int(*)(VALUE, VALUE) | each,
|  | VALUE | arg
| ) |  |

Definition at line 4483 of file string.c.

References re_registers::beg, CONST_ID, re_registers::end, FALSE, FIX2LONG, FIXNUM_P, idLE, INT2FIX, ISDIGIT, NIL_P, numberof, Qnil, rb_cString, rb_enc_check(), rb_enc_sprintf(), rb_enc_str_new(), rb_fstring_lit, rb_funcall(), rb_funcallv, rb_str_cmp(), rb_str_equal(), rb_str_format(), rb_str_to_inum(), rb_usascii_encoding(), RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by rb_str_include_range_p().

## ◆ rb_str_upto_endless_each()

VALUE rb_str_upto_endless_each | ( | VALUE | beg,
|  | int(*)(VALUE, VALUE) | each,
|  | VALUE | arg
| ) |  |

Definition at line 4565 of file string.c.

References re_registers::beg, CONST_ID, FALSE, FIX2LONG, FIXABLE, FIXNUM_P, INT2FIX, ISDIGIT, LONG2NUM, numberof, rb_cString, rb_enc_sprintf(), rb_fstring_lit, rb_funcallv, rb_str_format(), rb_str_to_inum(), rb_usascii_encoding(), RSTRING_LEN, RSTRING_PTR, and StringValue.

## ◆ rb_string_value()

VALUE rb_string_value | ( | volatile VALUE * | ptr | ) |

Definition at line 2323 of file string.c.

References ptr, rb_str_to_str(), and T_STRING.

Referenced by rb_string_value_cstr(), and rb_string_value_ptr().

## ◆ rb_string_value_cstr()

char * rb_string_value_cstr | ( | volatile VALUE * | ptr | ) |

Definition at line 2439 of file string.c.

References ptr, rb_eArgError, rb_raise(), rb_string_value(), and str.

Referenced by rb_fiddle_value_to_generic().

## ◆ rb_string_value_ptr()

char * rb_string_value_ptr | ( | volatile VALUE * | ptr | ) |

Definition at line 2334 of file string.c.

References ptr, rb_string_value(), RSTRING_PTR, and str.

## ◆ rb_sym_proc_call()

VALUE rb_sym_proc_call | ( | ID | mid,
|  | int | argc,
|  | const VALUE * | argv,
|  | int | kw_splat,
|  | VALUE | passed_proc
| ) |  |

Definition at line 11171 of file string.c.

References argc, argv, rb_eArgError, rb_funcall_with_block_kw(), and rb_raise().

## ◆ rb_sym_to_s()

VALUE rb_sym_to_s | ( | VALUE | sym | ) |

Definition at line 11148 of file string.c.

References rb_cString, rb_sym2str(), and sym.

Referenced by Init_String().

## ◆ rb_tainted_str_new()

VALUE rb_tainted_str_new | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 957 of file string.c.

References len, ptr, rb_str_new, and rb_warn_deprecated_to_remove().

## ◆ rb_tainted_str_new_cstr()

VALUE rb_tainted_str_new_cstr | ( | const char * | ptr | ) |

Definition at line 964 of file string.c.

References ptr, rb_str_new_cstr, and rb_warn_deprecated_to_remove().

## ◆ rb_to_id()

ID rb_to_id | ( | VALUE | name | ) |

Definition at line 11501 of file string.c.

References name, rb_intern_str, SYM2ID, and SYMBOL_P.

Referenced by rb_f_trace_var().

## ◆ rb_to_symbol()

VALUE rb_to_symbol | ( | VALUE | name | ) |

Definition at line 11511 of file string.c.

References name, rb_str_intern(), and SYMBOL_P.

Referenced by rb_fiddle_type_ensure().

## ◆ rb_usascii_str_new()

VALUE rb_usascii_str_new | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 841 of file string.c.

References ENC_CODERANGE_7BIT, ENCODING_CODERANGE_SET, len, ptr, rb_str_new, rb_usascii_encindex, and str.

## ◆ rb_usascii_str_new_cstr()

VALUE rb_usascii_str_new_cstr | ( | const char * | ptr | ) |

Definition at line 881 of file string.c.

References ENC_CODERANGE_7BIT, ENCODING_CODERANGE_SET, ptr, rb_str_new_cstr, rb_usascii_encindex, and str.

## ◆ rb_usascii_str_new_static()

VALUE rb_usascii_str_new_static | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 939 of file string.c.

References ENCINDEX_US_ASCII, len, ptr, and rb_cString.

## ◆ rb_utf8_str_new()

VALUE rb_utf8_str_new | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 849 of file string.c.

References len, ptr, rb_cString, rb_enc_associate_index(), rb_utf8_encindex, and str.

## ◆ rb_utf8_str_new_cstr()

VALUE rb_utf8_str_new_cstr | ( | const char * | ptr | ) |

Definition at line 889 of file string.c.

References ptr, rb_enc_associate_index(), rb_str_new_cstr, rb_utf8_encindex, and str.

## ◆ rb_utf8_str_new_static()

VALUE rb_utf8_str_new_static | ( | const char * | ptr,
|  | long | len
| ) |  |

Definition at line 945 of file string.c.

References ENCINDEX_UTF_8, len, ptr, and rb_cString.

## ◆ RUBY_ALIAS_FUNCTION() [1/2]

RUBY_ALIAS_FUNCTION | ( | rb_str_buf_cat(VALUE str, const char *ptr, long len) | ,
|  | rb_str_cat | ,
|  | (str, ptr, len) |
| ) |  |

Definition at line 2978 of file string.c.

References ENC_CODERANGE, ENC_CODERANGE_7BIT, ENC_CODERANGE_CLEAN_P, ENC_CODERANGE_UNKNOWN, ENC_CODERANGE_VALID, ENCODING_CODERANGE_SET, ENCODING_GET, ENCODING_IS_ASCII8BIT, len, ptr, Qundef, rb_eArgError, rb_eEncCompatError, rb_enc_asciicompat, rb_enc_from_index(), rb_enc_name, rb_enc_str_coderange(), rb_raise(), rb_str_buf_cat, RSTRING_LEN, str, and UNREACHABLE_RETURN.

## ◆ RUBY_ALIAS_FUNCTION() [2/2]

RUBY_ALIAS_FUNCTION | ( | rb_str_dup_frozen(VALUE str) | ,
|  | rb_str_new_frozen | ,
|  | (str) |
| ) |  |

Definition at line 2811 of file string.c.

References FL_SET, FL_TEST, rb_eRuntimeError, rb_raise(), str, and STR_TMPLOCK.

## ◆ ruby_escaped_char()

const char * ruby_escaped_char | ( | int | c | ) |

Definition at line 6117 of file string.c.

References NULL.

Referenced by rb_str_escape().

## ◆ STATIC_ASSERT()

STATIC_ASSERT | ( | STR_BUF_MIN_SIZE | ,
|  | STR_BUF_MIN_SIZE | ,
|  | RSTRING_EMBED_LEN_MAX |
| ) |  |

## Variable Documentation

## ◆ rb_cString

VALUE rb_cString

Definition at line 80 of file string.c.

Referenced by Init_Complex(), Init_Exception(), Init_Rational(), Init_String(), InitVM_transcode(), rb_ec_str_resurrect(), rb_enc_str_new(), rb_enc_str_new_static(), rb_enc_vsprintf(), rb_hash_aset(), rb_hash_key_str(), rb_str_buf_new(), rb_str_new(), rb_str_new_static(), rb_str_opt_plus(), rb_str_plus(), rb_str_resurrect(), rb_str_times(), rb_str_upto_each(), rb_str_upto_endless_each(), rb_sym_to_s(), rb_usascii_str_new_static(), rb_utf8_str_new(), and rb_utf8_str_new_static().

## ◆ rb_cSymbol

VALUE rb_cSymbol

Definition at line 81 of file string.c.

Referenced by Init_String(), and rb_str_intern().

## ◆ rb_fs

VALUE rb_fs

Definition at line 502 of file string.c.

Referenced by Init_String().

## ◆ rb_fstring_hash_type

const struct st_hash_type rb_fstring_hash_type

Initial value:
= {
fstring_cmp,
rb_str_hash,
}
rb_str_hash
st_index_t rb_str_hash(VALUE str)
Definition: string.c:3314

Definition at line 287 of file string.c.

Referenced by Init_vm_objects().