Ruby  2.1.10p492(2016-04-01revision54464)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
string.c File Reference
#include "ruby/ruby.h"
#include "ruby/re.h"
#include "ruby/encoding.h"
#include "vm_core.h"
#include "internal.h"
#include "probes.h"
#include <assert.h>
#include <math.h>
#include <ctype.h>

Go to the source code of this file.

Data Structures

struct  tr
 

Macros

#define BEG(no)   (regs->beg[(no)])
 
#define END(no)   (regs->end[(no)])
 
#define STRING_ENUMERATORS_WANTARRAY   0 /* next major */
 
#define RUBY_MAX_CHAR_LEN   16
 
#define STR_TMPLOCK   FL_USER7
 
#define STR_UNSET_NOCAPA(s)
 
#define STR_SET_NOEMBED(str)
 
#define STR_SET_EMBED(str)   FL_UNSET((str), STR_NOEMBED)
 
#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 STR_SET_SHARED(str, shared_str)
 
#define STR_HEAP_PTR(str)   (RSTRING(str)->as.heap.ptr)
 
#define STR_HEAP_SIZE(str)   (RSTRING(str)->as.heap.aux.capa + TERM_LEN(str))
 
#define STR_ENC_GET(str)   get_encoding(str)
 
#define STR_BUF_MIN_SIZE   128
 
#define str_make_independent(str)   str_make_independent_expand((str), 0L)
 
#define rb_str_dup_frozen   rb_str_new_frozen
 
#define str_buf_cat2(str, ptr)   str_buf_cat((str), (ptr), strlen(ptr))
 
#define lesser(a, b)   (((a)>(b))?(b):(a))
 
#define CHAR_ESC_LEN   13 /* sizeof(\x{ hex of 32bit unsigned int } \0) */
 
#define IS_EVSTR(p, e)   ((p) < (e) && (*(p) == '$' || *(p) == '@' || *(p) == '{'))
 
#define CHECK_IF_ASCII(c)
 
#define TR_TABLE_SIZE   257
 
#define ascii_isspace(c)   isspacetable[(unsigned char)(c)]
 
#define DEFAULT_REPLACE_CHAR(str)
 
#define rb_intern(str)   rb_intern_const(str)
 

Typedefs

typedef unsigned char * USTR
 

Enumerations

enum  neighbor_char { NEIGHBOR_NOT_CHAR, NEIGHBOR_FOUND, NEIGHBOR_WRAPPED }
 

Functions

static VALUE rb_str_clear (VALUE str)
 
rb_encodingrb_enc_get_from_index (int index)
 
static rb_encodingget_actual_encoding (const int encidx, VALUE str)
 
static rb_encodingget_encoding (VALUE str)
 
static int fstring_cmp (VALUE a, VALUE b)
 
static int fstr_update_callback (st_data_t *key, st_data_t *value, st_data_t arg, int existing)
 
VALUE rb_fstring (VALUE str)
 
static int fstring_set_class_i (st_data_t key, st_data_t val, st_data_t arg)
 
static int single_byte_optimizable (VALUE str)
 
static const char * search_nonascii (const char *p, const char *e)
 
static int coderange_scan (const char *p, long len, rb_encoding *enc)
 
long rb_str_coderange_scan_restartable (const char *s, const char *e, rb_encoding *enc, int *cr)
 
static void str_enc_copy (VALUE str1, VALUE str2)
 
static void rb_enc_cr_str_copy_for_substr (VALUE dest, VALUE src)
 
static void rb_enc_cr_str_exact_copy (VALUE dest, VALUE src)
 
int rb_enc_str_coderange (VALUE str)
 
int rb_enc_str_asciionly_p (VALUE str)
 
static void str_mod_check (VALUE s, const char *p, long len)
 
size_t rb_str_capacity (VALUE str)
 
static VALUE str_alloc (VALUE klass)
 
static VALUE empty_str_alloc (VALUE klass)
 
static VALUE str_new0 (VALUE klass, const char *ptr, long len, int termlen)
 
static VALUE str_new (VALUE klass, const char *ptr, long len)
 
VALUE rb_str_new (const char *ptr, long len)
 
VALUE rb_usascii_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_enc_str_new_cstr (const char *ptr, 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_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)
 
static VALUE str_replace_shared_without_enc (VALUE str2, VALUE str)
 
static VALUE str_replace_shared (VALUE str2, VALUE str)
 
static VALUE str_new_shared (VALUE klass, VALUE str)
 
static VALUE str_new3 (VALUE klass, VALUE str)
 
VALUE rb_str_new_shared (VALUE str)
 
static VALUE str_new4 (VALUE klass, VALUE str)
 
VALUE rb_str_new_frozen (VALUE orig)
 
VALUE rb_str_new_with_class (VALUE obj, const char *ptr, long len)
 
static VALUE str_new_empty (VALUE str)
 
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_alloc_tmp_buffer (volatile VALUE *store, long len)
 
void rb_free_tmp_buffer (volatile VALUE *store)
 
void rb_str_free (VALUE str)
 
RUBY_FUNC_EXPORTED size_t rb_str_memsize (VALUE str)
 
VALUE rb_str_to_str (VALUE str)
 
static void str_discard (VALUE str)
 
void rb_str_shared_replace (VALUE str, VALUE str2)
 
VALUE rb_obj_as_string (VALUE obj)
 
static VALUE str_replace (VALUE str, VALUE str2)
 
static VALUE str_duplicate (VALUE klass, VALUE str)
 
VALUE rb_str_dup (VALUE str)
 
VALUE rb_str_resurrect (VALUE str)
 
static VALUE rb_str_init (int argc, VALUE *argv, VALUE str)
 
static long enc_strlen (const char *p, const char *e, rb_encoding *enc, int cr)
 
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)
 
static long str_strlen (VALUE str, rb_encoding *enc)
 
long rb_str_strlen (VALUE str)
 
VALUE rb_str_length (VALUE str)
 
static VALUE rb_str_bytesize (VALUE str)
 
static VALUE rb_str_empty (VALUE str)
 
VALUE rb_str_plus (VALUE str1, VALUE str2)
 
VALUE rb_str_times (VALUE str, VALUE times)
 
static VALUE rb_str_format_m (VALUE str, VALUE arg)
 
static void str_modifiable (VALUE str)
 
static int str_independent (VALUE str)
 
static void str_make_independent_expand (VALUE str, long expand)
 
void rb_str_modify (VALUE str)
 
void rb_str_modify_expand (VALUE str, long expand)
 
static void str_modify_keep_cr (VALUE str)
 
void rb_str_associate (VALUE str, VALUE add)
 
VALUE rb_str_associated (VALUE str)
 
void rb_must_asciicompat (VALUE str)
 
VALUE rb_string_value (volatile VALUE *ptr)
 
char * rb_string_value_ptr (volatile VALUE *ptr)
 
static int zero_filled (const char *s, int n)
 
static const char * str_null_char (const char *s, long len, const int minlen, rb_encoding *enc)
 
static char * str_fill_term (VALUE str, char *s, long len, int oldtermlen, int termlen)
 
char * rb_string_value_cstr (volatile VALUE *ptr)
 
void rb_str_fill_terminator (VALUE str, const int newminlen)
 
VALUE rb_check_string_type (VALUE str)
 
static VALUE rb_str_s_try_convert (VALUE dummy, VALUE str)
 
static char * str_nth_len (const char *p, const char *e, long *nthp, rb_encoding *enc)
 
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 long str_offset (const char *p, const char *e, long nth, rb_encoding *enc, int singlebyte)
 
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)
 
static VALUE str_buf_cat (VALUE str, const char *ptr, long len)
 
VALUE rb_str_buf_cat (VALUE str, const char *ptr, long len)
 
VALUE rb_str_buf_cat2 (VALUE str, const char *ptr)
 
VALUE rb_str_cat (VALUE str, const char *ptr, long len)
 
VALUE rb_str_cat2 (VALUE str, const char *ptr)
 
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)
 
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 (VALUE str1, VALUE str2)
 
static VALUE rb_str_prepend (VALUE str, VALUE str2)
 
st_index_t rb_str_hash (VALUE str)
 
int rb_str_hash_cmp (VALUE str1, VALUE str2)
 
static VALUE rb_str_hash_m (VALUE str)
 
int rb_str_comparable (VALUE str1, VALUE str2)
 
int rb_str_cmp (VALUE str1, VALUE str2)
 
static VALUE str_eql (const VALUE str1, const VALUE str2)
 
VALUE rb_str_equal (VALUE str1, VALUE str2)
 
static VALUE rb_str_eql (VALUE str1, VALUE str2)
 
static VALUE rb_str_cmp_m (VALUE str1, VALUE str2)
 
static VALUE rb_str_casecmp (VALUE str1, VALUE str2)
 
static long rb_str_index (VALUE str, VALUE sub, long offset)
 
static VALUE rb_str_index_m (int argc, VALUE *argv, VALUE str)
 
static long str_rindex (VALUE str, VALUE sub, const char *s, long pos, rb_encoding *enc)
 
static long rb_str_rindex (VALUE str, VALUE sub, long pos)
 
