summaryrefslogtreecommitdiff
path: root/string.c
AgeCommit message (Collapse)Author
2014-05-19string.c: byte offsetnobu
* string.c (rb_pat_search): advance by byte offset but not by char offset. [ruby-core:62669] [Bug #9849] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-19string.c: constifynobu
* string.c (rb_str_index): constify local pointer variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21* string.c (rb_str_coderange_scan_restartable): coderange is alwaysnaruse
ENC_CODERANGE_VALID if the string is ASCII-8BIT and already has a non ASCII character. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21* string.c (coderange_scan): remove useless condtion `p < e` afternaruse
search_nonascii. * string.c (rb_str_coderange_scan_restartable): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21* string.c (coderange_scan): remove unused logic.naruse
* string.c (rb_str_coderange_scan_restartable): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21string.c: rename rb_str_splice as rb_str_updatenobu
* string.c (rb_str_update): rename rb_str_splice as exported name rb_str_update, and make the former an alias macro of the latter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18string.c: SHARABLE_SUBSTRING_Pnobu
* string.c (SHARABLE_SUBSTRING_P): predicate if substring can be shared with the original string. true if just at the end of the original string, for the time being. all substring will be able to be shared in the future. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18string.c: share middle of a stringnobu
* string.c (rb_str_new_frozen): consider the shared string at middle. * string.c (rb_str_subseq, rb_str_substr, str_byte_substr): share middle of a string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18string.c: revert r45622nobu
* string.c (str_buf_cat): revert r45622. broken data can be added later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18string.c: r45621nobu
* string.c (str_buf_cat): revert r45621. this function does not scan appended data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18string.c: don't clear coderange at expandingnobu
* string.c (rb_str_modify_expand): like as str_modify_keep_cr, don't clear coderange unless broken. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18string.c: keep code rangenobu
* string.c (str_buf_cat): keep code range if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18* string.c: use uintptr_t instead of VALUE because they are not rubynaruse
object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18* string.c: check str_strlen's argument, and add comment ornaruse
use NULL if simply it uses str's enc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18* string.c (str_strlen): use enc_strlen if the coderange is known.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18* string.c (enc_strlen): move UTF-8 optimization from str_strlen tonaruse
enc_strlen. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17string.c: argument checknobu
* string.c (rb_str_cat_cstr): check the argument as other `_cstr` functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17string.c: rb_str_cat_cstrnobu
* string.c (rb_str_cat): make non-buf version main. * string.c (rb_str_cat_cstr): rename from rb_str_cat2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17string.c: alias of rb_str_buf_cat and rb_str_buf_cat2nobu
* string.c (rb_str_cat, rb_str_cat2): make aliases of rb_str_buf_cat and rb_str_buf_cat2 respectively. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17string.c: reduce duplicated codenobu
* string.c (rb_str_cat, rb_str_cat2): reduce duplicated code, they are same as rb_str_buf_cat and rb_str_buf_cat2 respectively now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-14string.c: reduce function callsnobu
* string.c (rb_enc_cr_str_buf_cat): reduce invariant function calls of rb_enc_from_index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-14string.c: keep source code rangenobu
* string.c (rb_enc_cr_str_buf_cat): keep code range of the source string even if code range of the destination string is unknown. no reason to the former is affected by the latter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-12string.c: clear env self in symbol procnobu
* 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
2014-04-09string.c: remove unnecessary terminator spacenobu
* 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
2014-04-09string.c: fix capacitynobu
* 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
2014-03-30* parse.y (rb_str_dynamic_intern): [DOC] move rdoc from rb_str_intern.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-28string.c: infect match resultnobu
* 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
2014-03-28string.c: backref substitutionnobu
* 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
2014-03-28string.c: unset $~ if unmatchnobu
* 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
2014-03-27string.c: suppress warningsnobu
* 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
2014-03-27string.c: search by rb_str_indexnobu
* 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
2014-03-27string.c: mustnot_brokennobu
* 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
2014-03-27string.c: invert flagnobu
* 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
2014-03-26* parse.y: support Symbol GC. [ruby-trunk Feature #9634]nari
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
2014-03-25Stop allocating backref strings within gsub's search loopcharliesome
* 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
2014-03-14[DOC] add links to `Object#hash`nobu
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
2014-03-14string.c: [DOC] rb_str_hash_mnobu
* 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
2014-02-27adjust indent and stylenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-25* string.c (sym_find): Add Symbol.find(str), which returns whether givennaruse
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
2014-02-14string.c (rb_str_format_m): trade volatile for RB_GC_GUARDnormal
* 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
2014-02-05* internal.h, vm_core.h: move LIKELY/UNLIKELY/UNINITIALIZED_VAR()ko1
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
2014-02-05* string.c (rb_str_free): use FL_TEST(str, STR_SHARED) directlyko1
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
2014-02-05* internal.h: remove macros STR_NOCAPA and STR_NOCAPA_P().ko1
* 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
2014-02-05* string.c: refactoring, especially about string flags.ko1
* 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
2014-02-05* string.c (RESIZE_CAPA): should not resize shared string.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05* string.c (rb_str_new_frozen): refactoring code.ko1
* 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
2014-02-04* string.c: use long allocator names instead of numberedko1
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
2014-02-04* string.c: use STR_SHARED instead of ELTS_SHARED.ko1
(same value, but more clear meaning) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-04* string.c: remvoe STR_ASSOC related code.ko1
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
2014-02-04pack.c: use ivar for associated objectsnobu
* 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