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

1185 Коммитов

Автор SHA1 Сообщение Дата
duerst 2788cd9849 string.c: Added option parsing/checking for upcase/downcase/
capitalize/swapcase (with Kimihito Matsui

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-12 07:03:31 +00:00
nobu 2a4729a40d Fix rdoc for String#rstrip!, lstrip! [ci skip]
* string.c (rb_str_lstrip_bang, rb_str_rstrip_bang): [DOC] Fix
  ruby-doc comments for String#rstrip! and lstrip!.  It looks like
  dropped bang.  [Fix GH-1175]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-27 09:08:17 +00:00
yui-knk adc0898538 * string.c: Fix document. Default value of the first
argument of `String#split` is not `$;` but `nil`.
  When `nil` is passed as first argument, `$;` is used.
  [ci skip] [Bug #11729] [ruby-dev:49378]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-23 03:02:07 +00:00
nobu 9da8a29760 string.c: no exception on dummy encoding
* string.c (str_compat_and_valid): as scrub does nothing for dummy
  encoding string now, incompatible encoding is not a matter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-22 06:21:14 +00:00
nobu 61c19c9d43 string.c: infection
* string.c (rb_str_scrub): the result should be infected by the
  original string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-17 05:16:27 +00:00
nobu 365fae4dd9 string.c: radix indicators [ci skip]
* string.c (rb_str_oct): [DOC] mention radix indicators.
  [ruby-core:71310] [Bug #11648]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-15 04:49:59 +00:00
hsbt 52cd994814 * enum.c: fix a typo in documentation.
[ci skip][fix GH-1140] Patch by @jutaz
* io.c: ditto.
* iseq.c: ditto.
* numeric.c: ditto.
* process.c: ditto.
* string.c: ditto.
* vm_trace.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14 02:52:14 +00:00
naruse e3ab670a71 * object.c (rb_inspect): dump inspected result with rb_str_escape()
instead of raising Encoding::CompatibilityError. [Feature #11801]

* string.c (rb_str_escape): added to dump given string like
  rb_str_inspect without quotes and always dump in US-ASCII
  like rb_str_dump.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-10 18:57:08 +00:00
nobu cf183a58de string.c: use rb_id_encoding
* string.c (rb_str_init): rb_id_encoding() returns same ID with
  caching.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 23:41:27 +00:00
usa 4466d4baa9 * string.c (rb_str_init): now accepts new option parameter `encoding'.
[Feature #11785]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 16:48:52 +00:00
duerst d9c6135c5b string.c: removed unused variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 08:36:43 +00:00
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