static VALUE rb_str_rindex_m (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_match (VALUE x, VALUE y)
 
static VALUE get_pat (VALUE, int)
 
static VALUE rb_str_match_m (int argc, VALUE *argv, VALUE str)
 
static enum neighbor_char enc_succ_char (char *p, long len, rb_encoding *enc)
 
static enum neighbor_char enc_pred_char (char *p, long len, rb_encoding *enc)
 
static enum neighbor_char enc_succ_alnum_char (char *p, long len, rb_encoding *enc, char *carry)
 
VALUE rb_str_succ (VALUE orig)
 
static VALUE rb_str_succ_bang (VALUE str)
 
static VALUE rb_str_upto (int argc, VALUE *argv, VALUE beg)
 
static VALUE rb_str_subpat (VALUE str, VALUE re, VALUE backref)
 
static VALUE rb_str_aref (VALUE str, VALUE indx)
 
static VALUE rb_str_aref_m (int argc, VALUE *argv, VALUE str)
 
VALUE rb_str_drop_bytes (VALUE str, long len)
 
static void rb_str_splice_0 (VALUE str, long beg, long len, VALUE val)
 
static void rb_str_splice (VALUE str, long beg, long len, VALUE val)
 
void rb_str_update (VALUE str, long beg, long len, VALUE val)
 
static void rb_str_subpat_set (VALUE str, VALUE re, VALUE backref, VALUE val)
 
static VALUE rb_str_aset (VALUE str, VALUE indx, VALUE val)
 
static VALUE rb_str_aset_m (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_insert (VALUE str, VALUE idx, VALUE str2)
 
static VALUE rb_str_slice_bang (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_sub_bang (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_sub (int argc, VALUE *argv, VALUE str)
 
static VALUE str_gsub (int argc, VALUE *argv, VALUE str, int bang)
 
static VALUE rb_str_gsub_bang (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_gsub (int argc, VALUE *argv, VALUE str)
 
VALUE rb_str_replace (VALUE str, VALUE str2)
 
static VALUE rb_str_chr (VALUE str)
 
static VALUE rb_str_getbyte (VALUE str, VALUE index)
 
static VALUE rb_str_setbyte (VALUE str, VALUE index, VALUE value)
 
static VALUE str_byte_substr (VALUE str, long beg, long len)
 
static VALUE str_byte_aref (VALUE str, VALUE indx)
 
static VALUE rb_str_byteslice (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_reverse (VALUE str)
 
static VALUE rb_str_reverse_bang (VALUE str)
 
static VALUE rb_str_include (VALUE str, VALUE arg)
 
static VALUE rb_str_to_i (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_to_f (VALUE str)
 
static VALUE rb_str_to_s (VALUE str)
 
int rb_str_buf_cat_escaped_char (VALUE result, unsigned int c, int unicode_p)
 
VALUE rb_str_inspect (VALUE str)
 
VALUE rb_str_dump (VALUE str)
 
static void rb_str_check_dummy_enc (rb_encoding *enc)
 
static VALUE rb_str_upcase_bang (VALUE str)
 
static VALUE rb_str_upcase (VALUE str)
 
static VALUE rb_str_downcase_bang (VALUE str)
 
static VALUE rb_str_downcase (VALUE str)
 
static VALUE rb_str_capitalize_bang (VALUE str)
 
static VALUE rb_str_capitalize (VALUE str)
 
static VALUE rb_str_swapcase_bang (VALUE str)
 
static VALUE rb_str_swapcase (VALUE str)
 
static unsigned int trnext (struct tr *t, rb_encoding *enc)
 
static VALUE rb_str_delete_bang (int, VALUE *, VALUE)
 
static VALUE tr_trans (VALUE str, VALUE src, VALUE repl, int sflag)
 
static VALUE rb_str_tr_bang (VALUE str, VALUE src, VALUE repl)
 
static VALUE rb_str_tr (VALUE str, VALUE src, VALUE repl)
 
static void tr_setup_table (VALUE str, char stable[TR_TABLE_SIZE], int first, VALUE *tablep, VALUE *ctablep, rb_encoding *enc)
 
static int tr_find (unsigned int c, const char table[TR_TABLE_SIZE], VALUE del, VALUE nodel)
 
static VALUE rb_str_delete (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_squeeze_bang (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_squeeze (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_tr_s_bang (VALUE str, VALUE src, VALUE repl)
 
static VALUE rb_str_tr_s (VALUE str, VALUE src, VALUE repl)
 
static VALUE rb_str_count (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_split_m (int argc, VALUE *argv, VALUE str)
 
VALUE rb_str_split (VALUE str, const char *sep0)
 
static VALUE rb_str_enumerate_lines (int argc, VALUE *argv, VALUE str, int wantarray)
 
static VALUE rb_str_each_line (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_lines (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_each_byte_size (VALUE str, VALUE args, VALUE eobj)
 
static VALUE rb_str_enumerate_bytes (VALUE str, int wantarray)
 
static VALUE rb_str_each_byte (VALUE str)
 
static VALUE rb_str_bytes (VALUE str)
 
static VALUE rb_str_each_char_size (VALUE str, VALUE args, VALUE eobj)
 
static VALUE rb_str_enumerate_chars (VALUE str, int wantarray)
 
static VALUE rb_str_each_char (VALUE str)
 
static VALUE rb_str_chars (VALUE str)
 
static VALUE rb_str_enumerate_codepoints (VALUE str, int wantarray)
 
static VALUE rb_str_each_codepoint (VALUE str)
 
static VALUE rb_str_codepoints (VALUE str)
 
static long chopped_length (VALUE str)
 
static VALUE rb_str_chop_bang (VALUE str)
 
static VALUE rb_str_chop (VALUE str)
 
static VALUE rb_str_chomp_bang (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_chomp (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_lstrip_bang (VALUE str)
 
static VALUE rb_str_lstrip (VALUE str)
 
static VALUE rb_str_rstrip_bang (VALUE str)
 
static VALUE rb_str_rstrip (VALUE str)
 
static VALUE rb_str_strip_bang (VALUE str)
 
static VALUE rb_str_strip (VALUE str)
 
static VALUE scan_once (VALUE str, VALUE pat, long *start)
 
static VALUE rb_str_scan (VALUE str, VALUE pat)
 
static VALUE rb_str_hex (VALUE str)
 
static VALUE rb_str_oct (VALUE str)
 
static VALUE rb_str_crypt (VALUE str, VALUE salt)
 
VALUE rb_str_intern (VALUE s)
 
VALUE rb_str_ord (VALUE s)
 
static VALUE rb_str_sum (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_justify (int argc, VALUE *argv, VALUE str, char jflag)
 
static VALUE rb_str_ljust (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_rjust (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_center (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_partition (VALUE str, VALUE sep)
 
static VALUE rb_str_rpartition (VALUE str, VALUE sep)
 
static VALUE rb_str_start_with (int argc, VALUE *argv, VALUE str)
 
static VALUE rb_str_end_with (int argc, VALUE *argv, VALUE str)
 
void rb_str_setter (VALUE val, ID id, VALUE *var)
 
static VALUE rb_str_force_encoding (VALUE str, VALUE enc)
 
static VALUE rb_str_b (VALUE str)
 
static VALUE rb_str_valid_encoding_p (VALUE str)
 
static VALUE rb_str_is_ascii_only_p (VALUE str)
 
VALUE rb_str_ellipsize (VALUE str, long len)
 Shortens str and adds three dots, an ellipsis, if it is longer than len characters. More...
 
static VALUE str_compat_and_valid (VALUE str, rb_encoding *enc)
 
VALUE rb_str_scrub (VALUE str, VALUE repl)
 
static VALUE str_scrub (int argc, VALUE *argv, VALUE str)
 
static VALUE str_scrub_bang (int argc, VALUE *argv, VALUE str)
 
static VALUE sym_equal (VALUE sym1, VALUE sym2)
 
static int sym_printable (const char *s, const char *send, rb_encoding *enc)
 
int rb_str_symname_p (VALUE sym)
 
VALUE rb_str_quote_unprintable (VALUE str)
 
VALUE rb_id_quote_unprintable (ID id)
 
static VALUE sym_inspect (VALUE sym)
 
VALUE rb_sym_to_s (VALUE sym)
 
static VALUE sym_to_sym (VALUE sym)
 
static VALUE sym_call (VALUE args, VALUE sym, int argc, VALUE *argv, VALUE passed_proc)
 
static VALUE sym_to_proc (VALUE sym)
 
static VALUE sym_succ (VALUE sym)
 
static VALUE sym_cmp (VALUE sym, VALUE other)
 
static VALUE sym_casecmp (VALUE sym, VALUE other)
 
static VALUE sym_match (VALUE sym, VALUE other)
 
static VALUE sym_aref (int argc, VALUE *argv, VALUE sym)
 
static VALUE sym_length (VALUE sym)
 
static VALUE sym_empty (VALUE sym)
 
static VALUE sym_upcase (VALUE sym)
 
static VALUE sym_downcase (VALUE sym)
 
static VALUE sym_capitalize (VALUE sym)
 
static VALUE sym_swapcase (VALUE sym)
 
static VALUE sym_encoding (VALUE sym)
 
ID rb_to_id (VALUE name)
 
void Init_String (void)
 

Variables

VALUE rb_cString
 
VALUE rb_cSymbol
 
static st_tablefrozen_strings
 
static const struct st_hash_type fstring_hash_type
 
VALUE rb_fs
 
static ID id_to_s
 
static const char isspacetable [256]
 

Macro Definition Documentation

◆ ascii_isspace

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

Definition at line 6149 of file string.c.

Referenced by rb_str_rstrip_bang(), and rb_str_split_m().

◆ BEG

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

Definition at line 22 of file string.c.

Referenced by rb_str_split_m(), rb_str_sub_bang(), rb_str_subpat_set(), scan_once(), and str_gsub().

◆ CHAR_ESC_LEN

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

Definition at line 4747 of file string.c.

Referenced by rb_str_buf_cat_escaped_char(), and rb_str_inspect().

◆ CHECK_IF_ASCII

#define CHECK_IF_ASCII (   c)
Value:
(void)((cr == ENC_CODERANGE_7BIT && !rb_isascii(c)) ? \
(cr = ENC_CODERANGE_VALID) : 0)
#define ENC_CODERANGE_7BIT
Definition: encoding.h:49
#define ENC_CODERANGE_VALID
Definition: encoding.h:50
#define rb_isascii(c)
Definition: ruby.h:1757

Referenced by tr_trans().

◆ 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)

Referenced by rb_str_scrub().

◆ END

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

Definition at line 23 of file string.c.

Referenced by rb_str_split_m(), rb_str_sub_bang(), rb_str_subpat_set(), scan_once(), and str_gsub().

◆ IS_EVSTR

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

Definition at line 4889 of file string.c.

Referenced by rb_str_dump().

◆ lesser

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

Definition at line 2457 of file string.c.

Referenced by rb_str_cmp().

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

◆ rb_str_dup_frozen

#define rb_str_dup_frozen   rb_str_new_frozen

◆ RESIZE_CAPA

#define RESIZE_CAPA (   str,
  capacity 
)
Value:
do {\
const int termlen = TERM_LEN(str);\
if (STR_EMBED_P(str)) {\
if ((capacity) > RSTRING_EMBED_LEN_MAX) {\
char *const tmp = ALLOC_N(char, (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 {\
REALLOC_N(RSTRING(str)->as.heap.ptr, char, (capacity)+termlen);\
if (!STR_NOCAPA_P(str))\
RSTRING(str)->as.heap.aux.capa = (capacity);\
}\
} while (0)
#define RSTRING(obj)
Definition: ruby.h:1121
#define ALLOC_N(type, n)
Definition: ruby.h:1341
#define TERM_LEN(str)
Definition: string.c:87
#define RSTRING_LEN(str)
Definition: ruby.h:841
#define RSTRING_EMBED_LEN_MAX
Definition: ruby.h:819
#define RSTRING_PTR(str)
Definition: ruby.h:845
#define STR_NOCAPA_P(s)
Definition: internal.h:730
#define STR_EMBED_P(str)
Definition: internal.h:731

Definition at line 96 of file string.c.

Referenced by rb_str_associate(), rb_str_splice_0(), rb_str_sub_bang(), rb_str_succ(), and str_buf_cat().

◆ RUBY_MAX_CHAR_LEN

#define RUBY_MAX_CHAR_LEN   16

Definition at line 50 of file string.c.

◆ str_buf_cat2

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

Definition at line 2120 of file string.c.

Referenced by rb_str_inspect().

◆ STR_BUF_MIN_SIZE

#define STR_BUF_MIN_SIZE   128

Definition at line 888 of file string.c.

Referenced by rb_str_buf_new().

◆ 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)
#define RSTRING_LEN(str)
Definition: ruby.h:841
#define STR_EMBED_P(str)
Definition: internal.h:731

Definition at line 76 of file string.c.

Referenced by rb_str_chomp_bang().

◆ STR_ENC_GET

#define STR_ENC_GET (   str)    get_encoding(str)

◆ STR_HEAP_PTR

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

Definition at line 121 of file string.c.

Referenced by rb_str_free(), rb_str_resize(), str_discard(), and tr_trans().

◆ STR_HEAP_SIZE

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

Definition at line 122 of file string.c.

Referenced by rb_str_free(), rb_str_memsize(), str_discard(), and tr_trans().

◆ str_make_independent

#define str_make_independent (   str)    str_make_independent_expand((str), 0L)

Definition at line 1480 of file string.c.

Referenced by rb_str_associate(), rb_str_modify(), str_fill_term(), and str_modify_keep_cr().

◆ STR_SET_EMBED

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

◆ STR_SET_EMBED_LEN

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

Definition at line 61 of file string.c.

Referenced by rb_str_clear(), rb_str_drop_bytes(), rb_str_resize(), rb_str_shared_replace(), and str_replace_shared_without_enc().

◆ STR_SET_LEN

#define STR_SET_LEN (   str,
 
)
Value:
do { \
if (STR_EMBED_P(str)) {\
STR_SET_EMBED_LEN((str), (n));\
}\
else {\
RSTRING(str)->as.heap.len = (n);\
}\
} while (0)
#define STR_EMBED_P(str)
Definition: internal.h:731

Definition at line 67 of file string.c.

Referenced by rb_str_chomp_bang(), rb_str_chop_bang(), rb_str_delete_bang(), rb_str_justify(), rb_str_lstrip_bang(), rb_str_reverse(), rb_str_rstrip_bang(), rb_str_set_len(), rb_str_splice_0(), rb_str_squeeze_bang(), rb_str_sub_bang(), rb_str_succ(), str_buf_cat(), and str_new0().

◆ STR_SET_NOEMBED

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

Definition at line 56 of file string.c.

Referenced by rb_str_resize(), rb_str_shared_replace(), str_make_independent_expand(), str_new0(), str_new4(), str_replace(), and tr_trans().

◆ STR_SET_SHARED

#define STR_SET_SHARED (   str,
  shared_str 
)
Value:
do { \
RB_OBJ_WRITE((str), &RSTRING(str)->as.heap.aux.shared, (shared_str)); \
FL_SET((str), ELTS_SHARED); \
} while (0)
#define ELTS_SHARED
Definition: ruby.h:817
#define RSTRING(obj)
Definition: ruby.h:1121

Definition at line 116 of file string.c.

Referenced by str_new4(), str_replace(), and str_replace_shared_without_enc().

◆ STR_TMPLOCK

#define STR_TMPLOCK   FL_USER7

Definition at line 51 of file string.c.

Referenced by rb_str_unlocktmp(), RUBY_ALIAS_FUNCTION(), and str_modifiable().

◆ STR_UNSET_NOCAPA

#define STR_UNSET_NOCAPA (   s)
Value:
do {\
} while (0)
#define ELTS_SHARED
Definition: ruby.h:817
#define FL_TEST(x, f)
Definition: ruby.h:1169
#define FL_UNSET(x, f)
Definition: ruby.h:1177
#define STR_ASSOC
#define STR_NOEMBED
Definition: internal.h:724

Definition at line 52 of file string.c.

Referenced by rb_str_modify_expand(), rb_str_shared_replace(), and str_make_independent_expand().

◆ STRING_ENUMERATORS_WANTARRAY

#define STRING_ENUMERATORS_WANTARRAY   0 /* next major */

Definition at line 32 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)
#define UNLIKELY(x)
Definition: vm_core.h:109

Definition at line 88 of file string.c.

Referenced by rb_str_append(), rb_str_cat(), rb_str_resize(), rb_str_set_len(), str_fill_term(), str_make_independent_expand(), and str_new0().

◆ TERM_LEN

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

◆ TR_TABLE_SIZE

#define TR_TABLE_SIZE   257

Definition at line 5709 of file string.c.

Referenced by rb_str_count(), rb_str_delete_bang(), and rb_str_squeeze_bang().

Typedef Documentation

◆ USTR

typedef unsigned char* USTR

Definition at line 5341 of file string.c.

Enumeration Type Documentation

◆ neighbor_char

Enumerator
NEIGHBOR_NOT_CHAR 
NEIGHBOR_FOUND 
NEIGHBOR_WRAPPED 

Definition at line 3053 of file string.c.

Function Documentation

◆ chopped_length()

static long chopped_length ( VALUE  str)
static

Definition at line 6874 of file string.c.

References rb_enc_ascget(), rb_enc_prev_char, RSTRING_LEN, RSTRING_PTR, and STR_ENC_GET.

Referenced by rb_str_chop(), and rb_str_chop_bang().

◆ coderange_scan()

static int coderange_scan ( const char *  p,
long  len,
rb_encoding enc 
)
static

◆ empty_str_alloc()

static VALUE empty_str_alloc ( VALUE  klass)
inlinestatic

◆ enc_pred_char()

static enum neighbor_char enc_pred_char ( char *  p,
long  len,
rb_encoding enc 
)
static

◆ enc_strlen()

static long enc_strlen ( const char *  p,
const char *  e,
rb_encoding enc,
int  cr 
)
inlinestatic

◆ enc_succ_alnum_char()

static enum neighbor_char enc_succ_alnum_char ( char *  p,
long  len,
rb_encoding enc,
char *  carry 
)
static

◆ enc_succ_char()

static enum neighbor_char enc_succ_char ( char *  p,
long  len,
rb_encoding enc 
)
static

◆ fstr_update_callback()

static int fstr_update_callback ( st_data_t key,
st_data_t value,
st_data_t  arg,
int  existing 
)
static

◆ fstring_cmp()

static int fstring_cmp ( VALUE  a,
VALUE  b 
)
static

Definition at line 224 of file string.c.

References cmp, ENCODING_GET, and rb_str_hash_cmp().

◆ fstring_set_class_i()

static int fstring_set_class_i ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
)
static

Definition at line 217 of file string.c.

References key, RBASIC_SET_CLASS, and ST_CONTINUE.

Referenced by Init_String().

◆ get_actual_encoding()

static rb_encoding* get_actual_encoding ( const int  encidx,
VALUE  str 
)
static

◆ get_encoding()

static rb_encoding* get_encoding ( VALUE  str)
static

Definition at line 159 of file string.c.

References ENCODING_GET, and get_actual_encoding().

◆ get_pat()

static VALUE get_pat ( VALUE  pat,
int  quote 
)
static

◆ Init_String()

void Init_String ( void  )

Definition at line 8766 of file string.c.

References CLASS_OF, empty_str_alloc(), frozen_strings, fstring_set_class_i(), id_to_s, Qnil, rb_cObject, rb_cString, rb_cSymbol, rb_define_alloc_func(), rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_define_variable(), rb_fs, rb_include_module(), rb_intern, rb_mComparable, rb_obj_encoding(), rb_obj_freeze(), rb_str_aref_m(), rb_str_aset_m(), rb_str_b(), rb_str_bytes(), rb_str_bytesize(), rb_str_byteslice(), rb_str_capitalize(), rb_str_capitalize_bang(), rb_str_casecmp(), rb_str_center(), rb_str_chars(), rb_str_chomp(), rb_str_chomp_bang(), rb_str_chop(), rb_str_chop_bang(), rb_str_chr(), rb_str_clear(), rb_str_cmp_m(), rb_str_codepoints(), rb_str_concat(), rb_str_count(), rb_str_crypt(), rb_str_delete(), rb_str_delete_bang(), rb_str_downcase(), rb_str_downcase_bang(), rb_str_dump(), rb_str_each_byte(), rb_str_each_char(), rb_str_each_codepoint(), rb_str_each_line(), rb_str_empty(), rb_str_end_with(), rb_str_eql(), rb_str_equal(), rb_str_force_encoding(), rb_str_format_m(), rb_str_getbyte(), rb_str_gsub(), rb_str_gsub_bang(), rb_str_hash_m(), rb_str_hex(), rb_str_include(), rb_str_index_m(), rb_str_init(), rb_str_insert(), rb_str_inspect(), rb_str_intern(), rb_str_is_ascii_only_p(), rb_str_length(), rb_str_lines(), rb_str_ljust(), rb_str_lstrip(), rb_str_lstrip_bang(), rb_str_match(), rb_str_match_m(), rb_str_oct(), rb_str_ord(), rb_str_partition(), rb_str_plus(), rb_str_prepend(), rb_str_replace(), rb_str_reverse(), rb_str_reverse_bang(), rb_str_rindex_m(), rb_str_rjust(), rb_str_rpartition(), rb_str_rstrip(), rb_str_rstrip_bang(), rb_str_s_try_convert(), rb_str_scan(), rb_str_setbyte(), rb_str_slice_bang(), rb_str_split_m(), rb_str_squeeze(), rb_str_squeeze_bang(), rb_str_start_with(), rb_str_strip(), rb_str_strip_bang(), rb_str_sub(), rb_str_sub_bang(), rb_str_succ(), rb_str_succ_bang(), rb_str_sum(), rb_str_swapcase(), rb_str_swapcase_bang(), rb_str_times(), rb_str_to_f(), rb_str_to_i(), rb_str_to_s(), rb_str_tr(), rb_str_tr_bang(), rb_str_tr_s(), rb_str_tr_s_bang(), rb_str_upcase(), rb_str_upcase_bang(), rb_str_upto(), rb_str_valid_encoding_p(), rb_sym_all_symbols(), rb_sym_to_s(), rb_undef_alloc_func(), rb_undef_method(), st_foreach(), str_scrub(), str_scrub_bang(), sym_aref(), sym_capitalize(), sym_casecmp(), sym_cmp(), sym_downcase(), sym_empty(), sym_encoding(), sym_equal(), sym_inspect(), sym_length(), sym_match(), sym_succ(), sym_swapcase(), sym_to_proc(), sym_to_sym(), and sym_upcase().

◆ rb_alloc_tmp_buffer()

void* rb_alloc_tmp_buffer ( volatile VALUE store,
long  len 
)

Definition at line 925 of file string.c.

References rb_str_tmp_new(), and RSTRING_PTR.

◆ rb_check_string_type()

VALUE rb_check_string_type ( VALUE  str)

◆ rb_enc_cr_str_buf_cat()

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 
)
static

◆ rb_enc_cr_str_copy_for_substr()

static void rb_enc_cr_str_copy_for_substr ( VALUE  dest,
VALUE  src 
)
static

◆ rb_enc_cr_str_exact_copy()

static void rb_enc_cr_str_exact_copy ( VALUE  dest,
VALUE  src 
)
static

Definition at line 428 of file string.c.

References ENC_CODERANGE, ENC_CODERANGE_SET, and str_enc_copy().

Referenced by rb_str_new_frozen(), str_new4(), str_replace(), and str_replace_shared().

◆ rb_enc_get_from_index()

rb_encoding* rb_enc_get_from_index ( int  index)

Definition at line 602 of file encoding.c.

References must_encindex().

Referenced by get_actual_encoding().

◆ rb_enc_nth()

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

Definition at line 1752 of file string.c.

References str_nth_len().

Referenced by rb_str_ellipsize(), and rb_str_format().

◆ rb_enc_str_asciionly_p()

int rb_enc_str_asciionly_p ( VALUE  str)

◆ 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 2250 of file string.c.

References ENC_CODERANGE_UNKNOWN, NULL, rb_enc_cr_str_buf_cat(), and rb_enc_to_index.

Referenced by rb_reg_regsub(), str_gsub(), and strio_write().

◆ rb_enc_str_coderange()

int rb_enc_str_coderange ( VALUE  str)

◆ rb_enc_str_new()

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

◆ rb_enc_str_new_cstr()

VALUE rb_enc_str_new_cstr ( const char *  ptr,
rb_encoding enc 
)

Definition at line 577 of file string.c.

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

◆ rb_enc_strlen()

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

Definition at line 1141 of file string.c.

References ENC_CODERANGE_UNKNOWN, and enc_strlen().

Referenced by rb_str_format(), and update_char_offset().

◆ rb_enc_strlen_cr()

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

◆ rb_external_str_new()

VALUE rb_external_str_new ( const char *  ptr,
long  len 
)

◆ rb_external_str_new_cstr()

VALUE rb_external_str_new_cstr ( const char *  ptr)

Definition at line 713 of file string.c.

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

Referenced by ruby_set_argv().

◆ rb_external_str_new_with_enc()

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

◆ rb_external_str_with_enc()

VALUE rb_external_str_with_enc ( VALUE  str,
rb_encoding eenc 
)

◆ rb_filesystem_str_new()

VALUE rb_filesystem_str_new ( const char *  ptr,
long  len 
)

Definition at line 731 of file string.c.

References rb_external_str_new_with_enc(), and rb_filesystem_encoding().

◆ rb_filesystem_str_new_cstr()

VALUE rb_filesystem_str_new_cstr ( const char *  ptr)

◆ rb_free_tmp_buffer()

void rb_free_tmp_buffer ( volatile VALUE store)

Definition at line 933 of file string.c.

References rb_str_clear().

◆ rb_fstring()

VALUE rb_fstring ( VALUE  str)

◆ rb_id_quote_unprintable()

VALUE rb_id_quote_unprintable ( ID  id)

Definition at line 8424 of file string.c.

References rb_id2str(), and rb_str_quote_unprintable().

◆ rb_locale_str_new()

VALUE rb_locale_str_new ( const char *  ptr,
long  len 
)

Definition at line 719 of file string.c.

References rb_external_str_new_with_enc(), and rb_locale_encoding().

Referenced by env_str_new().

◆ rb_locale_str_new_cstr()

VALUE rb_locale_str_new_cstr ( const char *  ptr)

◆ rb_must_asciicompat()

void rb_must_asciicompat ( VALUE  str)

◆ rb_obj_as_string()

VALUE rb_obj_as_string ( VALUE  obj)

◆ rb_str_append()

VALUE rb_str_append ( VALUE  str,
VALUE  str2 
)

◆ rb_str_aref()

static VALUE rb_str_aref ( VALUE  str,
VALUE  indx 
)
static

◆ rb_str_aref_m()

static VALUE rb_str_aref_m ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_aset()

static VALUE rb_str_aset ( VALUE  str,
VALUE  indx,
VALUE  val 
)
static

◆ rb_str_aset_m()

static VALUE rb_str_aset_m ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_associate()

void rb_str_associate ( VALUE  str,
VALUE  add 
)

◆ rb_str_associated()

VALUE rb_str_associated ( VALUE  str)

Definition at line 1569 of file string.c.

References Qfalse, RSTRING, STR_ASSOC_P, and STR_SHARED_P.

Referenced by pack_unpack().

◆ rb_str_b()

static VALUE rb_str_b ( VALUE  str)
static

◆ rb_str_buf_append()

VALUE rb_str_buf_append ( VALUE  str,
VALUE  str2 
)

◆ rb_str_buf_cat()

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

◆ rb_str_buf_cat2()

VALUE rb_str_buf_cat2 ( VALUE  str,
const char *  ptr 
)

◆ rb_str_buf_cat_ascii()

VALUE rb_str_buf_cat_ascii ( VALUE  str,
const char *  ptr 
)

◆ rb_str_buf_cat_escaped_char()

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

Definition at line 4750 of file string.c.

References buf, CHAR_ESC_LEN, ISPRINT, rb_str_buf_cat(), result, snprintf, and strlen().

Referenced by rb_reg_expr_str(), and rb_str_inspect().

◆ rb_str_buf_new()

VALUE rb_str_buf_new ( long  capa)

◆ rb_str_buf_new_cstr()

VALUE rb_str_buf_new_cstr ( const char *  ptr)

Definition at line 907 of file string.c.

References rb_str_buf_cat(), rb_str_buf_new(), and strlen().

Referenced by rb_load_fail().

◆ rb_str_bytes()

static VALUE rb_str_bytes ( VALUE  str)
static

Definition at line 6667 of file string.c.

References rb_str_enumerate_bytes().

Referenced by Init_String().

◆ rb_str_bytesize()

static VALUE rb_str_bytesize ( VALUE  str)
static

Definition at line 1317 of file string.c.

References LONG2NUM, and RSTRING_LEN.

Referenced by Init_String().

◆ rb_str_byteslice()

static VALUE rb_str_byteslice ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 4528 of file string.c.

References argc, argv, NUM2LONG, rb_check_arity, str_byte_aref(), and str_byte_substr().

Referenced by Init_String().

◆ rb_str_capacity()

size_t rb_str_capacity ( VALUE  str)

◆ rb_str_capitalize()

static VALUE rb_str_capitalize ( VALUE  str)
static

Definition at line 5271 of file string.c.

References rb_str_capitalize_bang(), and rb_str_dup().

Referenced by Init_String(), and sym_capitalize().

◆ rb_str_capitalize_bang()

static VALUE rb_str_capitalize_bang ( VALUE  str)
static

◆ rb_str_casecmp()

static VALUE rb_str_casecmp ( VALUE  str1,
VALUE  str2 
)
static

◆ rb_str_cat()

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

◆ rb_str_cat2()

VALUE rb_str_cat2 ( VALUE  str,
const char *  ptr 
)

◆ rb_str_center()

static VALUE rb_str_center ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 7708 of file string.c.

References argc, argv, and rb_str_justify().

Referenced by Init_String().

◆ rb_str_chars()

static VALUE rb_str_chars ( VALUE  str)
static

Definition at line 6773 of file string.c.

References rb_str_enumerate_chars().

Referenced by Init_String().

◆ rb_str_check_dummy_enc()

static void rb_str_check_dummy_enc ( rb_encoding enc)
static

◆ rb_str_chomp()

static VALUE rb_str_chomp ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 7074 of file string.c.

References argc, argv, rb_str_chomp_bang(), and rb_str_dup().

Referenced by Init_String().

◆ rb_str_chomp_bang()

static VALUE rb_str_chomp_bang ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_chop()

static VALUE rb_str_chop ( VALUE  str)
static

Definition at line 6936 of file string.c.

References chopped_length(), and rb_str_subseq().

Referenced by Init_String().

◆ rb_str_chop_bang()

static VALUE rb_str_chop_bang ( VALUE  str)
static

◆ rb_str_chr()

static VALUE rb_str_chr ( VALUE  str)
static

Definition at line 4367 of file string.c.

References rb_str_substr().

Referenced by Init_String().

◆ rb_str_clear()

static VALUE rb_str_clear ( VALUE  str)
static

◆ rb_str_cmp()

int rb_str_cmp ( VALUE  str1,
VALUE  str2 
)

◆ rb_str_cmp_m()

static VALUE rb_str_cmp_m ( VALUE  str1,
VALUE  str2 
)
static

Definition at line 2595 of file string.c.

References INT2FIX, rb_check_funcall(), rb_intern, rb_invcmp(), rb_str_cmp(), RB_TYPE_P, result, and T_STRING.

Referenced by Init_String(), and sym_cmp().

◆ rb_str_codepoints()

static VALUE rb_str_codepoints ( VALUE  str)
static

Definition at line 6867 of file string.c.

References rb_str_enumerate_codepoints().

Referenced by Init_String().

◆ rb_str_coderange_scan_restartable()

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

◆ rb_str_comparable()

int rb_str_comparable ( VALUE  str1,
VALUE  str2 
)

◆ rb_str_concat()

VALUE rb_str_concat ( VALUE  str1,
VALUE  str2 
)

◆ rb_str_conv_enc()

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

◆ rb_str_conv_enc_opts()

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

◆ rb_str_count()

static VALUE rb_str_count ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_crypt()

static VALUE rb_str_crypt ( VALUE  str,
VALUE  salt 
)
static

◆ rb_str_delete()

static VALUE rb_str_delete ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 5881 of file string.c.

References argc, argv, rb_str_delete_bang(), and rb_str_dup().

Referenced by Init_String().

◆ rb_str_delete_bang()

static VALUE rb_str_delete_bang ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_downcase()

static VALUE rb_str_downcase ( VALUE  str)
static

Definition at line 5200 of file string.c.

References rb_str_downcase_bang(), and rb_str_dup().

Referenced by Init_String(), and sym_downcase().

◆ rb_str_downcase_bang()

static VALUE rb_str_downcase_bang ( VALUE  str)
static

◆ rb_str_drop_bytes()

VALUE rb_str_drop_bytes ( VALUE  str,
long  len 
)

◆ rb_str_dump()

VALUE rb_str_dump ( VALUE  str)

◆ rb_str_dup()

VALUE rb_str_dup ( VALUE  str)

◆ rb_str_each_byte()

static VALUE rb_str_each_byte ( VALUE  str)
static

Definition at line 6650 of file string.c.

References rb_str_enumerate_bytes().

Referenced by Init_String().

◆ rb_str_each_byte_size()

static VALUE rb_str_each_byte_size ( VALUE  str,
VALUE  args,
VALUE  eobj 
)
static

Definition at line 6593 of file string.c.

References LONG2FIX, and RSTRING_LEN.

Referenced by rb_str_enumerate_bytes().

◆ rb_str_each_char()

static VALUE rb_str_each_char ( VALUE  str)
static

Definition at line 6756 of file string.c.

References rb_str_enumerate_chars().

Referenced by Init_String().

◆ rb_str_each_char_size()

static VALUE rb_str_each_char_size ( VALUE  str,
VALUE  args,
VALUE  eobj 
)
static

Definition at line 6673 of file string.c.

References rb_str_length().

Referenced by rb_str_enumerate_chars(), and rb_str_enumerate_codepoints().

◆ rb_str_each_codepoint()

static VALUE rb_str_each_codepoint ( VALUE  str)
static

Definition at line 6849 of file string.c.

References rb_str_enumerate_codepoints().

Referenced by Init_String().

◆ rb_str_each_line()

static VALUE rb_str_each_line ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 6569 of file string.c.

References argc, argv, and rb_str_enumerate_lines().

Referenced by Init_String().

◆ 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
strthe string to ellipsize.
lenthe 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 7969 of file string.c.

References 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_with_class(), rb_str_subseq(), rb_usascii_str_new(), RSTRING_LEN, and RSTRING_PTR.

Referenced by rb_hash_fetch_m(), and sys_fail2().

◆ rb_str_empty()

static VALUE rb_str_empty ( VALUE  str)
static

Definition at line 1334 of file string.c.

References Qfalse, Qtrue, and RSTRING_LEN.

Referenced by Init_String(), and sym_empty().

◆ rb_str_end_with()

static VALUE rb_str_end_with ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 7852 of file string.c.

References argc, argv, memcmp(), Qfalse, Qtrue, rb_enc_check(), rb_enc_left_char_head, RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_String().

◆ rb_str_enumerate_bytes()

static VALUE rb_str_enumerate_bytes ( VALUE  str,
int  wantarray 
)
static

◆ rb_str_enumerate_chars()

static VALUE rb_str_enumerate_chars ( VALUE  str,
int  wantarray 
)
static

◆ rb_str_enumerate_codepoints()

static VALUE rb_str_enumerate_codepoints ( VALUE  str,
int  wantarray 
)
static

◆ rb_str_enumerate_lines()

static VALUE rb_str_enumerate_lines ( int  argc,
VALUE argv,
VALUE  str,
int  wantarray 
)
static

◆ rb_str_eql()

static VALUE rb_str_eql ( VALUE  str1,
VALUE  str2 
)
static

Definition at line 2562 of file string.c.

References Qfalse, Qtrue, RB_TYPE_P, str_eql(), and T_STRING.

Referenced by Init_String().

◆ rb_str_equal()

VALUE rb_str_equal ( VALUE  str1,
VALUE  str2 
)

◆ rb_str_export()

VALUE rb_str_export ( VALUE  str)

Definition at line 743 of file string.c.

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

◆ rb_str_export_locale()

VALUE rb_str_export_locale ( VALUE  str)

Definition at line 749 of file string.c.

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

◆ rb_str_export_to_enc()

VALUE rb_str_export_to_enc ( VALUE  str,
rb_encoding enc 
)

Definition at line 755 of file string.c.

References rb_str_conv_enc(), and STR_ENC_GET.

Referenced by alias(), scalar(), start_document(), start_mapping(), start_sequence(), and transcode_string().

◆ rb_str_fill_terminator()

void rb_str_fill_terminator ( VALUE  str,
const int  newminlen 
)

Definition at line 1669 of file string.c.

References rb_enc_get(), rb_enc_mbminlen, RSTRING_LEN, RSTRING_PTR, and str_fill_term().

Referenced by rb_enc_associate_index().

◆ rb_str_force_encoding()

static VALUE rb_str_force_encoding ( VALUE  str,
VALUE  enc 
)
static

Definition at line 7892 of file string.c.

References ENC_CODERANGE_CLEAR, rb_enc_associate(), rb_to_encoding(), and str_modifiable().

Referenced by Init_String().

◆ rb_str_format_m()

static VALUE rb_str_format_m ( VALUE  str,
VALUE  arg 
)
static

Definition at line 1431 of file string.c.

References NIL_P, RARRAY_CONST_PTR, RARRAY_LENINT, rb_check_array_type(), and rb_str_format().

Referenced by Init_String().

◆ rb_str_free()

void rb_str_free ( VALUE  str)

◆ rb_str_freeze()

VALUE rb_str_freeze ( VALUE  str)

◆ rb_str_getbyte()

static VALUE rb_str_getbyte ( VALUE  str,
VALUE  index 
)
static

Definition at line 4379 of file string.c.

References INT2FIX, NUM2LONG, Qnil, RSTRING_LEN, and RSTRING_PTR.

Referenced by Init_String().

◆ rb_str_gsub()

static VALUE rb_str_gsub ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 4304 of file string.c.

References argc, argv, and str_gsub().

Referenced by Init_String().

◆ rb_str_gsub_bang()

static VALUE rb_str_gsub_bang ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 4253 of file string.c.

References argc, argv, str_gsub(), and str_modify_keep_cr().

Referenced by Init_String().

◆ rb_str_hash()

st_index_t rb_str_hash ( VALUE  str)

◆ rb_str_hash_cmp()

int rb_str_hash_cmp ( VALUE  str1,
VALUE  str2 
)

Definition at line 2431 of file string.c.

References memcmp(), rb_str_comparable(), RSTRING_LEN, and RSTRING_PTR.

Referenced by cdhash_cmp(), fstring_cmp(), and rb_any_cmp().

◆ rb_str_hash_m()

static VALUE rb_str_hash_m ( VALUE  str)
static

Definition at line 2451 of file string.c.

References INT2FIX, and rb_str_hash().

Referenced by Init_String().

◆ rb_str_hex()

static VALUE rb_str_hex ( VALUE  str)
static

Definition at line 7366 of file string.c.

References FALSE, and rb_str_to_inum().

Referenced by Init_String().

◆ rb_str_include()

static VALUE rb_str_include ( VALUE  str,
VALUE  arg 
)
static

Definition at line 4645 of file string.c.

References Qfalse, Qtrue, rb_str_index(), and StringValue.

Referenced by Init_String().

◆ rb_str_index()

static long rb_str_index ( VALUE  str,
VALUE  sub,
long  offset 
)
static

◆ rb_str_index_m()

static VALUE rb_str_index_m ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_init()

static VALUE rb_str_init ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 1085 of file string.c.

References argc, argv, rb_scan_args(), and rb_str_replace().

Referenced by Init_String().

◆ rb_str_insert()

static VALUE rb_str_insert ( VALUE  str,
VALUE  idx,
VALUE  str2 
)
static

Definition at line 3888 of file string.c.

References NUM2LONG, rb_str_append(), and rb_str_splice().

Referenced by Init_String().

◆ rb_str_inspect()

VALUE rb_str_inspect ( VALUE  str)

◆ rb_str_intern()

VALUE rb_str_intern ( VALUE  s)

◆ rb_str_is_ascii_only_p()

static VALUE rb_str_is_ascii_only_p ( VALUE  str)
static

◆ rb_str_justify()

static VALUE rb_str_justify ( int  argc,
VALUE argv,
VALUE  str,
char  jflag 
)
static

◆ rb_str_length()

VALUE rb_str_length ( VALUE  str)

◆ rb_str_lines()

static VALUE rb_str_lines ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 6587 of file string.c.

References argc, argv, and rb_str_enumerate_lines().

Referenced by Init_String().

◆ rb_str_ljust()

static VALUE rb_str_ljust ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 7668 of file string.c.

References argc, argv, and rb_str_justify().

Referenced by Init_String().

◆ rb_str_locktmp_ensure()

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

Definition at line 2000 of file string.c.

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

Referenced by io_fread(), and io_getpartial().

◆ rb_str_lstrip()

static VALUE rb_str_lstrip ( VALUE  str)
static

Definition at line 7135 of file string.c.

References rb_str_dup(), and rb_str_lstrip_bang().

Referenced by Init_String().

◆ rb_str_lstrip_bang()

static VALUE rb_str_lstrip_bang ( VALUE  str)
static

◆ rb_str_match()

static VALUE rb_str_match ( VALUE  x,
VALUE  y 
)
static

◆ rb_str_match_m()

static VALUE rb_str_match_m ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 3039 of file string.c.

References argc, argv, get_pat(), NIL_P, rb_block_given_p(), rb_check_arity, rb_funcall2, rb_intern, rb_yield(), and result.

Referenced by Init_String().

◆ rb_str_memsize()

RUBY_FUNC_EXPORTED size_t rb_str_memsize ( VALUE  str)

Definition at line 953 of file string.c.

References ELTS_SHARED, FL_TEST, STR_HEAP_SIZE, and STR_NOEMBED.

Referenced by obj_memsize_of().

◆ rb_str_modify()

void rb_str_modify ( VALUE  str)

◆ rb_str_modify_expand()

void rb_str_modify_expand ( VALUE  str,
long  expand 
)

◆ rb_str_new()

VALUE rb_str_new ( const char *  ptr,
long  len 
)

Definition at line 534 of file string.c.

References rb_cString, and str_new().

Referenced by addrinfo_mdump(), addrinfo_to_sockaddr(), appendline(), argf_getpartial(), asn1str_to_str(), BigDecimal_dump(), BigDecimal_inspect(), BigDecimal_split(), BigDecimal_to_f(), BigDecimal_to_s(), bsock_getpeername(), bsock_getsockname(), bsock_getsockopt(), bubblebabble_str_new(), check_pipe_command(), cState_array_nl(), cState_indent(), cState_object_nl(), cState_space(), cState_space_before(), cState_to_h(), date_strftime_internal(), date_zone_to_diff(), decode_bstr(), decode_eoc(), dir_s_home(), econv_convert(), econv_description(), econv_finish(), econv_primitive_errinfo(), econv_putback(), env_fetch(), env_str_new(), extract_user_token(), gzfile_getc(), gzfile_read(), gzfile_read_all(), gzfile_read_header(), gzfile_readpartial(), gzreader_gets(), infected_str_new(), inspect1(), inspect2(), int_chr(), int_ossl_asn1_decode0_prim(), io_getc(), io_setstrbuf(), io_shift_cbuf(), join_der(), lib_conv_listelement(), lib_fromUTF8_core(), lib_merge_tklist(), lib_toUTF8_core(), lib_UTF_backslash_core(), load_file_internal(), load_file_read_contents(), load_transcoder_entry(), make_econv_exception(), match_to_s(), Messaging_HandleMessage(), name_to_backref_number(), ossl_asn1cons_to_der(), ossl_asn1data_to_der(), ossl_asn1eoc_initialize(), ossl_bn_to_s(), ossl_cipher_final(), ossl_cipher_update(), ossl_dh_compute_key(), ossl_dh_to_der(), ossl_digest_finish(), ossl_dsa_sign(), ossl_dsa_to_der(), ossl_hmac_s_digest(), ossl_make_error(), ossl_membio2str0(), ossl_pkcs12_to_der(), ossl_pkcs7_to_der(), ossl_pkey_sign(), ossl_rand_bytes(), ossl_rand_pseudo_bytes(), ossl_rsa_private_decrypt(), ossl_rsa_private_encrypt(), ossl_rsa_public_decrypt(), ossl_rsa_public_encrypt(), ossl_rsa_to_der(), ossl_spki_get_challenge(), ossl_spki_print(), ossl_spki_to_der(), ossl_ssl_read_internal(), ossl_ssl_session_to_der(), ossl_ssl_session_to_pem(), ossl_ssl_session_to_text(), ossl_sslctx_session_get_cb(), ossl_sslctx_set_ciphers(), ossl_str_new(), ossl_x509_to_der(), ossl_x509attr_get_value(), ossl_x509attr_to_der(), ossl_x509crl_get_signature_algorithm(), ossl_x509crl_to_der(), ossl_x509crl_to_pem(), ossl_x509crl_to_text(), ossl_x509ext_to_der(), ossl_x509name_to_a(), ossl_x509name_to_der(), ossl_x509req_get_signature_algorithm(), ossl_x509req_to_der(), ossl_x509req_to_pem(), ossl_x509req_to_text(), parse(), proc_options(), r_bytes0(), r_bytes1_buffered(), rb_compile_cstr(), rb_digest_base_finish(), rb_enc_str_new(), rb_exc_new(), rb_execarg_fixup(), rb_execarg_run_options(), rb_f_backquote(), rb_f_getenv(), rb_file_dirname(), rb_file_join(), rb_file_s_basename(), rb_file_s_extname(), rb_gdbm_fetch(), rb_gdbm_firstkey(), rb_gdbm_nextkey(), rb_inflate_inflate(), rb_io_getline_fast(), rb_io_putc(), rb_io_ungetbyte(), rb_iseq_disasm(), rb_iseq_disasm_insn(), rb_nkf_convert(), rb_parser_compile_cstr(), rb_path_check(), rb_random_bytes(), rb_reg_compile(), rb_reg_quote(), rb_str_conv_enc_opts(), rb_str_enumerate_lines(), rb_str_format(), rb_str_new_cstr(), rb_str_plus(), rb_str_slice_bang(), rb_tainted_str_new(), rb_usascii_str_new(), rb_write_error2(), reg_named_captures_iter(), rsock_addrinfo_inspect_sockaddr(), ruby_init_loadpath_safe(), s3e(), set_file_encoding(), set_option_encoding_once(), sock_s_gethostbyaddr(), sock_s_pack_sockaddr_in(), sock_sockaddr(), sockopt_s_bool(), sockopt_s_byte(), sockopt_s_int(), sockopt_s_ipv4_multicast_loop(), sockopt_s_ipv4_multicast_ttl(), sockopt_s_linger(), str_new(), strio_getline(), strio_putc(), strio_read(), strio_substr(), time_mdump(), time_strftime(), tkstr_to_str(), warn_print(), writer(), zstream_detach_buffer(), zstream_detach_input(), and zstream_expand_buffer_into().

◆ rb_str_new_cstr()

VALUE rb_str_new_cstr ( const char *  ptr)

◆ rb_str_new_frozen()

VALUE rb_str_new_frozen ( VALUE  orig)

◆ rb_str_new_shared()

VALUE rb_str_new_shared ( VALUE  str)

Definition at line 799 of file string.c.

References OBJ_INFECT, rb_obj_class(), and str_new3().

Referenced by rb_file_s_basename(), and rb_str_subseq().

◆ rb_str_new_with_class()

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

Definition at line 874 of file string.c.

References rb_obj_class(), and str_new().

Referenced by rb_str_ellipsize().

◆ rb_str_oct()

static VALUE rb_str_oct ( VALUE  str)
static

Definition at line 7387 of file string.c.

References FALSE, and rb_str_to_inum().

Referenced by Init_String().

◆ rb_str_offset()

long rb_str_offset ( VALUE  str,
long  pos 
)

Definition at line 1780 of file string.c.

References RSTRING_END, RSTRING_PTR, single_byte_optimizable(), STR_ENC_GET, and str_offset().

Referenced by rb_str_rpartition(), and reg_match_pos().

◆ rb_str_ord()

VALUE rb_str_ord ( VALUE  s)

Definition at line 7487 of file string.c.

References rb_enc_codepoint, RSTRING_END, RSTRING_PTR, STR_ENC_GET, and UINT2NUM.

Referenced by Init_String().

◆ rb_str_partition()

static VALUE rb_str_partition ( VALUE  str,
VALUE  sep 
)
static

◆ rb_str_plus()

VALUE rb_str_plus ( VALUE  str1,
VALUE  str2 
)

◆ rb_str_prepend()

static VALUE rb_str_prepend ( VALUE  str,
VALUE  str2 
)
static

Definition at line 2412 of file string.c.

References rb_str_update(), and StringValue.

Referenced by Init_String().

◆ rb_str_quote_unprintable()

VALUE rb_str_quote_unprintable ( VALUE  str)

◆ rb_str_replace()

VALUE rb_str_replace ( VALUE  str,
VALUE  str2 
)

Definition at line 4322 of file string.c.

References str_discard(), str_modifiable(), str_replace(), and StringValue.

Referenced by Init_String(), rb_str_init(), and str_scrub_bang().

◆ rb_str_resize()

VALUE rb_str_resize ( VALUE  str,
long  len 
)

Definition at line 2024 of file string.c.

References ENC_CODERANGE_CLEAR, MEMCPY, rb_eArgError, rb_raise(), REALLOC_N, RSTRING, RSTRING_EMBED_LEN_MAX, RSTRING_LEN, ruby_xfree(), STR_EMBED_P, STR_HEAP_PTR, str_independent(), str_make_independent_expand(), STR_SET_EMBED, STR_SET_EMBED_LEN, STR_SET_NOEMBED, TERM_FILL, and TERM_LEN.

Referenced by append_fspath(), appendline(), argf_getpartial(), argf_read(), big2str_generic(), BigDecimal_dump(), BigDecimal_inspect(), BigDecimal_split(), BigDecimal_to_s(), copy_home_path(), copy_stream_body(), copy_stream_fallback_body(), econv_primitive_convert(), flo_to_s(), get_user_from_path(), glob_helper(), gzfile_error_inspect(), gzfile_readpartial(), lib_conv_listelement(), literal_concat0(), marshal_dump(), moreswitches(), ossl_cipher_update(), ossl_digest_finish(), ossl_ssl_read_internal(), r_object0(), rb_big2str0(), rb_econv_append(), rb_enc_vsprintf(), rb_feature_p(), rb_file_expand_path_internal(), rb_gzfile_set_comment(), rb_gzfile_set_orig_name(), rb_io_getline_fast(), rb_iseq_disasm(), rb_nkf_putchar(), rb_reg_quote(), rb_reg_to_s(), rb_str_concat(), rb_str_conv_enc_opts(), rb_str_format(), rb_str_vcatf(), realpath_rec(), ruby_init_loadpath_safe(), ruby_setenv(), set_file_encoding(), setup_narg(), str_shrink(), str_transcoding_resize(), strio_extend(), strio_init(), strio_read(), strio_truncate(), strio_ungetbyte(), strio_ungetc(), sym_inspect(), VpAlloc(), w_nbyte(), yyparse(), zstream_append_buffer(), zstream_detach_buffer(), zstream_discard_input(), zstream_expand_buffer(), and zstream_expand_buffer_into().

◆ rb_str_resurrect()

VALUE rb_str_resurrect ( VALUE  str)

◆ rb_str_reverse()

static VALUE rb_str_reverse ( VALUE  str)
static

◆ rb_str_reverse_bang()

static VALUE rb_str_reverse_bang ( VALUE  str)
static

◆ rb_str_rindex()

static long rb_str_rindex ( VALUE  str,
VALUE  sub,
long  pos 
)
static

◆ rb_str_rindex_m()

static VALUE rb_str_rindex_m ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_rjust()

static VALUE rb_str_rjust ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 7688 of file string.c.

References argc, argv, and rb_str_justify().

Referenced by Init_String().

◆ rb_str_rpartition()

static VALUE rb_str_rpartition ( VALUE  str,
VALUE  sep 
)
static

◆ rb_str_rstrip()

static VALUE rb_str_rstrip ( VALUE  str)
static

Definition at line 7205 of file string.c.

References rb_str_dup(), and rb_str_rstrip_bang().

Referenced by Init_String().

◆ rb_str_rstrip_bang()

static VALUE rb_str_rstrip_bang ( VALUE  str)
static

◆ rb_str_s_try_convert()

static VALUE rb_str_s_try_convert ( VALUE  dummy,
VALUE  str 
)
static

Definition at line 1696 of file string.c.

References rb_check_string_type().

Referenced by Init_String().

◆ rb_str_scan()

static VALUE rb_str_scan ( VALUE  str,
VALUE  pat 
)
static

◆ rb_str_scrub()

VALUE rb_str_scrub ( VALUE  str,
VALUE  repl 
)

◆ rb_str_set_len()

void rb_str_set_len ( VALUE  str,
long  len 
)

◆ rb_str_setbyte()

static VALUE rb_str_setbyte ( VALUE  str,
VALUE  index,
VALUE  value 
)
static

Definition at line 4398 of file string.c.

References NUM2INT, NUM2LONG, rb_eIndexError, rb_raise(), rb_str_modify(), RSTRING_LEN, and RSTRING_PTR.

Referenced by Init_String().

◆ rb_str_setter()

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

Definition at line 7875 of file string.c.

References NIL_P, rb_eTypeError, rb_id2name(), rb_raise(), RB_TYPE_P, T_STRING, and val.

Referenced by Init_IO().

◆ rb_str_shared_replace()

void rb_str_shared_replace ( VALUE  str,
VALUE  str2 
)

◆ rb_str_slice_bang()

static VALUE rb_str_slice_bang ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 3923 of file string.c.

References argc, argv, buf, NIL_P, rb_check_arity, rb_str_aref_m(), rb_str_aset_m(), rb_str_new(), result, and str_modify_keep_cr().

Referenced by Init_String().

◆ rb_str_splice()

static void rb_str_splice ( VALUE  str,
long  beg,
long  len,
VALUE  val 
)
static

◆ rb_str_splice_0()

static void rb_str_splice_0 ( VALUE  str,
long  beg,
long  len,
VALUE  val 
)
static

◆ rb_str_split()

VALUE rb_str_split ( VALUE  str,
const char *  sep0 
)

Definition at line 6409 of file string.c.

References rb_str_new2, rb_str_split_m(), and StringValue.

◆ rb_str_split_m()

static VALUE rb_str_split_m ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_squeeze()

static VALUE rb_str_squeeze ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 5988 of file string.c.

References argc, argv, rb_str_dup(), and rb_str_squeeze_bang().

Referenced by Init_String().

◆ rb_str_squeeze_bang()

static VALUE rb_str_squeeze_bang ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_start_with()

static VALUE rb_str_start_with ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 7829 of file string.c.

References argc, argv, memcmp(), Qfalse, Qtrue, rb_enc_check(), RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by Init_String().

◆ rb_str_strip()

static VALUE rb_str_strip ( VALUE  str)
static

Definition at line 7243 of file string.c.

References rb_str_dup(), and rb_str_strip_bang().

Referenced by Init_String().

◆ rb_str_strip_bang()

static VALUE rb_str_strip_bang ( VALUE  str)
static

Definition at line 7222 of file string.c.

References NIL_P, Qnil, rb_str_lstrip_bang(), and rb_str_rstrip_bang().

Referenced by Init_String(), and rb_str_strip().

◆ rb_str_strlen()

long rb_str_strlen ( VALUE  str)

Definition at line 1284 of file string.c.

References STR_ENC_GET, and str_strlen().

◆ rb_str_sub()

static VALUE rb_str_sub ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 4120 of file string.c.

References argc, argv, rb_str_dup(), and rb_str_sub_bang().

Referenced by Init_String().

◆ rb_str_sub_bang()

static VALUE rb_str_sub_bang ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_sublen()

long rb_str_sublen ( VALUE  str,
long  pos 
)

◆ rb_str_subpat()

static VALUE rb_str_subpat ( VALUE  str,
VALUE  re,
VALUE  backref 
)
static

◆ rb_str_subpat_set()

static void rb_str_subpat_set ( VALUE  str,
VALUE  re,
VALUE  backref,
VALUE  val 
)
static

◆ rb_str_subpos()

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

◆ rb_str_subseq()

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

◆ rb_str_substr()

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

◆ rb_str_succ()

VALUE rb_str_succ ( VALUE  orig)

◆ rb_str_succ_bang()

static VALUE rb_str_succ_bang ( VALUE  str)
static

Definition at line 3360 of file string.c.

References rb_str_shared_replace(), and rb_str_succ().

Referenced by Init_String().

◆ rb_str_sum()

static VALUE rb_str_sum ( int  argc,
VALUE argv,
VALUE  str 
)
static

◆ rb_str_swapcase()

static VALUE rb_str_swapcase ( VALUE  str)
static

Definition at line 5334 of file string.c.

References rb_str_dup(), and rb_str_swapcase_bang().

Referenced by Init_String(), and sym_swapcase().

◆ rb_str_swapcase_bang()

static VALUE rb_str_swapcase_bang ( VALUE  str)
static

◆ rb_str_symname_p()

int rb_str_symname_p ( VALUE  sym)

◆ rb_str_times()

VALUE rb_str_times ( VALUE  str,
VALUE  times 
)

◆ rb_str_tmp_new()

VALUE rb_str_tmp_new ( long  len)

◆ rb_str_to_f()

static VALUE rb_str_to_f ( VALUE  str)
static

Definition at line 4712 of file string.c.

References DBL2NUM, FALSE, and rb_str_to_dbl().

Referenced by Init_String().

◆ rb_str_to_i()

static VALUE rb_str_to_i ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 4679 of file string.c.

References argc, argv, FALSE, NUM2INT, rb_eArgError, rb_raise(), rb_scan_args(), and rb_str_to_inum().

Referenced by Init_String().

◆ rb_str_to_s()

static VALUE rb_str_to_s ( VALUE  str)
static

Definition at line 4727 of file string.c.

References rb_cString, rb_obj_class(), and str_duplicate().

Referenced by Init_String().

◆ rb_str_to_str()

VALUE rb_str_to_str ( VALUE  str)

◆ rb_str_tr()

static VALUE rb_str_tr ( VALUE  str,
VALUE  src,
VALUE  repl 
)
static

Definition at line 5702 of file string.c.

References rb_str_dup(), and tr_trans().

Referenced by Init_String().

◆ rb_str_tr_bang()

static VALUE rb_str_tr_bang ( VALUE  str,
VALUE  src,
VALUE  repl 
)
static

Definition at line 5660 of file string.c.

References tr_trans().

Referenced by Init_String().

◆ rb_str_tr_s()

static VALUE rb_str_tr_s ( VALUE  str,
VALUE  src,
VALUE  repl 
)
static

Definition at line 6025 of file string.c.

References rb_str_dup(), and tr_trans().

Referenced by Init_String().

◆ rb_str_tr_s_bang()

static VALUE rb_str_tr_s_bang ( VALUE  str,
VALUE  src,
VALUE  repl 
)
static

Definition at line 6005 of file string.c.

References tr_trans().

Referenced by Init_String().

◆ rb_str_unlocktmp()

VALUE rb_str_unlocktmp ( VALUE  str)

◆ rb_str_upcase()

static VALUE rb_str_upcase ( VALUE  str)
static

Definition at line 5117 of file string.c.

References rb_str_dup(), and rb_str_upcase_bang().

Referenced by Init_String(), and sym_upcase().

◆ rb_str_upcase_bang()

static VALUE rb_str_upcase_bang ( VALUE  str)
static

◆ rb_str_update()

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

Definition at line 3744 of file string.c.

References rb_str_splice(), and val.

Referenced by eval_string_with_cref(), rb_str_prepend(), and strio_ungetc().

◆ rb_str_upto()

static VALUE rb_str_upto ( int  argc,
VALUE argv,
VALUE  beg 
)
static

◆ rb_str_valid_encoding_p()

static VALUE rb_str_valid_encoding_p ( VALUE  str)
static

Definition at line 7929 of file string.c.

References ENC_CODERANGE_BROKEN, Qfalse, Qtrue, and rb_enc_str_coderange().

Referenced by Init_String().

◆ rb_string_value()

VALUE rb_string_value ( volatile VALUE ptr)

Definition at line 1588 of file string.c.

References rb_str_to_str(), RB_TYPE_P, 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)

◆ rb_string_value_ptr()

char* rb_string_value_ptr ( volatile VALUE ptr)

Definition at line 1599 of file string.c.

References rb_string_value(), and RSTRING_PTR.

◆ rb_sym_to_s()

VALUE rb_sym_to_s ( VALUE  sym)

◆ rb_tainted_str_new()

VALUE rb_tainted_str_new ( const char *  ptr,
long  len 
)

◆ rb_tainted_str_new_cstr()

VALUE rb_tainted_str_new_cstr ( const char *  ptr)

Definition at line 598 of file string.c.

References OBJ_TAINT, and rb_str_new2.

Referenced by addrinfo_firstonly_new(), addrinfo_list_new(), and init_addrinfo_getaddrinfo().

◆ rb_to_id()

ID rb_to_id ( VALUE  name)

◆ rb_usascii_str_new()

VALUE rb_usascii_str_new ( const char *  ptr,
long  len 
)

◆ rb_usascii_str_new_cstr()

VALUE rb_usascii_str_new_cstr ( const char *  ptr)

◆ RUBY_ALIAS_FUNCTION()

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

Definition at line 1976 of file string.c.

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

◆ scan_once()

static VALUE scan_once ( VALUE  str,
VALUE  pat,
long *  start 
)
static

◆ search_nonascii()

static const char* search_nonascii ( const char *  p,
const char *  e 
)
inlinestatic

◆ single_byte_optimizable()

static int single_byte_optimizable ( VALUE  str)
inlinestatic

◆ str_alloc()

static VALUE str_alloc ( VALUE  klass)
inlinestatic

◆ str_buf_cat()

static VALUE str_buf_cat ( VALUE  str,
const char *  ptr,
long  len 
)
static

◆ str_byte_aref()

static VALUE str_byte_aref ( VALUE  str,
VALUE  indx 
)
static

◆ str_byte_substr()

static VALUE str_byte_substr ( VALUE  str,
long  beg,
long  len 
)
static

◆ str_compat_and_valid()

static VALUE str_compat_and_valid ( VALUE  str,
rb_encoding enc 
)
static

◆ str_discard()

static void str_discard ( VALUE  str)
inlinestatic

◆ str_duplicate()

static VALUE str_duplicate ( VALUE  klass,
VALUE  str 
)
static

Definition at line 1054 of file string.c.

References str_alloc(), and str_replace().

Referenced by rb_str_dup(), rb_str_resurrect(), and rb_str_to_s().

◆ str_enc_copy()

static void str_enc_copy ( VALUE  str1,
VALUE  str2 
)
inlinestatic

◆ str_eql()

static VALUE str_eql ( const VALUE  str1,
const VALUE  str2 
)
static

Definition at line 2512 of file string.c.

References memcmp(), Qfalse, Qtrue, rb_str_comparable(), RSTRING_LEN, and RSTRING_PTR.

Referenced by rb_str_eql(), and rb_str_equal().

◆ str_fill_term()

static char* str_fill_term ( VALUE  str,
char *  s,
long  len,
int  oldtermlen,
int  termlen 
)
static

◆ str_gsub()

static VALUE str_gsub ( int  argc,
VALUE argv,
VALUE  str,
int  bang 
)
static

◆ str_independent()

static int str_independent ( VALUE  str)
inlinestatic

◆ str_make_independent_expand()

static void str_make_independent_expand ( VALUE  str,
long  expand 
)
static

◆ str_mod_check()

static void str_mod_check ( VALUE  s,
const char *  p,
long  len 
)
inlinestatic

◆ str_modifiable()

static void str_modifiable ( VALUE  str)
inlinestatic

◆ str_modify_keep_cr()

static void str_modify_keep_cr ( VALUE  str)
static

◆ str_new()

static VALUE str_new ( VALUE  klass,
const char *  ptr,
long  len 
)
static

Definition at line 528 of file string.c.

References str_new0().

Referenced by rb_str_new(), rb_str_new_frozen(), rb_str_new_with_class(), and rb_str_tmp_new().

◆ str_new0()

static VALUE str_new0 ( VALUE  klass,
const char *  ptr,
long  len,
int  termlen 
)
static

◆ str_new3()

static VALUE str_new3 ( VALUE  klass,
VALUE  str 
)
static

◆ str_new4()

static VALUE str_new4 ( VALUE  klass,
VALUE  str 
)
static

◆ str_new_empty()

static VALUE str_new_empty ( VALUE  str)
static

Definition at line 880 of file string.c.

References OBJ_INFECT, rb_enc_copy(), and rb_str_new5.

Referenced by rb_str_partition(), rb_str_rpartition(), and rb_str_split_m().

◆ str_new_shared()

static VALUE str_new_shared ( VALUE  klass,
VALUE  str 
)
static

Definition at line 787 of file string.c.

References str_alloc(), and str_replace_shared().

Referenced by str_new3().

◆ str_nth()

static char* str_nth ( const char *  p,
const char *  e,
long  nth,
rb_encoding enc,
int  singlebyte 
)
static

Definition at line 1758 of file string.c.

References str_nth_len().

Referenced by rb_str_rindex(), rb_str_splice(), and str_offset().

◆ str_nth_len()

static char* str_nth_len ( const char *  p,
const char *  e,
long *  nthp,
rb_encoding enc 
)
static

◆ str_null_char()

static const char* str_null_char ( const char *  s,
long  len,
const int  minlen,
rb_encoding enc 
)
static

Definition at line 1615 of file string.c.

References rb_enc_mbclen(), and zero_filled().

Referenced by rb_string_value_cstr().

◆ str_offset()

static long str_offset ( const char *  p,
const char *  e,
long  nth,
rb_encoding enc,
int  singlebyte 
)
static

◆ str_replace()

static VALUE str_replace ( VALUE  str,
VALUE  str2 
)
static

◆ str_replace_shared()

static VALUE str_replace_shared ( VALUE  str2,
VALUE  str 
)
static

Definition at line 779 of file string.c.

References rb_enc_cr_str_exact_copy(), and str_replace_shared_without_enc().

Referenced by str_new_shared(), and str_replace().

◆ str_replace_shared_without_enc()

static VALUE str_replace_shared_without_enc ( VALUE  str2,
VALUE  str 
)
static

◆ str_rindex()

static long str_rindex ( VALUE  str,
VALUE  sub,
const char *  s,
long  pos,
rb_encoding enc 
)
static

Definition at line 2837 of file string.c.

References memcmp(), rb_enc_prev_char, RSTRING_END, RSTRING_LEN, RSTRING_PTR, sub, and t().

Referenced by rb_str_rindex().

◆ str_scrub()

static VALUE str_scrub ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 8290 of file string.c.

References argc, argv, NIL_P, Qnil, rb_check_arity, rb_str_dup(), and rb_str_scrub().

Referenced by Init_String().

◆ str_scrub_bang()

static VALUE str_scrub_bang ( int  argc,
VALUE argv,
VALUE  str 
)
static

Definition at line 8312 of file string.c.

References argc, argv, NIL_P, Qnil, rb_check_arity, rb_str_replace(), and rb_str_scrub().

Referenced by Init_String().

◆ str_strlen()

static long str_strlen ( VALUE  str,
rb_encoding enc 
)
static

◆ sym_aref()

static VALUE sym_aref ( int  argc,
VALUE argv,
VALUE  sym 
)
static

Definition at line 8636 of file string.c.

References argc, argv, rb_str_aref_m(), rb_sym_to_s(), and sym.

Referenced by Init_String().

◆ sym_call()

static VALUE sym_call ( VALUE  args,
VALUE  sym,
int  argc,
VALUE argv,
VALUE  passed_proc 
)
static

Definition at line 8506 of file string.c.

References argc, argv, rb_eArgError, rb_funcall_with_block(), rb_raise(), and sym.

Referenced by sym_to_proc().

◆ sym_capitalize()

static VALUE sym_capitalize ( VALUE  sym)
static

Definition at line 8702 of file string.c.

References rb_id2str(), rb_str_capitalize(), rb_str_intern(), sym, and SYM2ID.

Referenced by Init_String().

◆ sym_casecmp()

static VALUE sym_casecmp ( VALUE  sym,
VALUE  other 
)
static

Definition at line 8603 of file string.c.

References Qnil, rb_str_casecmp(), rb_sym_to_s(), sym, and SYMBOL_P.

Referenced by Init_String().

◆ sym_cmp()

static VALUE sym_cmp ( VALUE  sym,
VALUE  other 
)
static

Definition at line 8586 of file string.c.

References Qnil, rb_str_cmp_m(), rb_sym_to_s(), sym, and SYMBOL_P.

Referenced by Init_String().

◆ sym_downcase()

static VALUE sym_downcase ( VALUE  sym)
static

Definition at line 8689 of file string.c.

References rb_id2str(), rb_str_downcase(), rb_str_intern(), sym, and SYM2ID.

Referenced by Init_String().

◆ sym_empty()

static VALUE sym_empty ( VALUE  sym)
static

Definition at line 8663 of file string.c.

References rb_id2str(), rb_str_empty(), sym, and SYM2ID.

Referenced by Init_String().

◆ sym_encoding()

static VALUE sym_encoding ( VALUE  sym)
static

Definition at line 8728 of file string.c.

References rb_id2str(), rb_obj_encoding(), sym, and SYM2ID.

Referenced by Init_String().

◆ sym_equal()

static VALUE sym_equal ( VALUE  sym1,
VALUE  sym2 
)
static

Definition at line 8363 of file string.c.

References Qfalse, and Qtrue.

Referenced by Init_String().

◆ sym_inspect()

static VALUE sym_inspect ( VALUE  sym)
static

◆ sym_length()

static VALUE sym_length ( VALUE  sym)
static

Definition at line 8650 of file string.c.

References rb_id2str(), rb_str_length(), sym, and SYM2ID.

Referenced by Init_String().

◆ sym_match()

static VALUE sym_match ( VALUE  sym,
VALUE  other 
)
static

Definition at line 8620 of file string.c.

References rb_str_match(), rb_sym_to_s(), and sym.

Referenced by Init_String().

◆ sym_printable()

static int sym_printable ( const char *  s,
const char *  send,
rb_encoding enc 
)
static

Definition at line 8371 of file string.c.

References FALSE, rb_enc_codepoint_len(), rb_enc_isprint, and TRUE.

Referenced by rb_str_quote_unprintable(), and rb_str_symname_p().

◆ sym_succ()

static VALUE sym_succ ( VALUE  sym)
static

Definition at line 8566 of file string.c.

References rb_str_intern(), rb_str_succ(), rb_sym_to_s(), and sym.

Referenced by Init_String().

◆ sym_swapcase()

static VALUE sym_swapcase ( VALUE  sym)
static

Definition at line 8715 of file string.c.

References rb_id2str(), rb_str_intern(), rb_str_swapcase(), sym, and SYM2ID.

Referenced by Init_String().

◆ sym_to_proc()

static VALUE sym_to_proc ( VALUE  sym)
static

◆ sym_to_sym()

static VALUE sym_to_sym ( VALUE  sym)
static

Definition at line 8500 of file string.c.

References sym.

Referenced by Init_String().

◆ sym_upcase()

static VALUE sym_upcase ( VALUE  sym)
static

Definition at line 8676 of file string.c.

References rb_id2str(), rb_str_intern(), rb_str_upcase(), sym, and SYM2ID.

Referenced by Init_String().

◆ tr_find()

static int tr_find ( unsigned int  c,
const char  table[TR_TABLE_SIZE],
VALUE  del,
VALUE  nodel 
)
static

Definition at line 5775 of file string.c.

References FALSE, NIL_P, rb_hash_lookup, TRUE, and UINT2NUM.

Referenced by rb_str_count(), rb_str_delete_bang(), and rb_str_squeeze_bang().

◆ tr_setup_table()

static void tr_setup_table ( VALUE  str,
char  stable[TR_TABLE_SIZE],
int  first,
VALUE tablep,
VALUE ctablep,
rb_encoding enc 
)
static

◆ tr_trans()

static VALUE tr_trans ( VALUE  str,
VALUE  src,
VALUE  repl,
int  sflag 
)
static

◆ trnext()

static unsigned int trnext ( struct tr t,
rb_encoding enc 
)
static

◆ zero_filled()

static int zero_filled ( const char *  s,
int  n 
)
static

Definition at line 1606 of file string.c.

Referenced by str_fill_term(), and str_null_char().

Variable Documentation

◆ frozen_strings

st_table* frozen_strings
static

Definition at line 166 of file string.c.

Referenced by Init_String(), rb_fstring(), and rb_str_free().

◆ fstring_hash_type

const struct st_hash_type fstring_hash_type
static
Initial value:
= {
}
st_index_t rb_str_hash(VALUE str)
Definition: string.c:2421
static int fstring_cmp(VALUE a, VALUE b)
Definition: string.c:224

Definition at line 168 of file string.c.

Referenced by rb_fstring().

◆ id_to_s

ID id_to_s
static

Definition at line 1008 of file string.c.

Referenced by Init_String(), and rb_obj_as_string().

◆ isspacetable

const char isspacetable[256]
static
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 6130 of file string.c.

◆ rb_cString

VALUE rb_cString

◆ rb_cSymbol

VALUE rb_cSymbol

Definition at line 48 of file string.c.

Referenced by Init_String().

◆ rb_fs

VALUE rb_fs

Definition at line 251 of file string.c.

Referenced by Init_String(), and rb_str_split_m().