summaryrefslogtreecommitdiff
path: root/string.c
AgeCommit message (Collapse)Author
2013-06-05* string.c (String#b): Allow code range scan to happen later soknu
ascii_only? on a result string returns the correct value. [ruby-core:55315] [Bug #8496] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-01string.c: remove old interfacesnobu
* string.c (rb_str_new[2-5], rb_{tainted,usascii}_str_new2), (rb_str_buf_new2): remove old interfaces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-24string.c: check argument typenobu
* string.c (rb_str_quote_unprintable): check if argument is a string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-20string.c: infectnobu
* string.c (rb_str_conv_enc_opts): should infect. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19fix typos. Patch by k_takata.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18* string.c (str_scrub0): added for refactoring.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18* string.c (str_scrub_bang): add String#scrub!. [Feature #8414]naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* string.c (rb_str_new_frozen): remove debug print.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* gc.c: support RGENGC. [ruby-trunk - Feature #8339]ko1
See this ticet about RGENGC. * gc.c: Add several flags: * RGENGC_DEBUG: if >0, then prints debug information. * RGENGC_CHECK_MODE: if >0, add assertions. * RGENGC_PROFILE: if >0, add profiling features. check GC.stat and GC::Profiler. * include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0). * array.c: add write barriers for T_ARRAY and generate sunny objects. * include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if you want to access raw pointers. If you modify the contents which pointer pointed, then you need to care write barrier. * bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects. * complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX and generate sunny objects. * rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write barriers for T_RATIONAL and generate sunny objects. * internal.h: add write barriers for RBasic::klass. * numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects. * object.c (rb_class_allocate_instance), range.c: generate sunny T_OBJECT objects. * string.c: add write barriers for T_STRING and generate sunny objects. * variable.c: add write barriers for ivars. * vm_insnhelper.c (vm_setivar): ditto. * include/ruby/ruby.h, debug.c: use two flags FL_WB_PROTECTED and FL_OLDGEN. * node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED): move flag bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* include/ruby/ruby.h: constify RBasic::klass and addko1
RBASIC_CLASS(obj) macro which returns a class of `obj'. This change is a part of RGENGC branch [ruby-trunk - Feature #8339]. * object.c: add new function rb_obj_reveal(). This function reveal interal (hidden) object by rb_obj_hide(). Note that do not change class before and after hiding. Only permitted example is: klass = RBASIC_CLASS(obj); rb_obj_hide(obj); .... rb_obj_reveal(obj, klass); TODO: API design. rb_obj_reveal() should be replaced with others. TODO: modify constified variables using cast may be harmful for compiler's analysis and optimizaton. Any idea to prohibt inserting RBasic::klass directly? If rename RBasic::klass and force to use RBASIC_CLASS(obj), then all codes such as `RBASIC(obj)->klass' will be compilation error. Is it acceptable? (We have similar experience at Ruby 1.9, for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)". * internal.h: add some macros. * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal object. * RBASIC_SET_CLASS(obj, cls) set RBasic::klass. * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS without write barrier (planned). * RCLASS_SET_SUPER(a, b) set super class of a. * array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c, file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c, parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c, string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c: Use above macros and functions to access RBasic::klass. * ext/coverage/coverage.c, ext/readline/readline.c, ext/socket/ancdata.c, ext/socket/init.c, * ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* *.c, parse.y, insns.def: use RARRAY_AREF/ASET macroko1
instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-09* string.c: Add call-seq alias for String#=== [Bug #8381]zzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24* string.c: Document String#setbyte return value by @gjmurakami-10genzzak
[Fixes GH-294] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-23* string.c (rb_str_inspect): refix r40413, on Ruby 1.9 usual characternaruse
escape uses hex/Unicode escapes, so fix to use Unicode escape on Unicode strings and hex on others. [ruby-core:54458] [Bug #8290] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-23string.c: fix for UTF-32nobu
* string.c (rb_str_scrub): fix for UTF-32. strlen() on strings contain NUL returns wrong result, use sizeof operator instead. [ruby-dev:45975] [Feature #6752] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-23string.c: suppress warningsnobu
* string.c (rb_str_scrub): suppress maybe-uninitialized and empty body in an else-statement. [ruby-dev:45975] [Feature #6752] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-23* string.c (rb_str_inspect): NUL should not be represented asknu
"\0" when octal digits may follow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-19Add example for String#scrubnaruse
[Feature #6321] [Feature #6752] [Bug #7967] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-19* string.c (str_scrub): add ruby method String#scrub which verify andnaruse
fix invalid byte sequence. * string.c (str_compat_and_valid): check given string is compatible and valid with given encoding. * transcode.c (str_transcode0): If invalid: :replace is specified for String#encode, replace invalid byte sequence even if the destination encoding equals to the source encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-14* string.c (String#gsub): fix typo in documentationeregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12* array.c: Document synonymous methods, by windwiny [GH-277]zzak
* bignum.c: ditto * complex.c: ditto * dir.c: ditto * encoding.c: ditto * enumerator.c: ditto * numeric.c: ditto * proc.c: ditto * re.c: ditto * string.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04reduce overhead of TYPEnobu
* array.c (ary_join_1): reduce overhead of TYPE(). * eval.c (rb_frozen_class_p, rb_mod_{append,prepend}_features): ditto. * string.c (rb_to_id): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-25string.c: performance improvementnobu
* string.c (rb_str_rpartition): get rid of conversion from byte offset to char offset and backward, for performance improvement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24* string.c (rb_str_rpartition): revert r39903, and convert byte offsetnaruse
to char offset; the return value of rb_reg_search is byte offset, but other than it of rb_str_rpartition expects char offset. [Bug #8138] [ruby-dev:47183] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24Fix String#rpartition(/re/) against a multibyte string.knu
* string.c (rb_str_rpartition): Fix String#rpartition(/re/) against a multibyte string. [Bug #8138] [ruby-dev:47183] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-21string.c: potential memory leaknobu
* string.c (rb_str_conv_enc_opts): allocate and hide wrapper before creating converter to be wrapped, to get rid of potential memory leak by failure on the allocation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-19convert with one converternobu
* string.c (rb_str_conv_enc_opts): convert with one converter, instead of re-creating converters for each buffer expansion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-25* string.c (str_byte_substr): don't set coderange if it's not known.naruse
[Bug #7954] [ruby-dev:47108] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-25string.c: STRING_ENUMERATORS_WANTARRAYnobu
* string.c (STRING_ENUMERATORS_WANTARRAY): name preprocessing codition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23* array.c: Document #<=> return values and formattingzzak
* bignum.c: ditto * file.c: ditto * object.c: ditto * numeric.c: ditto * rational.c: ditto * string.c: ditto * time.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-17compar.c: inversed comarison without infinite recursionnobu
* compar.c (rb_invcmp): compare by inversed comarison, with preventing from infinite recursion. [ruby-core:52305] [Bug #7870] * string.c (rb_str_cmp_m), time.c (time_cmp): get rid of infinite recursion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-31* string.c (rb_str_aset_m): Documentation for String#[]= fixzzak
Raises an IndexError if Regexp match is out of range. Github fixes #243 Patch by Dmtiriy Budnik git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-05* string.c (rb_str_enumerate_lines): fix invalid byte sequence errorglass
when a separator is passed. The patch is from yoshidam (Yoshida Masato). [Bug #7646] [ruby-dev:46827] * test/ruby/test_string.rb: a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25string.c: empty string is not invalidnobu
* string.c (rb_enc_cr_str_copy_for_substr): empty string is always valid or 7bit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25string.c: reduce duplicated codenobu
* string.c (rb_str_enumerate_lines, rb_str_chop): reduce duplicated code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25string.c: GC guardnobu
* string.c (rb_str_enumerate_chars): prevent shared copy from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-22internal.h: quote unprintablenobu
* internal.h (QUOTE, QUOTE_ID): quote unprintable chars in strings and IDs. [Bug #7574] [ruby-dev:46749] * string.c (rb_str_quote_unprintable): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-08* eval.c (rb_mod_refine), vm_eval.c (rb_yield_refine_block):shugo
Module#refine activates all refinements defined in that module only in a given block. * string.c (sym_to_proc, sym_call): don't use refinements. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01adjust style.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30string.c: compare with to_strnobu
* string.c (rb_str_cmp_m): try to compare with to_str result if possible before calling <=> method. [ruby-core:49279] [Bug #7342] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30string.c: use rb_check_funcallnobu
* string.c (rb_str_cmp_m): use rb_check_funcall instead of respond_to and call. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30string.c: always fixed valuenobu
* string.c (rb_str_cmp_m): return fixed value, one of -1,0,+1 always. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27* string.c (rb_str_enumerate_chars, rb_str_enumerate_codepoints)knu
(rb_str_enumerate_lines): Dummy initialization of ary has been replaced with UNINITIALIZED_VAR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27Suppress uninitialized variable warning with UNINITIALIZED_VAR()naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26string.c: suppress warningnobu
* string.c (rb_str_enumerate_bytes): suppress a uninitialized variable warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* string.c (rb_str_enumerate_chars, rb_str_enumerate_codepoints)kosaki
(rb_str_enumerate_lines): suppress "may be used uninitialized in this function" warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26string.c: suppress warningsnobu
* string.c (rb_str_enumerate_{lines,chars,codepoints}): suppress uninitialized variable warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24String#{lines,chars,codepoints,bytes} now return an array.knu
* string.c (rb_str_each_line, rb_str_lines): String#lines now returns an array instead of an enumerator. Passing a block is deprecated but still supported for backwards compatibility. Based on the patch by yhara. [Feature #6670] * string.c (rb_str_each_char, rb_str_chars): Ditto for String#chars. * string.c (rb_str_each_codepoint, rb_str_codepoints): Ditto for String#codepoints. * string.c (rb_str_each_byte, rb_str_bytes): Ditto for String#bytes. * NEWS: Add notes for the above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12* probes.d: add DTrace probe declarations. [ruby-core:27448]tenderlove
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe. * compile.c (rb_insns_name): allowing DTrace probes to access instruction sequence name. * Makefile.in: translate probes.d file to appropriate header file. * common.mk: declare dependencies on the DTrace header. * configure.in: add a test for existence of DTrace. * eval.c (setup_exception): add a probe for when an exception is raised. * gc.c: Add DTrace probes for mark begin and end, and sweep begin and end. * hash.c (empty_hash_alloc): Add a probe for hash allocation. * insns.def: Add probes for function entry and return. * internal.h: function declaration for compile.c change. * load.c (rb_f_load): add probes for `load` entry and exit, require entry and exit, and wrapping search_required for load path search. * object.c (rb_obj_alloc): added a probe for general object creation. * parse.y (yycompile0): added a probe around parse and compile phase. * string.c (empty_str_alloc, str_new): DTrace probes for string allocation. * test/dtrace/*: tests for DTrace probes. * vm.c (vm_invoke_proc): add probes for function return on exception raise, hash create, and instruction sequence execution. * vm_core.h: add probe declarations for function entry and exit. * vm_dump.c: add probes header file. * vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on function entry and return. * vm_exec.c: expose instruction number to instruction name function. * vm_insnshelper.c: add function entry and exit probes for cfunc methods. * vm_insnhelper.h: vm usage information is always collected, so uncomment the functions. 12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org> * configure.in (isinf, isnan): isinf() and isnan() are macros on DragonFly which cannot be found by AC_REPLACE_FUNCS(). This workaround enforces the fact that they exist on DragonFly. 12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org> * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo), vm_insnhelper.c (vm_search_method): revert r37616 because it's too slow. [ruby-dev:46477] * test/ruby/test_refinement.rb (test_inline_method_cache): skip the test until the bug is fixed efficiently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09siphashnobu
* random.c (rb_memhash): use siphash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e