Commit graph

290 commits

Author SHA1 Message Date
knu
05a579c9ec Forward port r34151 from ruby_1_8_7.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@34379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-26 07:10:03 +00:00
nobu
2102e6443a * string.c (rb_str_partition, rb_str_rpartition)
(rb_str_start_with, rb_str_end_with): preserve the last match
  data.  [ruby-core:39671] [Bug #5351]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@33527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-26 07:05:42 +00:00
nobu
09267569c3 * string.c (rb_string_value_cstr): make NUL terminated if it is
not done.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-04-14 06:58:13 +00:00
matz
255ef3ccac * string.c (rb_str_times): backport r15514 to reduce loop
overhead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-10 04:05:15 +00:00
naruse
185ed6e270 * string.c (rb_str_split): add rdoc.
patched by Hugh Sasse [ruby-core:27819]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-25 17:27:50 +00:00
knu
25e036d5aa * string.c: Add instance methods to Symbol: succ, next, <=>,
casecmp, =~, [], slice, length, size, empty?, match, upcase,
  downcase, capitalize and swapcase. [backport from 1.9]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-31 15:40:46 +00:00
usa
d0c1160f73 * string.c (rb_str_inspect): wrong result of UTF-8 inspect because of
the mistake of calculation.  reported by eban via IRC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-15 02:50:07 +00:00
marcandre
ea1b7a9577 * time.c: rdoc fix for <=>
* array.c: ditto

* bignum.c: ditto

* compar.c: ditto

* file.c: ditto

* numeric.c: ditto

* string.c: rdoc fix for <=> and casecmp

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-28 05:01:29 +00:00
nobu
20a2b656c2 * string.c (rb_str_inspect): get rid of adding garbage to short
UTF-8 string.  [ruby-dev:39550]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-27 13:05:48 +00:00
nobu
3f0d0b9398 * *.[chy]: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@25430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-22 01:00:18 +00:00
knu
e8b0f17319 * array.c (ary_resize_capa): Remove an unused function.
* array.c, bignum.c, dir.c, enumerator.c, gc.c, io.c, numeric.c,
  object.c, re.c, string.c, struct.c: Mixing two styles is not a
  good thing.  Stick with the K&R style in 1.8.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-23 12:07:23 +00:00
knu
f1f12658ee * array.c (Array#try_convert): New method backported from 1.9.
* hash.c (Hash#try_convert): New method backported from 1.9.

* io.c (IO#try_convert): New method backported from 1.9.

* re.c (Regexp#try_convert): New method backported from 1.9.

* string.c (String#try_convert): New method backported from 1.9.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@23018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-20 09:43:24 +00:00
nobu
b249fb0bad * string.c (get_arg_pat): no second parameter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@22369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-17 03:53:53 +00:00
nobu
c9524768d4 * string.c (rb_str_shared_replace): no need for
str_make_independent.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@22368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-17 03:50:59 +00:00
knu
3d5cdfec1c * string.c (rb_str_each): Add a deprecation warning to
String#each.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-17 10:57:16 +00:00
nobu
8c0efdc182 * string.c (rb_str_cmp_m): fixed rdoc. pointed out by <Thomas
C. Mitchell AT gmail.com> at [ruby-talk:321967]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-05 01:01:53 +00:00
knu
0543873335 * string.c (rb_str_getbyte, rb_str_setbyte): Add String#getbyte
and String#setbyte for the forward compatibility with 1.9, where
  the behavior of String#[] and String#[]= have changed; based on
  a patch from Shinichiro Hamaji in  [ruby-dev:37247].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-03 07:23:09 +00:00
nobu
d5a75a3550 * string.c (str_independent): no independent string points null_str.
[ruby-core:20082]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-25 07:09:39 +00:00
nobu
23572d3cfa * string.c (rb_str_s_alloc, rb_str_replace): use null_str as well as
rb_string_value so that extension libraries do not segfault.
  [ruby-core:19971]

* string.c (rb_str_replace): reduced unnecessary malloc and copy.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-19 08:52:41 +00:00
nobu
3cc0976f7a * string.c (rb_str_succ): reverted previous changes. [ruby-dev:35389]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-09 13:11:39 +00:00
nobu
f5113b5731 * string.c (rb_str_succ): alphabets or numerics mutually enclosing
non-alphanumeric characters can carry up.  e.g., "1.999".succ should
  be "2.000".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-08 16:38:40 +00:00
nobu
f04db2b4cf * string.c (rb_str_succ): limit carrying in an alphanumeric region if
exists.  [ruby-dev:35094]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-07 15:23:01 +00:00
akr
19c818ca57 * string.c (rb_str_format_m): make tmp volatile to avoid possible GC
problem.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-29 14:03:38 +00:00
nobu
6f42fdc564 * string.c (str_buf_cat): check for self concatenation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-21 22:16:45 +00:00
nobu
8bb1dbdc25 * string.c (rb_str_buf_append): should infect.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 09:16:03 +00:00
nobu
3db4641b2a * array.c (rb_ary_store, rb_ary_splice): not depend on unspecified
behavior at integer overflow.

* string.c (str_buf_cat): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 06:42:07 +00:00
shyouhei
4a3f1dfb58 * array.c (ary_new, rb_ary_initialize, rb_ary_store,
rb_ary_aplice, rb_ary_times): integer overflows should be
  checked. based on patches from Drew Yao <ayao at apple.com>
  fixed CVE-2008-2726

* string.c (rb_str_buf_append): fixed unsafe use of alloca,
  which led memory corruption. based on a patch from Drew Yao
  <ayao at apple.com> fixed CVE-2008-2726

* sprintf.c (rb_str_format): backported from trunk.

* intern.h: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-19 23:12:46 +00:00
nobu
397ee1a315 * eval.c (rb_thread_select), string.c (str_gsub): suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-10 04:40:40 +00:00
nobu
9ed3d64d1d * suppress warnings on cygwin, mingw and mswin.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-01 19:55:25 +00:00
nobu
1378795e08 * suppress warnings with -Wwrite-string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00
knu
08b38ab3d6 * string.c (rb_str_start_with): Remove an unused variable.
(rb_str_upto_m): Fix a prototype.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-28 08:54:55 +00:00
knu
187a7b0b05 * range.c (range_step): Fix brokenness when a non-integer numeric
value is specified as step. [rubyspec]
  (range_step): Make use of String#step internally if a string (or
  string-alike) range is given.

* string.c (rb_str_upto_m, Init_String): Add an optional second
  argument to specify if the last value should be included.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-28 08:51:07 +00:00
knu
c1b8f48041 * string.c (Init_String): Define #bytesize as an alias for #size
for compatibility with 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-15 08:02:47 +00:00
matz
28693296b7 * string.c (rb_str_cat): fixed buffer overrun reported by
Christopher Thompson <cthompson at nexopia.com> in [ruby-core:16746]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-13 01:19:41 +00:00
matz
7f9f8d381e * string.c (rb_str_each_line): RDoc updated. [ruby-dev:34586]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-10 09:20:28 +00:00
knu
e926ef5233 * random.c (rb_genrand_int32, rb_genrand_real), intern.h: Export.
* string.c (rb_str_tmp_new), intern.h: New function.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 10:52:17 +00:00
knu
f5f1a18ceb * enum.c (enum_find, enum_reject): Return an enumerator if no
block is given.

* io.c (rb_io_each_line, rb_io_each_byte, rb_io_s_foreach,
  argf_each_line, argf_each_byte): Ditto.

* string.c (str_gsub): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 09:19:52 +00:00
knu
60dde833c3 * string.c (rb_str_each_char): New methods: String#chars and
#each_char.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 05:01:30 +00:00
knu
9fb81662b5 * string.c (rb_str_each_line, rb_str_each_byte): Reflect
enumerator integration.  #lines and #bytes are now aliases to
  #each_line and #each_byte, respectively.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 04:44:01 +00:00
knu
7d848354f8 * string.c (rb_str_partition, rb_str_rpartition,
rb_str_start_with, rb_str_end_with): New methods:
  String#partition, #rpartition, #start_with? and #end_with?;
  backported from 1.9.  These methods are $KCODE aware unlike
  #index, #rindex and #include?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-14 04:16:23 +00:00
nobu
5982102848 * string.c (rb_str_lines, rb_str_bytes): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@14728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-27 02:02:47 +00:00
nobu
9e1da70e14 * intern.h, string.c (rb_str_set_len): added for upgrading path from
1.8 to 1.9. [ruby-dev:32807]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@14727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-27 02:01:24 +00:00
matz
015014380b * string.c (rb_str_to_i): update RDoc since base can be any value
between 2 and 36.  [ruby-talk:272879]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-06 14:17:55 +00:00
shyouhei
a32a1b7a03 Sorry nobu, reverting r13473, which turned out to be a SEGV-generator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-23 08:20:11 +00:00
nobu
b21b9a46cf * string.c (str_alloc): defaults to null_str instead of NULL.
[ruby-dev:31774]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-20 16:46:21 +00:00
matz
bf0c93851a * string.c (rb_str_splice): integer overflow for length.
[ruby-dev:31739]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-05 13:18:23 +00:00
nobu
8af410bdb5 * string.c (rb_str_rindex_m): accept string-like object convertible
with #to_str method, as well as rb_str_index_m.  [ruby-core:11692]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-16 09:29:35 +00:00
usa
915e23730e * string.c (rb_str_sub_bang): calling rb_str_modify() should be just
before actually modifying the string.
  fixed: [ruby-dev:30211] (originally reported by zunda)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-30 06:04:37 +00:00
matz
7ba0cd826e * string.c (rb_str_upto): String#upto from empty string makes
inifinite loop.  [ruby-core:09864]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-08 19:02:50 +00:00
matz
46fa18da5b Revert r11453
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-03 03:14:57 +00:00