Граф коммитов

1224 Коммитов

Автор SHA1 Сообщение Дата
ko1 6d8bf54c44 * string.c: introduce String#+@ and String#-@ to control
String mutability.
  [Feature #11782]




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-07 15:10:00 +00:00
nobu cae3905e89 string.c: should not taint fstring
* string.c (rb_obj_as_string): fstring should not be infected.
  re-apply r52872 and fix a typo.
  TODO: other frozen strings also may not be.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-04 07:48:22 +00:00
naruse f2532ab8ca Revert r52872 "string.c: should not taint fstring"
This reverts commit b887c7c20a.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-04 04:10:00 +00:00
nobu b887c7c20a string.c: should not taint fstring
* string.c (rb_obj_as_string): fstring should not be infected.
  TODO: other frozen strings also may not be.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-03 07:02:19 +00:00
nobu 0167fc15fb string.c: adjust argument qualifier
* string.c (str_make_independent_expand): adjust argument
  qualifier to get rid of a VC bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-02 00:45:32 +00:00
nobu d58f17f37d string.c: no frozen error at cstr
* string.c (rb_string_value_cstr): should not raise on frozen
  string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-01 08:13:43 +00:00
normal f9806460e9 string.c: use predefined IDs for minor bloat reduction
* string.c (id_to_s): remove redundant variable
  (rb_obj_as_string): trade id_to_s for idTo_s
  (rb_str_equal): replace rb_intern(...) with pre-defined ID
  (rb_str_cmp_m): ditto
  (rb_str_match): ditto
  (str_upto_each): ditto
  (rb_str_sum): ditto
  (Init_String): remove id_to_s initialization

This leads to a minor size reduction on my x86 (32-bit) system:

   text	   data	    bss	    dec	    hex	filename
 129373	      8	     32	 129413	  1f985	string.o-orig
 129082	      8	      8	 129098	  1f84a	string.o

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-07 03:18:58 +00:00
ko1 05b9b42918 * encoding.c (rb_enc_check_str): add for performance.
This function only accept T_STRING (and T_REGEXP).

  This patch improves performance of a tiny_segmenter benchmark
  (num=2) 2.54sec -> 2.42sec on my machine.
  https://github.com/chezou/TinySegmenter.jl/blob/master/benchmark/benchmark.rb

* encoding.c: add ENC_DEBUG and ENC_ASSERT() macros.

* internal.h: add a decl. of rb_enc_check_str().

* string.c (rb_str_plus): use rb_enc_check_str().

* string.c (rb_str_subpat_set): ditto.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 09:10:32 +00:00
nobu 645116ff25 RUBY_DTRACE_CREATE_HOOK
* internal.h (RUBY_DTRACE_CREATE_HOOK): macro to call hook at
  object creation.

* vm.c (rb_source_location, rb_source_loc): retrieve source path
  and line number at once.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 05:32:57 +00:00
ko1 56eee285be revert r52336 (commit miss)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 05:30:50 +00:00
ko1 106f033b89 * gc.c (gc_mark_ptr): remove debug code for #11244.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 05:10:06 +00:00
hsbt 26cd2da784 * string.c: Added method signature to include hash. It's inconsistency
with `gsub` method signature.
  [ci skip][fix GH-1023] Patch by @danielevans

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 06:46:15 +00:00
nobu bcc07ef4d1 fix backslash [ci skip]
* string.c (rb_str_tr): [DOC] Escape backslash in String#tr
  documentation.  [Fix GH-1063]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22 15:22:22 +00:00
nobu 78baa98e69 string.c: rb_str_cat_conv_enc_opts
* file.c (rb_file_expand_path_internal): concatenate converted
  string to the result instead of making converted string and
  append it.
* string.c (rb_str_cat_conv_enc_opts): from rb_str_conv_enc_opts,
  separate function to concatenate with transcoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-17 04:55:47 +00:00
nobu c2e8fb0f34 proc.c: proc without env
* proc.c (rb_sym_to_proc): move from string.c and create a Proc
  with no environments.  [ruby-core:71088] [Bug #11594]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-15 04:37:26 +00:00
ko1 e8ba0b7b04 * import a github pull request
https://github.com/ruby/ruby/pull/1050
  by Kazuho Oku <kazuho@natadeco.co>.
  This pull request has the following commits.
* gc.c: reduce # of args to 6 (max. of register args on x86-64) so
  that the `newobj_of_slowpass` can be called via TCO.
* gc.c (newobj_of), string.c (str_duplicate): for performance,
  the hot functions must be inlined.
* gc.c: for performance, preceding arguments of `.*newobj_of.*`
  must be same, so that the arg registers can be reused in case of
  TCO.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10 06:34:24 +00:00
nobu 89dde224d4 string.c: str_duplicate
* string.c (str_duplicate): move from rb_str_resurrect to short
  circuit initialization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07 12:32:54 +00:00
nobu 2c31c3b45e string.c: fix non-embedded string
* string.c (rb_str_resurrect): fix resurrection of short enough to
  be embedded but not embedded string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07 11:43:17 +00:00
nobu 9fe491e788 string.c: optimize String#times
* string.c (rb_str_times): optimize for the argument 0 and 1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07 08:31:22 +00:00
nobu 8f4e6f14d8 string.c: use raw macro
* string.c (str_new_frozen): use raw macro for RString object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07 08:30:20 +00:00
nobu aa4de7328d * string.c (rb_sym_to_proc): rename
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-06 07:35:52 +00:00
nobu ceddb49868 vm_args.c: wrap symbol ifunc
* vm_args.c (args_setup_block_parameter): wrap a symbol in ifunc
  by a proc as a block parameter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-06 06:38:08 +00:00
nobu 237332fcea string.c: optimize rb_str_resurrect
* string.c (rb_str_resurrect): optimize by short circuit to copy
  hidden string without checking length, encoding and so on.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 17:29:40 +00:00
nobu de2c8c9dbc * string.c (rb_sym_proc_call): constify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-01 10:51:09 +00:00
nobu 66296d3774 proc.c: include symbol name
* proc.c (proc_to_s): include the original symbol name in string
  form.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-30 06:36:11 +00:00
nobu ed8b452e37 compile.c: fix performance of strconcat
* compile.c (compile_dstr_fragments): fix performance by omitting
  the first empty string only for keeping literal encoding if
  other literals are too.  [ruby-core:70930] [Bug #11556]
* string.c (rb_str_append_literal): append but keep encoding non
  US-ASCII.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-29 07:37:40 +00:00
nobu 6177abcbf0 string.c: separate resetting code range
* string.c (rb_str_setbyte): separate resetting code range by each
  code range, and remove unnecessary branches.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-20 01:17:25 +00:00
nobu 965d8241c1 string.c: keep coderange
* string.c (rb_str_setbyte): keep the code range as possible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-16 05:50:00 +00:00
nobu 078b6c9838 encindex.h: ENCINDEX
* encindex.h: separate encoding index constants from internal.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15 05:49:20 +00:00
nobu 3e6742cffe string.c: move common statement
* string.c (sym_inspect): move common statement and change
  variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-22 06:45:44 +00:00
hsbt d5f479ca7e * string.c: Fix documentation for String#slice
[ruby-core:70298][Bug #11427]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11 02:56:23 +00:00
hsbt 8322c36a9b * string.c: [DOC] Make #end_with? example doc symmetry
with #start_with? [fix GH-992][ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11 01:58:47 +00:00
nobu f7ab090635 vm.c: frozen_strings in rb_vm_t
* vm.c (Init_vm_objects, rb_vm_fstring_table): use frozen_strings
  table in rb_vm_t.  [ruby-core:70274] [Bug #11423]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-09 05:15:57 +00:00
nobu fb25833690 node.c: NODE_ALLOCA for ALLOCV
* node.c (rb_alloc_tmp_buffer): use NODE_ALLOCA to mark locations
  like as builtin alloca.  [ruby-core:70251] [Bug #11418]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-05 17:25:35 +00:00
nobu 2c8986d23b re.c: fix for wide character encodings
* re.c (rb_memsearch): should match only char boundaries in wide
  character encodings.  [ruby-core:70220] [Bug #11413]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-03 01:08:36 +00:00
nobu 987df2ece6 hash.c: move rb_obj_hash
* hash.c (rb_obj_hash): move in order to share with rb_any_hash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29 08:25:49 +00:00
nobu 6f65a0ebf2 string.c: empty non-embed case
* string.c (str_buf_cat): consider empty non-embed string case,
  not to loop infinitely.  [ruby-core:70074] [Bug #11383]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29 07:00:25 +00:00
nobu 48f9012df9 hash.c: fix symbol hash
* hash.c (rb_sym_hash): return same value as rb_any_hash() of
  Symbol.  [Bug #9381]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29 05:54:21 +00:00
nobu 8101cc3de4 string.c: fill the terminator
* string.c (str_replace_shared_without_enc): fill the terminator
  of embedded strings in wide char encodings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25 02:05:34 +00:00
nobu 9e4b24d4f3 string.c: remove redundant call
* string.c (str_replace): remove redundant coderage copy as
  str_replace_shared already copys it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25 01:48:53 +00:00
nobu 502004f617 string.c: cmp orders
* string.c (fstring_cmp, rb_str_hash_cmp): compare lengths first,
  then encodings, and contents at last.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25 01:48:47 +00:00
nobu b706810232 string.c: fstring must not be a shared string
* string.c (fstr_update_callback): fstring must not be a shared
  string, or the content without RSTRING_FSTR may be freed.
  [ruby-dev:49188] [Bug #11386]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 12:27:32 +00:00
nobu 4ab69ebbd7 string.c: pool only bare strings in fstring
* string.c (fstr_update_callback): pool bare strings only.
* string.c (rb_fstring): return the original string with sharing a
  fstring if it has extra attributes, not the fstring itself.
  [ruby-dev:49188] [Bug #11386]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 07:38:37 +00:00
nobu f965866f4f string.c: new string for fake string
* string.c (fstr_update_callback): create new string for fake
  string, and pool shared target unless substring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23 05:14:53 +00:00
nobu 8ea11e8e1e string.c: trivial optimizations
* string.c (rb_str_new_frozen, str_make_independent_expand):
  trivial peephole optimizations.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23 05:14:35 +00:00
nobu 21dbe868f8 string.c: taint flags
* include/ruby/ruby.h: add raw FL macros, which assume always the
  argument object is not a special constant.
* internal.h (STR_EMBED_P, STR_SHARED_P): valid only for T_STRING.
* string.c: deal with taint flags directly across String instances.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23 01:25:49 +00:00
nobu 33f5edd5f3 string.c: str_shared_replace
* string.c (str_shared_replace): split from rb_str_shared_replace
  without argument check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23 01:16:46 +00:00
nobu 61d807ccfa string.c: fix coderange of reverse
* string.c (rb_str_reverse): reversed string is not a substring,
  and should not set coderange of the original string.
  [ruby-dev:49189] [Bug #11387]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22 14:44:20 +00:00
nobu 137d08de4b encoding.h: ENC_CODERANGE_CLEAN_P
* include/ruby/encoding.h (ENC_CODERANGE_CLEAN_P): predicate that
  tells if the coderange is clean, that is 7bit or valid, and no
  needs to scrub.
* re.c (rb_reg_expr_str): use ENC_CODERANGE_CLEAN_P.
* string.c (enc_strlen, rb_enc_cr_str_buf_cat, rb_str_scrub):
  ditto.
* string.c (rb_str_enumerate_chars): ditto, and suppress a warning
  by gcc6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17 06:39:29 +00:00
nobu ffd76ff3b5 string.c: remove redundant calls
* string.c (rb_str_enumerate_lines): do not check if a block is
  given twice.  RETURN_ENUMERATOR includes rb_block_given_p()
  check which is redundant here.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16 12:29:23 +00:00
nobu 4592e15e35 string.c: remove redundant calls
* string.c (rb_str_enumerate_bytes, rb_str_enumerate_codepoints):
  do not check if a block is given twice.  RETURN_SIZED_ENUMERATOR
  includes rb_block_given_p() check which is redundant here.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-15 01:29:37 +00:00
normal bbf7495fe2 string.c: ensure String#freeze resizes internal buffer
rb_str_freeze may resize oversized buffers to save memory, so favor
it over rb_obj_freeze.  This is useful because IO methods do not
prematurely shrink buffers, as they are likely to be overwritten
with full data.

* string.c (Init_String): use rb_str_freeze for String#freeze

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 19:45:02 +00:00
nobu 0918c27a40 string.c: register_fstring
* string.c (register_fstring): separate registration from
  rb_fstring().

* string.c (rb_fstring_new): skip argument checks in rb_fstring().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 02:24:29 +00:00
normal a12fb26ff7 string.c (rb_str_justify): use RB_GC_GUARD
See doc/extension.rdoc for justification using RB_GC_GUARD instead
of volatile.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24 07:17:44 +00:00
nobu d3199656be string.c: rb_fstring_cstr
* string.c (rb_fstring_cstr): new function to make a fstring from
  a string literal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24 03:50:56 +00:00
normal a02a3f4649 socket: allow explicit buffer for recv and recv_nonblock
This reduces GC overhead and makes the API more consistent
with IO#read and IO#read_nonblock.

* ext/socket/basicsocket.c (bsock_recv): document outbuf
* ext/socket/unixsocket.c (unix_recvfrom): ditto
* ext/socket/init.c (rsock_strbuf, recvfrom_locktmp): new functions
  (rsock_s_recvfrom): support destination buffer as 3rd arg
  (rsock_s_recvfrom_nonblock): ditto
* string.c (rb_str_locktmp_ensure): export for internal ext
* test/socket/test_nonblock.rb: test recv_nonblock
* test/socket/test_unix.rb: test recv
  [ruby-core:69543] [Feature #11242]

Benchmark results:

             user     system      total        real
alloc    0.130000   0.280000   0.410000 (  0.420656)
extbuf   0.100000   0.220000   0.320000 (  0.318708)

-------------------8<--------------------
require 'socket'
require 'benchmark'
nr = 100000
msg = ' ' * 16384
size = msg.bytesize
buf = ' ' * size
UNIXSocket.pair(:DGRAM) do |a, b|
  Benchmark.bmbm do |x|
    x.report('alloc') do
      nr.times do
        b.send(msg, 0)
        a.recv(size, 0)
      end
    end

    x.report('extbuf') do
      nr.times do
        b.send(msg, 0)
        a.recv(size, 0, buf)
      end
    end
  end
end

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-15 20:02:43 +00:00
hsbt 5ffb21ebbd * string.c: added documentation for character sequence \' with String#sub
[Bug #11132][ruby-core:69121][fix GH-900][ci skip] Patch by @shishir127

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16 12:41:29 +00:00
nobu 80e0ef3a81 range.c: move String specific code
* range.c (range_include): call rb_str_include_range_p on String.

* string.c (str_upto_each): extract from rb_str_upto.

* string.c (rb_str_include_range_p): move String specific code
  from Range#include? in range.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-15 12:39:56 +00:00
nobu d70228d105 string.c: all_digits_p
* string.c (all_digits_p): extract duplicate code from
  rb_str_upto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-15 09:06:25 +00:00
glass f64ac5d4cd * string.c (rb_str_crypt): Raise ArgumentError when
string passed to String#crypt contains null.
  the patch is from jrusnack <jrusnack at redhat.com>.
  [Bug #10988] [fix GH-853]

* test/ruby/test_string.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-10 02:49:01 +00:00
nobu 2b0a6f47ac revert r50336
* string.c (str_buf_cat): expand later so that the buffer can be
  larger for further use.  [Bug #11080] [Bug #11080]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-25 05:26:22 +00:00
nobu b3626b3ee7 string.c: expand heap
* string.c (str_buf_cat): expand the heap buffer at making
  str independent, not only just copying.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-17 03:26:21 +00:00
nobu 26fa27fe12 string.c: clear NOFREE flag at embedding
* string.c (STR_SET_EMBED): clear NOFREE flag at embedding as
  embedded strings no longer refer static strings.
  [ruby-core:68436] [Bug #10942]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-17 02:58:37 +00:00
nobu 8c0b2a2860 string.c: check before modify
* string.c (rb_str_setbyte): check the argument first not to
  discard shared string and code range unnecessarily until
  actually changing the contents.  pointed out by headius.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-04 02:30:26 +00:00
ko1 89a603d2e6 * string.c: add a comment about RSTRING_FSTR.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-18 03:08:09 +00:00
ko1 1e98a25e9f * string.c: introduce STR_FAKESTR to show string is FAKESTR or not.
* string.c (STR_SET_SHARED): ignore FAKESTR because only Ruby objects
  can use write barrier.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-17 20:38:02 +00:00
nobu 4c0106ead6 string.c: smart chomp
* string.c (chompped_length): enable smart chomp for all non-dummy
  encoding strings, not only default_rs.
  [ruby-core:68258] [Bug #10893]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-24 00:47:12 +00:00
nobu 4f3217e326 string.c: raise a RegexpError
* string.c (get_pat_quoted): simply raise a RegexpError, TypeError
  is never raised.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-23 06:26:59 +00:00
nobu a10fdc9270 string.c: proper exception
* string.c (rb_str_split_m): raise ArgumentError at broken string
  not RegexpError, as Regexp is not involved in.
  [ruby-core:68229] [Bug #10886]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-23 06:26:42 +00:00
nobu 16294913f7 use rb_funcallv
* use rb_funcallv() for no arguments call instead of variadic
  rb_funcall().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16 04:08:52 +00:00
mame 2270365bde * string.c (str_discard): does not free for STR_NOFREE string.
[Bug #10853][ruby-core:68110]

* bootstraptest/test_string.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-13 13:06:58 +00:00
marcandre af574c63b5 * string.c: [DOC] Specify to_s on subclasses [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-29 15:56:58 +00:00
nobu 44bf6684fd string.c: term fill
* string.c (str_buf_cat): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-26 03:43:20 +00:00
nobu c0d0dd91e5 string.c: use local variables
* string.c (str_buf_cat): use local variables instead of repeating
  macros.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-26 03:43:08 +00:00
nobu 34d4105556 string.c: consider widechar
* string.c (str_make_independent_expand): consider wide char
  encoding.  [Fix GH-821]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-26 02:39:00 +00:00
nobu 622f3f14b6 string.c: terminate when embedded
* string.c (str_make_independent_expand): terminate String when
  moved from heap to embedded.  [Fix GH-821].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-26 02:37:51 +00:00
ayumin e717341ea6 * string.c: improve docs for String#<=>. [ruby-core:65399][Feature #10322]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-04 04:10:31 +00:00
ayumin 6abaf76463 * string.c: improve docs for String#strip and variations. [ruby-core:66081][Bug #10476]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-04 03:37:10 +00:00
nobu 020fcc95fe string.c: fix coderange for non-endianness string
* string.c (rb_enc_str_coderange): dummy wchar, non-endianness
  encoding string cannot be ascii only.
  [ruby-core:66835] [Bug #10598]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-15 07:19:25 +00:00
nobu 4d3677e14b string.c: reduce intermediate string
* string.c (rb_str_succ_bang): get rid of making intermediate
  string object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 07:23:18 +00:00
nobu 3b8c100418 string.c: term fill
* string.c (rb_str_succ): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 02:24:51 +00:00
nobu b96ff20fef string.c: use local variables
* string.c (rb_str_succ): extract local variables from constant
  RSTRING_PTR and RSTRING_LEN.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 02:24:49 +00:00
nobu 01e621579a string.c: check arguments for crypt
* string.c (rb_str_crypt): check arguments more strictly.
  * crypt() is not for wide char strings
  * salt bytes should not be NUL

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 01:49:20 +00:00
nobu 9cabd72f5f string.c: term fill
* string.c (rb_str_justify): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 01:32:36 +00:00
nobu 88ae402cbf string.c: term fill
* string.c (tr_trans): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-12 01:20:41 +00:00
nobu 5c100b57f8 string.c: term fill
* string.c (rb_str_squeeze_bang): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-11 00:37:58 +00:00
nobu 7a77cf7133 string.c: term fill
* string.c (rb_str_delete_bang): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 12:26:11 +00:00
nobu 117438ee7b string.c: term fill
* string.c (rb_str_sub_bang): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 12:09:49 +00:00
nobu 9d17096309 string.c: term fill
* string.c (rb_str_splice_0): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 07:49:10 +00:00
nobu ed94c24944 string.c: term fill
* string.c (rb_str_chop_bang): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 07:48:56 +00:00
nobu c77efe1144 string.c: term fill
* string.c (rb_str_chomp_bang): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 07:48:48 +00:00
nobu 0c50d7ba15 string.c: term fill
* string.c (rb_str_times): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 07:48:43 +00:00
nobu c00aca4aa0 string.c: term fill
* string.c (rb_str_plus): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 07:48:34 +00:00
nobu b890ed926a string.c: local variables
* string.c (rb_str_plus, rb_str_splice_0): extract local
  variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 07:48:21 +00:00
nobu 516b9026fd string.c: chompped_length chomp_rs
* string.c (chompped_length, chomp_rs): extract from
  rb_str_chomp_bang to share with rb_str_chomp.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-10 07:48:17 +00:00
hsbt 93db27d51f * string.c: [DOC] Add missing documentation around String#chomp.
Patchby @stderr [ci skip][fix GH-780]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-09 11:24:46 +00:00
nobu 49b3b2d8a2 string.c: fake string is not sharing
* string.c (setup_fake_str): fake string does not share another
  string, but just should not free.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-03 05:34:10 +00:00
nobu aaed10716a intern.h: SIZED_ENUMERATOR
* include/ruby/intern.h (SIZED_ENUMERATOR): separate from
  RETURN_SIZED_ENUMERATOR.

* string.c (rb_str_enumerate_chars): get rid of calling
  rb_block_given_p() twice.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-03 03:25:12 +00:00
nobu 25bab786cb string.c: preserve encoding of global variable
* string.c (rb_str_setter): preserve encoding of global variable
  name in error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-23 17:03:48 +00:00
akr 2b9191e557 * internal.h: Gather declarations in non-header files.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 15:13:05 +00:00