Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Macros | Functions
string.h File Reference

Internal header for String. More...

#include "ruby/internal/config.h"
#include <stddef.h>
#include "internal/compilers.h"
#include "ruby/internal/stdbool.h"
#include "ruby/encoding.h"
#include "ruby/ruby.h"

Go to the source code of this file.

Macros

#define STR_NOEMBED   FL_USER1
 
#define STR_SHARED   FL_USER2 /* = ELTS_SHARED */
 
#define rb_fstring_lit(str)   rb_fstring_new((str), rb_strlen_lit(str))
 
#define rb_fstring_literal(str)   rb_fstring_lit(str)
 
#define rb_fstring_enc_lit(str, enc)   rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
 
#define rb_fstring_enc_literal(str, enc)   rb_fstring_enc_lit(str, enc)
 
#define rb_fstring_cstr(str)
 

Functions

VALUE rb_fstring (VALUE)
 
VALUE rb_fstring_cstr (const char *str)
 
VALUE rb_fstring_enc_new (const char *ptr, long len, rb_encoding *enc)
 
int rb_str_buf_cat_escaped_char (VALUE result, unsigned int c, int unicode_p)
 
int rb_str_symname_p (VALUE)
 
VALUE rb_str_quote_unprintable (VALUE)
 
char * rb_str_fill_terminator (VALUE str, const int termlen)
 
void rb_str_change_terminator_length (VALUE str, const int oldtermlen, const int termlen)
 
VALUE rb_str_locktmp_ensure (VALUE str, VALUE(*func)(VALUE), VALUE arg)
 
VALUE rb_str_chomp_string (VALUE str, VALUE chomp)
 
VALUE rb_external_str_with_enc (VALUE str, rb_encoding *eenc)
 
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_enc_str_scrub (rb_encoding *enc, VALUE str, VALUE repl)
 
VALUE rb_str_initialize (VALUE str, const char *ptr, long len, rb_encoding *enc)
 
size_t rb_str_memsize (VALUE)
 
char * rb_str_to_cstr (VALUE str)
 
const char * ruby_escaped_char (int c)
 
void rb_str_make_independent (VALUE str)
 
int rb_enc_str_coderange_scan (VALUE str, rb_encoding *enc)
 
VALUE rb_str_tmp_frozen_acquire (VALUE str)
 
void rb_str_tmp_frozen_release (VALUE str, VALUE tmp)
 
VALUE rb_setup_fake_str (struct RString *fake_str, const char *name, long len, rb_encoding *enc)
 
VALUE rb_str_upto_each (VALUE, VALUE, int, int(*each)(VALUE, VALUE), VALUE)
 
VALUE rb_str_upto_endless_each (VALUE, int(*each)(VALUE, VALUE), VALUE)
 
VALUE rb_fstring_new (const char *ptr, long len)
 
VALUE rb_obj_as_string_result (VALUE str, VALUE obj)
 
VALUE rb_str_opt_plus (VALUE x, VALUE y)
 
VALUE rb_str_concat_literals (size_t num, const VALUE *strary)
 
VALUE rb_str_eql (VALUE str1, VALUE str2)
 
VALUE rb_id_quote_unprintable (ID)
 
VALUE rb_sym_proc_call (ID mid, int argc, const VALUE *argv, int kw_splat, VALUE passed_proc)
 
VALUE rb_ec_str_resurrect (struct rb_execution_context_struct *ec, VALUE str)
 

Detailed Description

Internal header for String.

Author
Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Definition in file string.h.

Macro Definition Documentation

◆ rb_fstring_cstr

#define rb_fstring_cstr (   str)
Value:
(__builtin_constant_p(str) ? \
rb_fstring_new((str), (long)strlen(str)) : \
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
#define rb_fstring_cstr(str)
Definition: string.h:136
size_t strlen(const char *)

Definition at line 136 of file string.h.

◆ rb_fstring_enc_lit

#define rb_fstring_enc_lit (   str,
  enc 
)    rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))

Definition at line 80 of file string.h.

◆ rb_fstring_enc_literal

#define rb_fstring_enc_literal (   str,
  enc 
)    rb_fstring_enc_lit(str, enc)

Definition at line 81 of file string.h.

◆ rb_fstring_lit

#define rb_fstring_lit (   str)    rb_fstring_new((str), rb_strlen_lit(str))

Definition at line 78 of file string.h.

◆ rb_fstring_literal

#define rb_fstring_literal (   str)    rb_fstring_lit(str)

Definition at line 79 of file string.h.

◆ STR_NOEMBED

#define STR_NOEMBED   FL_USER1

Definition at line 19 of file string.h.

◆ STR_SHARED

#define STR_SHARED   FL_USER2 /* = ELTS_SHARED */

Definition at line 20 of file string.h.

Function Documentation

◆ 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_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_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_external_str_with_enc()

VALUE rb_external_str_with_enc ( VALUE  str,
rb_encoding eenc 
)

◆ rb_fstring()

VALUE rb_fstring ( VALUE  str)

◆ rb_fstring_cstr()

VALUE rb_fstring_cstr ( const char *  str)

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

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

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

◆ rb_str_concat_literals()

VALUE rb_str_concat_literals ( size_t  num,
const VALUE strary 
)

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

char * rb_str_fill_terminator ( VALUE  str,
const int  termlen 
)

Definition at line 2454 of file string.c.

References len, RSTRING_LEN, RSTRING_PTR, and str.

◆ 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_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_opt_plus()

VALUE rb_str_opt_plus ( VALUE  x,
VALUE  y 
)

◆ rb_str_quote_unprintable()

VALUE rb_str_quote_unprintable ( VALUE  str)

◆ rb_str_symname_p()

int rb_str_symname_p ( VALUE  sym)

◆ rb_str_tmp_frozen_acquire()

VALUE rb_str_tmp_frozen_acquire ( VALUE  str)

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  str,
VALUE  tmp 
)

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

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

◆ rb_str_upto_endless_each()

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

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

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