aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
Commit message (Collapse)AuthorAgeFilesLines
* string.c: clear env self in symbol procnobu2014-04-121-0/+1
| | | | | | | | * string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear caller's self which is useless, so that it can get collected. [Fixes GH-592] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: remove unnecessary terminator spacenobu2014-04-091-3/+2
| | | | | | | | * string.c (str_buf_cat): remove unnecessary terminator space, since the capacity does not include its length but RESIZE_CAPA() considers it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix capacitynobu2014-04-091-1/+1
| | | | | | | * string.c (str_buf_cat): should round up the capacity by 4KiB, but not number of rooms. [ruby-core:61886] [Bug #9709] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y (rb_str_dynamic_intern): [DOC] move rdoc from rb_str_intern.ktsj2014-03-301-20/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: infect match resultnobu2014-03-281-0/+3
| | | | | | | * string.c (rb_pat_search): match result should be infected by the pattern. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: backref substitutionnobu2014-03-281-14/+26
| | | | | | | | | * re.c (rb_reg_regsub): allow nil regexp for string matching. * string.c (rb_str_sub_bang, str_gsub): make substitution if replacement string has backref escapes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: unset $~ if unmatchnobu2014-03-281-3/+8
| | | | | | * string.c (rb_pat_search): unset $~ if the last match failed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: suppress warningsnobu2014-03-271-2/+2
| | | | | | | * string.c (rb_str_sub_bang, str_gsub): initialize conditionally assigned variables to suppress maybe-uninitialized warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: search by rb_str_indexnobu2014-03-271-55/+110
| | | | | | | | | | | | * re.c (match_regexp): set regexp for MatchData from string. * re.c (rb_backref_set_string): create MatchData from string and set backref. * string.c (rb_pat_search, rb_str_sub, rb_str_sub_bang, str_gsub), (scan_once, rb_str_scan, rb_str_partition): use rb_str_index instead of rb_reg_search() when pattern is a String. based on the patch by Sam Rawlins <sam.rawlins@gmail.com> [Fixes GH-579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: mustnot_brokennobu2014-03-271-6/+10
| | | | | | | * string.c (mustnot_broken): extract function to reject invalid byte sequence, from rb_str_split_m(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: invert flagnobu2014-03-271-5/+5
| | | | | | | * string.c (str_gsub): invert and rename `str_replace` flag as `need_backref`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y: support Symbol GC. [ruby-trunk Feature #9634]nari2014-03-261-15/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See this ticket about Symbol GC. * include/ruby/ruby.h: Declare few functions. * rb_sym2id: almost same as old SYM2ID but support dynamic symbols. * rb_id2sym: almost same as old ID2SYM but support dynamic symbols. * rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not pin down a dynamic symbol. Declare a new struct. * struct RSymbol: represents a dynamic symbol as object in Ruby's heaps. Add few macros. * STATIC_SYM_P: check a static symbol. * DYNAMIC_SYM_P: check a dynamic symbol. * RSYMBOL: cast to RSymbol * gc.c: declare RSymbol. support T_SYMBOL. * internal.h: Declare few functions. * rb_gc_free_dsymbol: free up a dynamic symbol. GC call this function at a sweep phase. * rb_str_dynamic_intern: convert a string to a dynamic symbol. * rb_check_id_without_pindown: not pinning function. * rb_sym2id_without_pindown: ditto. * rb_check_id_cstr_without_pindown: ditto. * string.c (Init_String): String#intern and String#to_sym use rb_str_dynamic_intern. * template/id.h.tmpl: use LSB of ID as a flag for determining a static symbol, so we shift left other ruby_id_types. * string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to avoid pinning. * load.c: use xx_without_pindown function at creating temporary ID to avoid pinning. * object.c: ditto. * sprintf.c: ditto. * struct.c: ditto. * thread.c: ditto. * variable.c: ditto. * vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Stop allocating backref strings within gsub's search loopcharliesome2014-03-251-3/+5
| | | | | | | | | | | | | | * internal.h: add prototype for rb_reg_search0 * re.c: rename rb_reg_search to rb_reg_search0, add set_backref_str argument to allow callers to indicate that they don't require the backref string to be allocated * string.c: don't allocate backref str if replacement string is provided Closes GH-578. [Bug #9676] [ruby-core:61682] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] add links to `Object#hash`nobu2014-03-141-0/+2
| | | | | | | add links to `Object#hash` to each #`hash` methods rdocs. [Fixes GH-567] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: [DOC] rb_str_hash_mnobu2014-03-141-1/+1
| | | | | | | * string.c (rb_str_hash_m): [DOC] hash value depends on the encoding too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* adjust indent and stylenobu2014-02-271-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (sym_find): Add Symbol.find(str), which returns whether givennaruse2014-02-251-0/+22
| | | | | | string is defined as symbol or not. [Feature #7854] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_str_format_m): trade volatile for RB_GC_GUARDnormal2014-02-141-2/+4
| | | | | | | | * string.c (rb_str_format_m): trade volatile for RB_GC_GUARD RB_GC_GUARD meaning is clear and has better code generation. [ruby-core:60688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h, vm_core.h: move LIKELY/UNLIKELY/UNINITIALIZED_VAR()ko12014-02-051-1/+0
| | | | | | | | | | macros from vm_core.h to internal.h. * string.c: remove dependency to "vm_core.h". * common.mk: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_free): use FL_TEST(str, STR_SHARED) directlyko12014-02-051-2/+2
| | | | | | | | | | because str is not embed. * string.c (str_replace): remove `FL_SET(str, STR_SHARED)' line because STR_SET_SHARED() set STR_SHARED. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: remove macros STR_NOCAPA and STR_NOCAPA_P().ko12014-02-051-4/+2
| | | | | | | | | | | * string.c (rb_str_resize): remove `STR_SET_NOEMBED(str)' because str_make_independent_expand() set NOEMBED flag. * string.c (rb_str_resize): remove `STR_NOCAPA_P(str)' check because `str' is independent (not shared). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: refactoring, especially about string flags.ko12014-02-051-25/+28
| | | | | | | | | | | | | | | * string.c (STR_UNSET_NOCAPA): removed. Use FL_UNSET() with STR_SHARED. * string.c (rb_str_capacity): check STR_SHARED directly beacuse it is not a embed string. * string.c (rb_str_modify_expand): ditto. * string.c (rb_str_shared_replace): use STR_SET_SHARED(). * string.c (str_make_independent_expand): remove STR_UNSET_NOCAPA() because `str' is not shared string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (RESIZE_CAPA): should not resize shared string.ko12014-02-051-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_new_frozen): refactoring code.ko12014-02-051-41/+31
| | | | | | | | | * Move code from str_new_frozen_with_klass() (and remove it) * `aux.shared' should not be 0 for STR_SHARED strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: use long allocator names instead of numberedko12014-02-041-32/+26
| | | | | | | | | | | | | allocator names. * rb_str_new2 -> rb_str_new_cstr * rb_str_new4 -> rb_str_new_frozen * rb_str_new5 -> rb_str_new_with_class * str_new3 -> str_new_shared * str_new4 -> str_new_frozen_with_klass git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: use STR_SHARED instead of ELTS_SHARED.ko12014-02-041-5/+5
| | | | | | | | (same value, but more clear meaning) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: remvoe STR_ASSOC related code.ko12014-02-041-53/+3
| | | | | | | | | | By r44804, string objects can not have STR_ASSOC flag. * internal.h: ditto. * ext/objspace/objspace_dump.c (dump_object): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* pack.c: use ivar for associated objectsnobu2014-02-041-41/+0
| | | | | | | | * pack.c (str_associate, str_associated): keep associated objects in an instance variables, instead of in the internal structure. * string.c (rb_str_associate, rb_str_associated): deprecate. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: enable capacity when setting capanobu2014-02-041-0/+1
| | | | | | | | * string.c (rb_str_modify_expand): enable capacity and disable assocation with packed objects when setting capa, so that pack("p") string fails to unpack properly after modified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: respect BOMnobu2014-01-151-1/+7
| | | | | | | * string.c (get_encoding): respect BOM on pseudo encodings. [ruby-dev:47895] [Bug #9415] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: use actual encodingsnobu2014-01-151-23/+38
| | | | | | | | | * string.c (get_actual_encoding): get actual encoding according to the BOM if exists. * string.c (rb_str_inspect): use according encoding, instead of pseudo encodings, UTF-{16,32}. [ruby-core:59757] [Bug #8940] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN intoko12013-12-201-4/+4
| | | | | | | | | | | | RB_OBJ_WRITE and RB_OBJ_WRITTEN. * array.c, class.c, compile.c, hash.c, internal.h, iseq.c, proc.c, process.c, re.c, string.c, variable.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: use rb_fstring() for strings stored in the symbol tabletmm12013-12-081-2/+13
| | | | | | | | | | | | | | | | | * parse.y (register_symid_str): use fstrings in symbol table [Bug #9171] [ruby-core:58656] * parse.y (rb_id2str): ditto * string.c (rb_fstring): create frozen_strings on first usage. this allows rb_fstring() calls from the parser (before cString is created) * string.c (fstring_set_class_i): set klass on fstrings generated before cString was defined * string.c (Init_String): convert frozen_strings table to String objects after boot * ext/-test-/symbol/type.c (bug_sym_id2str): expose rb_id2str() * test/-ext-/symbol/test_type.rb (module Test_Symbol): verify symbol table entries are fstrings git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_scrub): [DOC] add param str.nobu2013-12-051-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix declaration-after-statementnobu2013-12-041-1/+2
| | | | | | | * string.c (fstr_update_callback): move a variable declaration since ISO C90 forbids mixed declarations and code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (fstr_update_callback): Improve implementation in r43968tmm12013-12-041-13/+14
| | | | | | | | based on feedback from @nagachika. In the existing case, we can return ST_STOP to prevent any hash modification. In the !existing case, set both key and value to the fstr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_fstring): Use st_update instead of st_lookup +tmm12013-12-031-15/+23
| | | | | | | st_insert. * string.c (fstr_update_callback): New callback for st_update. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_fstring): fstrings should be ELTS_SHARED.ko12013-11-281-1/+8
| | | | | | | | | | | If we resurrect dying objects (non-marked, but not swept yet), pointing shared string can be collected. To avoid such issue, fstrings (recorded to fstring_table) should not be ELTS_SHARED (should not have a shared string). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c: Use rb_fstring() to de-duplicate string literals in code. ↵tmm12013-11-261-0/+5
| | | | | | | | | | | [ruby-core:58599] [Bug #9159] [ruby-core:54405] * iseq.c (prepare_iseq_build): De-duplicate iseq labels and source locations. * re.c (rb_reg_initialize): Use rb_fstring() for regex string. * string.c (rb_fstring): Handle non-string and already-fstr arguments. * vm_eval.c (eval_string_with_cref): De-duplicate eval source filename. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix memsize of frozen shared stringnobu2013-11-261-1/+4
| | | | | | | * string.c (str_new4): copy the original capacity so that memsize of frozen shared string returns correct size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: do not use ruby_sized_xrealloc() and ruby_sized_xfree()ko12013-11-251-2/+1
| | | | | | | | | | | | | | | if HAVE_MALLOC_USABLE_SIZE (or _WIN32) is defined. We don't need these function if malloc_usable_size() is available. * gc.c: catch up this change. * gc.c: define HAVE_MALLOC_USABLE_SIZE on _WIN32. * array.c (ary_resize_capa): do not use ruby_sized_xfree() with local variable to avoid "unused local variable" warning. This change only has few impact. * string.c (rb_str_resize): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (rb_gc_resurrect): added.ko12013-11-191-1/+1
| | | | | | | | | | | | rb_fstring() used rb_gc_mark() to avoid freeing used string. However, rb_gc_mark() set mark bit *and* pushes mark_stack. rb_gc_resurrect() does only set mark bit if it is before sweeping. * string.c (rb_fstring): use rb_gc_resurrect. * internal.h: add decl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: constifynobu2013-11-171-1/+1
| | | | | | * string.c (tr_find): constify argument table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: move common string/hash flags to include file.tmm12013-11-111-11/+0
| | | | | | | | * ext/objspace/objspace_dump.c: remove flags shared above. * hash.c: ditto. * string.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (iseq_compile_each): emit opt_str_freeze if the #freezecharliesome2013-11-091-0/+1
| | | | | | | | | | | | | | | | | | | method is called on a static string literal with no arguments. * defs/id.def (firstline): add freeze so idFreeze is available * insns.def (opt_str_freeze): add opt_str_freeze instruction which pushes a frozen string literal without allocating a new object if String#freeze is not overriden * string.c (Init_String): define String#freeze * vm.c (vm_init_redefined_flag): define BOP_FREEZE on String class as a basic operation * vm_insnhelper.h: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: fix typonobu2013-11-011-1/+1
| | | | | | | * string.c (rb_str_scrub): fix typo, should yield invalid byte sequence to be scrubbed. reported by znz at IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: export rb_str_scrubnobu2013-11-011-10/+10
| | | | | | | * string.c (rb_str_scrub): export with fixed length arguments, and allow nil as replacement string instead of omitting. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (STR_HEAP_SIZE): includes TERM_LEN(str).ko12013-10-171-2/+2
| | | | | | | | * string.c (rb_str_memsize): use STR_HEAP_SIZE(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c, internal.h: rename ruby_xsizefree/realloc toko12013-10-171-5/+5
| | | | | | | | | | rb_sized_free/realloc. * array.c: catch up these changes. * string.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c, string.c: use ruby_xsizedfree() and ruby_xsizedrealloc().ko12013-10-171-6/+10
| | | | | | | | * internal.h (SIZED_REALLOC_N): define a macro as REALLOC_N(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e