summaryrefslogtreecommitdiff
path: root/string.c
AgeCommit message (Collapse)Author
2013-12-05* string.c (rb_str_scrub): [DOC] add param str.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-04string.c: fix declaration-after-statementnobu
* 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
2013-12-04* string.c (fstr_update_callback): Improve implementation in r43968tmm1
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
2013-12-03* string.c (rb_fstring): Use st_update instead of st_lookup +tmm1
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
2013-11-28* string.c (rb_fstring): fstrings should be ELTS_SHARED.ko1
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
2013-11-26* compile.c: Use rb_fstring() to de-duplicate string literals in code. ↵tmm1
[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
2013-11-26string.c: fix memsize of frozen shared stringnobu
* 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
2013-11-25* internal.h: do not use ruby_sized_xrealloc() and ruby_sized_xfree()ko1
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
2013-11-19* gc.c (rb_gc_resurrect): added.ko1
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
2013-11-17string.c: constifynobu
* string.c (tr_find): constify argument table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-11* internal.h: move common string/hash flags to include file.tmm1
* 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
2013-11-09* compile.c (iseq_compile_each): emit opt_str_freeze if the #freezecharliesome
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
2013-11-01string.c: fix typonobu
* 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
2013-11-01string.c: export rb_str_scrubnobu
* 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
2013-10-17* string.c (STR_HEAP_SIZE): includes TERM_LEN(str).ko1
* 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
2013-10-17* gc.c, internal.h: rename ruby_xsizefree/realloc toko1
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
2013-10-17* array.c, string.c: use ruby_xsizedfree() and ruby_xsizedrealloc().ko1
* 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
2013-10-10string.c: use str_duplicatenobu
* string.c (rb_str_resurrect): use str_duplicate(), which does completely same. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-09string.c: mark frozen stringnobu
* string.c (rb_fstring): because of lazy sweep, str may be unmaked already and swept at next time, so mark it for the time being. [ruby-core:57756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().ko1
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and usecase of this macro is not acquire raw pointer, but acquire read-only pointer. So we rename to better name. RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR() (I expect that nobody use it). * array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c, string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-24string.c: fix for UTF-16/32nobu
* string.c (rb_str_inspect): get rid of out-of-bound access. * string.c (rb_str_inspect): when a UTF-16/32 string doesn't have a BOM, inspect as a dummy encoding string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-20string.c: scan coderangenobu
* string.c (rb_str_conv_enc_opts): make sure to scan coderange to get rid of unnecessary conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-18* string.c (rb_str_enumerate_lines): make String#each_line andglass
#lines not raise invalid byte sequence error when it is called with an argument. The patch also causes performance improvement. [ruby-dev:47549] [Bug #8698] * test/ruby/test_m17n_comb.rb (test_str_each_line): remove assertions which check that String#each_line and #lines will raise an error if the receiver includes invalid byte sequence. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-05* string.c (fstring_cmp): take string encoding into account whencharliesome
comparing fstrings [ruby-core:57037] [Bug #8866] * test/ruby/test_string.rb: add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-05string.c: reduce objects in rb_fstringnobu
* string.c (rb_fstring, rb_str_free): use st_data_t instead of VALUE. * string.c (rb_fstring): get rid of duplicating already frozen object. * parse.y (str_suffix_gen): freeze in advance to reduce objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-05* include/ruby/ruby.h: add RSTRING_FSTR flagcharliesome
* internal.h: add rb_fstring() prototype * parse.y (str_suffix_gen): deduplicate frozen string literals * string.c (rb_fstring): deduplicate frozen string literals * string.c (rb_str_free): delete fstrings from frozen_strings table when they are GC'd * string.c (Init_String): initialize frozen_strings table * test/ruby/test_string.rb: test frozen strings are deduplicated git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04string.c: fix for \Knobu
* string.c (str_gsub): use BEG(0) for whole matched position not return value from rb_reg_search(), for \K matching. [ruby-dev:47694] [Bug #8856] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-03string.c: rb_enc_str_new_cstrnobu
* string.c (rb_enc_str_new_cstr): new function to create a string from the C-string pointer with the specified encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31dir.c: reduce string objectnobu
* dir.c (dir_each): get rid of allocate new string from UTF-8 string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-08* string.c (rb_str_format_m): use RARRAY_RAWPTR() instead ofko1
RARRAY_PTR() because there is no new reference. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07* string.c: [DOC] Description of rb_str_equal [Fixes GH-375]zzak
Based on a patch by @markijbema https://github.com/ruby/ruby/pull/375 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06string.c: fix typonobu
* string.c (rb_str_ellipsize): [DOC] fix typo, "encoding" instead of "encoded" which is probably a slip of the auto-completion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01* string.c (str_rindex): remove comment.glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31* string.c (rb_str_rindex): fix bug introduced in r42269.glass
"".rindex("") should return 0. (str_rindex): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31* string.c (rb_str_rindex): performance improvement by usingglass
memrchr(3). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31* string.c (rb_str_rindex): refactoring and avoid to call str_nth() ifglass
pos == 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28* string.c: add internal API rb_str_locktmp_ensure().glass
* io.c (io_fread): use rb_str_locktmp_ensure(). [ruby-core:56121] [Bug #8669] * test/ruby/test_io.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22* string.c (rb_str_enumerate_chars): specify array capaglass
with str_strlen(). * string.c (rb_str_enumerate_codepoints): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22* string.c (rb_str_enumerate_chars): specify array capa.glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22* string.c (rb_str_each_char_size): performance implement byglass
using rb_str_length(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20* string.c (rb_str_succ): add missing case NEIGHBOR_WRAPPED.naruse
r42078 caused buggy behavior like "\xFF".b -> "\x01\xFF".b git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20string.c: wchar succnobu
* string.c (enc_succ_char, enc_pred_char): consider wchar case. [ruby-core:56071] [Bug #8653] * string.c (rb_str_succ): do not replace with invalid char. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18* string.c (str_alloc): no need to clear RString (already cleared).ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-14string.c: char lengthnobu
* string.c (str_null_char): calculate char length. fix commit miss at r41967. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-14string.c: consider old terminatornobu
* string.c (str_fill_term): consider old terminator length, and should not use rb_enc_ascget since it depends on the current encoding which may not be compatible with the new terminator. [Bug #8634] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-12encoding.c: refill terminator at associating encodingnobu
* encoding.c (rb_enc_associate_index): refill the terminator if it becomes longer than before. [ruby-dev:47500] [Bug #8624] * string.c (str_null_char, str_fill_term): get rid of out of bound access. * string.c (rb_str_fill_terminator): add a parameter for the length of new terminator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11transcode.c: fill terminatornobu
* transcode.c (str_encode_associate): fill terminator after conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11string.c: multi-byte terminatornobu
* string.c (rb_enc_str_new, rb_str_set_len, rb_str_resize): fill minimum length of the encoding as the terminator. * string.c (str_buf_cat, rb_str_buf_append, rb_str_splice_0): ditto. * string.c (str_make_independent_expand, rb_str_modify_expand): make the capacity enough for multi-byte terminator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11string.c: multi-byte terminatornobu
* string.c (rb_string_value_cstr): fill minimum length of the encoding as the terminator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11string.c: check null charnobu
* string.c (rb_string_value_cstr): check null char in char, not in byte. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e