aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
Commit message (Collapse)AuthorAgeFilesLines
* * 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
* string.c: use str_duplicatenobu2013-10-101-1/+1
| | | | | | | * 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
* string.c: mark frozen stringnobu2013-10-091-0/+3
| | | | | | | | * 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
* * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().ko12013-09-251-1/+1
| | | | | | | | | | | | | | | 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
* string.c: fix for UTF-16/32nobu2013-09-241-4/+8
| | | | | | | | * 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
* string.c: scan coderangenobu2013-09-201-1/+1
| | | | | | | * 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
* * string.c (rb_str_enumerate_lines): make String#each_line andglass2013-09-181-64/+47
| | | | | | | | | | | | #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
* * string.c (fstring_cmp): take string encoding into account whencharliesome2013-09-051-2/+14
| | | | | | | | 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
* string.c: reduce objects in rb_fstringnobu2013-09-051-8/+11
| | | | | | | | | * 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
* * include/ruby/ruby.h: add RSTRING_FSTR flagcharliesome2013-09-051-0/+25
| | | | | | | | | | | | * 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
* string.c: fix for \Knobu2013-09-041-1/+1
| | | | | | | | | * 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
* string.c: rb_enc_str_new_cstrnobu2013-09-031-0/+13
| | | | | | | * 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
* dir.c: reduce string objectnobu2013-08-311-0/+6
| | | | | | * 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
* * string.c (rb_str_format_m): use RARRAY_RAWPTR() instead ofko12013-08-081-1/+1
| | | | | | | | 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
* * string.c: [DOC] Description of rb_str_equal [Fixes GH-375]zzak2013-08-071-3/+8
| | | | | | | | 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
* string.c: fix typonobu2013-08-061-1/+1
| | | | | | | * 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
* * string.c (str_rindex): remove comment.glass2013-08-011-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_rindex): fix bug introduced in r42269.glass2013-07-311-5/+6
| | | | | | | "".rindex("") should return 0. (str_rindex): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_rindex): performance improvement by usingglass2013-07-311-16/+61
| | | | | | memrchr(3). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_rindex): refactoring and avoid to call str_nth() ifglass2013-07-311-11/+17
| | | | | | pos == 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c: add internal API rb_str_locktmp_ensure().glass2013-07-281-0/+7
| | | | | | | | | * 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
* * string.c (rb_str_enumerate_chars): specify array capaglass2013-07-221-12/+14
| | | | | | | | 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
* * string.c (rb_str_enumerate_chars): specify array capa.glass2013-07-221-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_each_char_size): performance implement byglass2013-07-221-10/+1
| | | | | | using rb_str_length(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_succ): add missing case NEIGHBOR_WRAPPED.naruse2013-07-201-1/+8
| | | | | | 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
* string.c: wchar succnobu2013-07-201-2/+43
| | | | | | | | | * 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
* * string.c (str_alloc): no need to clear RString (already cleared).ko12013-07-181-5/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: char lengthnobu2013-07-141-2/+1
| | | | | | | * 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
* string.c: consider old terminatornobu2013-07-141-17/+18
| | | | | | | | * 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
* encoding.c: refill terminator at associating encodingnobu2013-07-121-9/+14
| | | | | | | | | | | * 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
* transcode.c: fill terminatornobu2013-07-111-0/+10
| | | | | | | * 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
* string.c: multi-byte terminatornobu2013-07-111-27/+44
| | | | | | | | | | | * 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
* string.c: multi-byte terminatornobu2013-07-111-1/+29
| | | | | | | | * 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
* string.c: check null charnobu2013-07-111-0/+20
| | | | | | | | * 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
* string.c: rb_str_subposnobu2013-07-101-1/+1
| | | | | | * string.c (rb_str_subpos): make public function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_index): cache single byte flag and someglass2013-07-101-9/+10
| | | | | | cosmetic changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add a missing line for rb_str_equal of string.c by @JuanitoFatas [fixes GH-353]hsbt2013-07-091-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_succ): use ONIGENC_MBCLEN_CHARFOUND_P correctly.naruse2013-07-041-4/+8
| | | | | | * string.c (rb_str_dump): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: use built-in encoding indexesnobu2013-07-021-24/+14
| | | | | | | | * internal.h: add UTF-{16,32} dummy encodings. * string.c (rb_str_inspect, str_scrub0): use built-in encoding indexes in internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert r41728naruse2013-07-011-18/+20
| | | | | | | | | * string.c (rb_str_inspect): use encoding index macros in encdb.h. It breaks build because encdb.h requires miniruby and modified miniruby requires encdb.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c (rb_str_inspect): use encoding index macros in encdb.h.naruse2013-07-011-20/+18
| | | | | | * string.c (str_scrub0): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c: coderange appending to empty stringnobu2013-07-011-2/+3
| | | | | | | | * string.c (rb_enc_cr_str_buf_cat, rb_str_append): consider an empty string 7bit-clean and should not discard cached coderange of string to be appended. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* intern.h: define rb_enumerator_size_funcnobu2013-06-261-2/+2
| | | | | | | | * include/ruby/intern.h (rb_enumerator_size_func): define strict function declaration for rb_enumeratorize_with_size(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h, vm_eval.c (rb_funcall_with_block):ktsj2013-06-171-2/+2
| | | | | | | | | | | | | | | | new function to invoke a method with a block passed as an argument. * string.c (sym_call): use the above function to avoid a block sharing. [ruby-dev:47438] [Bug #8531] * vm_insnhelper.c (vm_yield_with_cfunc): don't set block in the frame. * test/ruby/test_symbol.rb (TestSymbol#test_block_given_to_proc): run related tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e