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

863 Коммитов

Автор SHA1 Сообщение Дата
shugo bb50421381 * string.c (sym_to_proc, sym_call): A Proc created by Symbol#to_proc
should close over the current refinements.
  [ruby-dev:46345] [Bug #7261]

* vm_eval.c (rb_call0, rb_search_method_entry,
  rb_funcall_passing_block_with_refinements): add a new argument
  `refinements' for the above changes.

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-02 05:48:29 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
VALUE rb_newobj_of(VALUE klass, VALUE flags)
  #define NEWOBJ_OF(obj,type,klass,flags)
  These allow to change a allocation strategy depending on klass
  or flags.

* gc.c: ditto

* array.c: use new C API.
* bignum.c: ditto
* class.c: ditto
* complex.c: ditto
* ext/socket/ancdata.c: ditto
* ext/socket/option.c: ditto
* hash.c: ditto
* io.c: ditto
* marshal.c: ditto
* numeric.c: ditto
* object.c: ditto
* random.c: ditto
* range.c: ditto
* rational.c: ditto
* re.c: ditto
* string.c: ditto
* struct.c: ditto
  [Feature #7177][Feature #7047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 06:57:51 +00:00
nobu e808b2b18f string.c: GC guard
* string.c (rb_str_sub{seq,pos,str}, rb_str_each_{line,codepoint}):
  prevent String copies from GC.  [ruby-core:47881] [Bug #7135]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-11 14:09:49 +00:00
zzak 1b5ce61327 * string.c (rb_str_match):
Clarify behavior for captured strings and local variable assignment
  Patch by Marcus Stollsteimer [ruby-dev:47668] [Bug #7062]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-06 19:38:18 +00:00
naruse 64989fa5a2 * string.c (rb_str_concat): use memcpy to copy a string which contains
NUL characters. [ruby-core:47751] [Bug #7090]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-30 12:20:09 +00:00
nobu d28d075cc1 RB_TYPE_P BUILTIN_TYPE
* string.c, vm_insnhelper.c, vm_method.c: use RB_TYPE_P() and
  BUILTIN_TYPE() if possible.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-01 22:29:26 +00:00
drbrain 00730b5e49 * string.c (rb_str_sub): Fixed wording of documentation to match the
replacement operation.  Minor cleanup of markup.  [Bug #6719]
* string.c (rb_str_sub_bang):  Minor wording change for clarity, minor
  cleanup of markup.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-23 22:03:30 +00:00
nobu d744433225 rb_str_new_frozen: new object if tainted/untrusted unmatch
* string.c (rb_str_new_frozen): since the result object should have
  same tainted/untrusted bits with the original object, return new
  object if the shared object unmatch.  [ruby-core:39745][Bug #5374]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-12 02:44:27 +00:00
drbrain cd0971e27f * array.c (rb_ary_aref): Added a description of the behavior of
index positioning.  [Bug #6680]
* array.c (rb_ary_aset):  ditto.  Reordered sentences for clarity.
* string.c (rb_str_aref_m):  Added a description of the behavior of
  index positioning


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-05 21:50:13 +00:00
drbrain 9360721e58 * string.c (rb_str_bytesize): Improve documentation. Patch by Oscar
Del Ben from github issue #138.
* string.c (rb_str_empty):  ditto.
* string.c (rb_str_times):  ditto.
* string.c (rb_str_dump):  ditto.
* string.c (rb_str_center):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-05 20:39:15 +00:00
drbrain ab63d24b04 * array.c (rb_ary_aref): Updated documentation to indicate the
starting index is an index into the array or string.  Updated
  examples to show behavior of indexes at the end of an array or
  string.  Based on patch by Marcus Stollsteimer.  [Bug #6680]
* array.c (rb_ary_aset):  ditto.
* string.c (rb_str_aref):  ditto.  Also added descriptive argument
  names to call-seq section.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-03 23:29:56 +00:00
nobu ffa20cf154 use rb_check_hash_type
* class.c (rb_scan_args): use rb_check_hash_type.
* process.c (rb_exec_getargs): ditto.
* sprintf.c (get_hash): ditto.
* string.c (rb_str_sub_bang, str_gsub): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-26 07:46:24 +00:00
nobu 3137b0819d rb_str_subpos
* string.c (rb_str_subpos): split from rb_str_substr.  returns
  adjusted position for substring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-18 08:10:13 +00:00
nobu f64e7c834f string.c: rb_str_symname_p
* string.c (rb_str_symname_p): new function that checks if the string
  is valid as a symbol name.  split from sym_inspect().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-09 14:36:17 +00:00
drbrain 9fa6147b9c * string.c (rb_str_start_with): Removed "p" from start_with? examples
to match other String method examples.  [ruby-trunk - Bug #6553]
* string.c (rb_str_end_with):  Updated end_with? to use code markup
  instead of italic.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 23:09:56 +00:00
naruse 70be643c5b Fix previous commit, it means not need to make the condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-02 08:52:55 +00:00
naruse 7671e7dd35 * string.c (rb_enc_cr_str_buf_cat): don't reset coderange as unknown.
the condition 'ptr_a8 && str_cr != ENC_CODERANGE_7BIT' means not
  unknown, str is also ASCII-8BIT because str_encindex == ptr_encindex,
  and nont (str_cr == ENC_CODERANGE_UNKNOWN) and
  str_cr != ENC_CODERANGE_7BIT means str_cr is valid because ASCII-8BIT
  can't be broken. [ruby-dev:45688] [Bug #6509]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-02 08:02:23 +00:00
nobu b0dd250dc9 use RB_TYPE_P() instead of comparison of TYPE()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-23 07:13:21 +00:00
naruse 2053b5f453 * enc/shift_jis.c (code_to_mbclen): return
ONIGERR_INVALID_CODE_POINT_VALUE if the code is invalid.

* enc/shift_jis.c (tr_next): increment character until the code
  is a valid character. [ruby-dev:45652] [Bug #6450]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-20 13:32:16 +00:00
drbrain e95f7ea80d * variable.c (trace_ev): Removed "not reached" comment as this line is
reached.
* variable.c (rb_obj_remove_instance_variable):  Replaced "not reached"
  comment with the UNREACHABLE macro.
* variable.c (rb_mod_const_missing):  ditto.
* variable.c (rb_mod_remove_cvar):  ditto.
* enum.c (first_i):  ditto.
* string.c (rb_str_aref):  ditto.
* string.c (str_byte_aref):  ditto.
* string.c (rb_to_id):  ditto.
* io.c (rb_io_fmode_modestr):  ditto.
* io.c (rb_io_oflags_modestr):  ditto.
* pack.c (num2i32):  ditto.
* vm_eval.c (rb_method_missing):  ditto.
* vm_eval.c (rb_f_throw):  ditto.
* dir.c (dir_read):  ditto.
* win32/win32.c (child_result):  ditto.
* struct.c (rb_struct_getmember):  ditto.
* struct.c (rb_struct_set):  ditto.
* struct.c (rb_struct_aref_id):  ditto.
* eval.c (rb_f_raise):  ditto.
* process.c (rb_f_exit_bang):  ditto.
* process.c (rb_f_exit):  ditto.
* process.c (rb_f_abort):  ditto.
* ext/-test-/iter/break.c (iter_break_value):  ditto.
* ext/pty/pty.c (pty_check):  ditto.
* ext/openssl/ossl_pkey.c (ossl_pkey_new):  ditto.
* ext/readline/readline.c (rb_remove_history):  ditto.
* ext/stringio/stringio.c (strio_unimpl):  ditto.
* numeric.c (num_sadded):  ditto.
* numeric.c (num_init_copy):  ditto.
* numeric.c (rb_num2ll):  ditto.
* numeric.c (rb_num2ull):  ditto.
* vm_insnhelper.c (call_cfunc):  ditto.
* ruby.c (opt_W_getter):  ditto.
* bignum.c (rb_big_coerce):  ditto.
* file.c (rb_f_test):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-14 00:36:26 +00:00
drbrain 38ce9797c1 * string.c (rb_str_tr): Documented use of \ to escape characters.
[ruby-trunk - Bug #6161]
* string.c (rb_str_count):  ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-10 21:11:37 +00:00
drbrain e5c418d991 * string.c (rb_str_split_m): Documented behavior of split on the empty
string.  [ruby-trunk - Feature #3575]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-10 00:57:40 +00:00
nobu 38b8afcf5a * string.c (rb_str_start_with, rb_str_end_with): raise an error if
an argument is not convertible to a String.
  [ruby-core:40623][Bug #5536]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-02 01:34:11 +00:00
nobu ab9c982cc0 * string.c (str_new_empty): should copy also the encoding as an
empty substring.  [ruby-dev:45441][Bug #6206]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-27 04:13:54 +00:00
naruse 73a184cc3a * string.c (tr_setup_table): fix multiple non latin argument for
non latin (over 256 characters) tr-like methods.
  [ruby-core:43371] [Bug #6167]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-25 09:20:04 +00:00
nobu 163ab0a4da * bignum.c (rb_str_to_inum): must be ASCII compatible encoding as
well as String#hex and String#oct.  [ruby-core:43566][Bug #6192]
* string.c (rb_must_asciicompat): check if ASCII compatible.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-23 04:19:24 +00:00
kazu ea6511c63a * string.c (trnext): fix bug with string ending with '\\'.
[ruby-dev:45374][Bug #6160]

* test/ruby/test_string.rb (TestString#test_delete): test for
  above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 16:49:44 +00:00
nobu ba20fe6289 * string.c (trnext): should advance char-wise.
[ruby-core:43335][Bug #6156]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 11:06:27 +00:00
nobu 65fcaf4113 * string.c (rb_str_conv_enc_opts): default to original encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 05:49:34 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00
marcandre 8a4de7abf8 * string.c (rb_str_aref): Improve rdoc, as per [bug #6106]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-06 04:09:04 +00:00
naruse 697b53d8a9 * ext/bigdecimal/lib/bigdecimal/math.rb: remove description about
BigMath#log. patched by Sho Hashimoto [ruby-dev:45307] [Bug #6112]

* string.c (str_byteslice): fix typo.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-05 02:53:36 +00:00
knu 9f0de403c5 Paranoia: /^/ -> /\A/ in regexp in rdoc. Pointed out by nobu.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-27 15:11:00 +00:00
knu 34205bc4ec * string.c (rb_str_crypt): Update rdoc and state that this
function is system dependent.  Reviewed by nobu, thanks to
  @takai.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-27 08:07:24 +00:00
ayumin 7e76ab5e5e * string.c (rb_str_prepend): Fix documentation for String#prepend.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-24 02:56:30 +00:00
nobu 83c7d9df2b * string.c (rb_str_modify_expand): fix memory leak.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-08 13:30:04 +00:00
ngoto c5831f3926 * string.c (rb_str_concat): set array element after definition
to fix compile error with Fujitsu C Compiler 5.6 on Solaris 10
  on Sparc.  [Bug #5878] [ruby-dev:45123]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-11 15:00:57 +00:00
naruse 800f04c6a5 * numeric.c (rb_enc_uint_char): raise RangeError when added codepoint
is invalid. [Feature #5855] [Bug #5863] [Bug #5864]

* string.c (rb_str_concat): ditto.

* string.c (rb_str_concat): set encoding as ASCII-8BIT when the string
  is US-ASCII and the argument is an integer greater than 127.

* regenc.c (onigenc_mb2_code_to_mbclen): rearrange error code.

* enc/euc_jp.c (code_to_mbclen): ditto.

* enc/shift_jis.c (code_to_mbclen): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08 20:42:45 +00:00
nobu 460528289a * string.c (str_nth_len): count ascii-only run at the end. this
bug appears only when single-byte-optimization is disabled due
  to unknown coderange.  [ruby-core:41896] [Bug #5836]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-04 05:24:39 +00:00
nobu 413f24d3b0 * whitespace cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-04 07:19:23 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
naruse f4dda52025 * string.c (tr_trans): free heap ptr when the str is not embeded.
patched by Eric Wong. [Bug #4956] [ruby-core:37708]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-01 05:28:48 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
mrkn 30a87f3535 * string.c: Fix the ambiguous description of the behavior of
rb_str_aref_m with a range.  It returns nil when the beginning of
  the range is greater than the end of the string rather than the range.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-09 09:39:47 +00:00
ryan 172af01255 Clarified String#tr rdoc. (RickHull)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01 22:29:09 +00:00
kosaki 724b1c60dc * string.c (rb_str_bytesize): rb_str_bytesize() should use LONG2NUM().
Patch by Nikolai Weibull. [Bug #4789] [ruby-core:36511]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 17:23:30 +00:00
naruse 140e1f0b15 * string.c: Improve documentation for String#start_with? and
String#end_with?. fixes #4652
  patched by Andrew Grimm <andrew.j.grimm at gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-09 09:35:27 +00:00
kosaki 8ff8d61961 * string.c (rb_to_id): remove unused variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-24 16:04:31 +00:00
naruse 88014987ad * string.c (rb_str_each_line): check string's length when compare
separator and string. [ruby-core:35815] fixes #4586

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-20 05:43:27 +00:00
matz 1df42597d1 cancel subversion backfire. sorry
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-07 08:44:45 +00:00