Commit graph

655 commits

Author SHA1 Message Date
yugui
8acba0bc1b * string (rb_string_value): warning for implicit conversion
from Symbol to String. This behavior was introduced in r22606,
  merged in r22738 to ruby_1_9_1. It was an unexpected language
  feature change. It will be removed from Ruby in the 1.9.2.
  c.f. [ruby-dev:40274].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-04 03:50:01 +00:00
yugui
34072faa0d merges r26052 from trunk into ruby_1_9_1.
--
* string.c (rb_str_justify): fixed the case a fill size is a
  multiple of the length of the padding.  [ruby-dev:39856]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-04 03:48:25 +00:00
yugui
7e0875aa16 merges r25334 from trunk into ruby_1_9_1.
--
* string.c (rb_check_string_type): rdoc fix [ruby-core:26084]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-01-30 12:47:40 +00:00
yugui
8a5224e4de * string.c (rb_str_justify): CVE-2009-4124.
Fixes a bug reported by 
  Emmanouel Kellinis <Emmanouel.Kellinis AT kpmg.co.uk>, KPMG London;
  Patch by nobu.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-07 04:11:26 +00:00
yugui
69b51262f3 merges r25351 from trunk into ruby_1_9_1. fixes the backport task #2214.
--
* parse.y (rb_intern3): check symbol table overflow.
  [ruby-core:26092]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@26011 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-05 09:39:48 +00:00
yugui
0a84a18ef4 merges r24511 from trunk into ruby_1_9_1.
--
* insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h: check
  definition of (classes)#=== for case/when optimization.
  Fix Bug #1376 [ruby-core:23190].
* string.c (Init_String), bignum.c (Init_Bignum),
  numeric.c (Init_Numeric): define String#===, Symbol#===,
  Bignum#===, Fixnum#===, Float#=== as same as (classes)#==.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-25 14:46:19 +00:00
yugui
3e26b95145 merges r24509 from trunk into ruby_1_9_1.
--
* string.c (rb_str_new_frozen): must not change encoding of frozen
  shared string.  [ruby-dev:39068]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-25 14:46:11 +00:00
yugui
04f65b4127 merges r24342 and r24348 from trunk into ruby_1_9_1.
--
 Can't use singlebyte optimization when the replacement is multibyte. [ruby-core:24612]

 * string.c (tr_trans): can't use singlebyte optimization when
          the replacement is multibyte. [ruby-core:24612]
--
* string.c (tr_trans): change condition of singlebyte optimization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-08 15:31:35 +00:00
yugui
18eff087da merges r24103 from trunk into ruby_1_9_1.
--
Check pos and strlen on Regexp#index(str, pos) [ruby-core:23660]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-15 12:01:14 +00:00
yugui
1032750aa6 merges r23930 from trunk into ruby_1_9_1.
--
* hash.c (rb_hash_hash): documentation fix.  a patch from
  Marc-Andre Lafortune.  [ruby-core:23943]

* object.c (rb_mod_cmp): ditto.

* range.c (range_eq): ditto.

* string.c (rb_str_partition, rb_str_rpartition): ditto.

* struct.c (rb_struct_s_def): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-12 14:46:09 +00:00
yugui
72c0d800b4 merges r23916 from trunk into ruby_1_9_1.
--
* re.c (reg_match_pos): adjust offset based on characters, not
  bytes.  [ruby-dev:38722]

* string.c (rb_str_offset): new function.

* string.c (rb_str_index_m): no call to rb_reg_adjust_startpos().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@24049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-12 14:45:43 +00:00
yugui
0fd0bacc61 merges r23568 from trunk into ruby_1_9_1.
--
* string.c (rb_str_each_char, rb_str_each_codepoint): string
  length must be long.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-20 09:07:17 +00:00
yugui
67a3f2eebc merges r23562 and r23564 from trunk into ruby_1_9_1.
--
* string.c (rb_str_partition): should use the converted result.  a
  patch from Marc-Andre Lafortune at [ruby-core:23540].
--
* string.c (rb_str_rpartition): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-20 09:07:02 +00:00
yugui
102ccac988 merges r23160 from trunk into ruby_1_9_1.
--
* string.c (rb_str_dump): buffer length plus one byte for null
  terminator.  [ruby-dev:38294]

* test/ruby/test_m17n.rb (test_str_dump): add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-04 12:30:06 +00:00
yugui
52e721592f merges r23159 from trunk into ruby_1_9_1.
--
* string.c (rb_str_rstrip_bang): should not sign-expand non-ascii.
  [ruby-core:23158]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-04 12:29:55 +00:00
yugui
1de888d407 merges r23155 and r23158 from trunk into ruby_1_9_1.
--
* string.c (rb_str_chop_bang): reset coderange. [ruby-core:23155]
--
* test/ruby/test_string.rb (test_chop, test_chop!): tests for [ruby-core:23155].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-04 12:29:44 +00:00
yugui
af2d1789ed merges r22611 from trunk into ruby_1_9_1.
--
* string.c (rb_str_force_encoding): should clear coderange at changing
  encoding.  [ruby-core:22437]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-04 09:19:09 +00:00
yugui
5665cf676f merges r22608 from trunk into ruby_1_9_1.
--
* string.c (rb_str_chomp_bang): coderange may change.
  [ruby-core:22414]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-03 11:40:32 +00:00
yugui
c18695771d merges r22606 from trunk into ruby_1_9_1.
--
* string.c (rb_str_delete_bang): should recalculate coderange.
  [ruby-talk:329267]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-03 11:40:22 +00:00
yugui
f3c363c6f7 merges r22505 and r22547 from trunk into ruby_1_9_1.
--
* string.c (tr_trans): should not be affected by the encoding of
  replacement unless actually modified.  [ruby-talk:328967]
--
* string.c (tr_trans): should recalculate coderange.
  [ruby-core:22326] (reopened at [ruby-core:22328])

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-03 11:39:19 +00:00
yugui
f08b595a5b merges r22255 from trunk into ruby_1_9_1.
* compile.c (compile_array_, defined_expr, iseq_compile_each): hide
  and freeze internal literal objects, to prevent from modifying.
  [ruby-dev:37959]

* iseq.c (insn_operand_intern): copy internal literal objects.

* insns.def (putstring, duparray): ditto.

* string.c (rb_str_replace): exported.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 12:49:14 +00:00
yugui
81e2c9e10d merges r22083 from trunk into ruby_1_9_1.
* string.c (rb_str_each_codepoint): update RDoc for
  String#codepoints.  a patch from Radoslaw Bulat in
  [ruby-core:21835]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 09:47:56 +00:00
yugui
a8b2bda760 merges r20952 from trunk into ruby_1_9_1.
* string.c (rb_external_str_new_with_enc): set ASCII-8BIT if
  encoding is US-ASCII and string contains 8bit characters.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-26 11:16:35 +00:00
yugui
863882ea3e merges r20906 from trunk into ruby_1_9_1.
* string.c (rb_str_upto): should return enumerator if called
  without block.  [ruby-dev:37526]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:50:32 +00:00
yugui
8c85ad0519 merges r20804 from trunk into ruby_1_9_1.
* string.c (rb_str_hash): gets rid of collisions between different
  encoding strings.  [ruby-core:20526]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-17 06:18:56 +00:00
yugui
d1167ba077 merges r20723 and r20724 from trunk into ruby_1_9_1.
* string.c (sym_inspect): quote if symbol contains non-printable
  characters.  [ruby-dev:37398]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-16 10:25:58 +00:00
yugui
2eb71691f9 merges r20722 from trunk into ruby_1_9_1.
* string.c (sym_equal): remove documentation error "Otherwise,
  compares them as strings".  [ruby-dev:37398]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-16 10:25:50 +00:00
yugui
e64a495bf8 merges r20651 from trunk into ruby_1_9_1.
* string.c (rb_string_value_ptr, rb_to_id): do not use a side
  effect expression in RSTRING_PTR.

* string.c (rb_str_split_m): simplified the argument of
  RSTRING_LEN.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-13 01:03:33 +00:00
yugui
7ac90158e2 merges r20534 from trunk into ruby_1_9_1.
* 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_9_1@20553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-05 13:34:25 +00:00
yugui
5f2d8e4eca merges r20224 from trunk into ruby_1_9_1
* include/ruby/intern.h (rb_{external,locale}_str_new_cstr): optimized
  versions for literal strings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-18 16:46:47 +00:00
yugui
90fe776136 merges r20145 from trunk into ruby_1_9_1.
* ext/curses/curses.c: curses encoding should obey locale.

* ext/curses/curses.c (curses_getch): 1.9 getch should return one
  character string for single byte string.  wchar_t support may
  follow in the future.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-11 11:00:39 +00:00
yugui
5952025834 merges r20125 from trunk into ruby_1_9_1.
* string.c (Init_String): remove Symbol#===.  [ruby-dev:37026]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-11 08:41:05 +00:00
yugui
c00233f707 merges r20046 from trunk into ruby_1_9_1.
* string.c (rb_str_check_dummy_enc): new function to check dummy
  encoding.

* string.c (rb_str_upcase_bang): case conversion functions should
  not be applicable to strings in dummy encoding.  [ruby-dev:36985]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-30 12:09:36 +00:00
mame
213be82796 * string.c (rb_str_cmp): fix condition which always returned true
because ENCODING_GET returns unsigned long.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 16:30:02 +00:00
matz
3896936492 * string.c (rb_str_dump): should have removed commented out
unnecessary code.  [ruby-cvs:27131]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-24 10:58:33 +00:00
shyouhei
78d2b00893 * string.c (rb_str_dump): do not use C++ comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-24 10:30:09 +00:00
matz
5a8db29b59 * string.c (rb_str_dump): use \u{ff} escape for UTF-8 encoding
string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-23 06:53:55 +00:00
matz
38c7a687e1 * string.c (rb_str_conv_enc_opts): new function to convert with
specifying ecflags and ecopts.

* ext/zlib/zlib.c (gzfile_newstr): specify ecflags and ecopts for
  conversion using above function.

* ext/zlib/zlib.c (gzfile_newstr): use own rb_econv_t for dummy
  encoding to handling stateful encoding (e.g. iso-2022-jp).
  [ruby-dev:36857]

* ext/zlib/zlib.c (gzfile_getc): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-22 16:53:50 +00:00
matz
4a3f2a7bc5 * string.c (rb_external_str_new_with_enc): no implicit strlen call.
[ruby-dev:36854]

* string.c (rb_external_str_new_cstr): new function to create
  string from external NUL terminated C string.

* string.c (rb_locale_str_new_cstr): ditto.

* ext/readline/readline.c: now use rb_locale_str_new_cstr().

* test/sdbm/test_sdbm.rb (TestSDBM#test_delete_with_block):
  deleted key to the block may be a copy of specified key.

* test/dbm/test_dbm.rb (TestDBM#test_delete_with_block): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-22 05:55:22 +00:00
matz
fa127bbb18 * string.c (rb_external_str_new_with_enc): wrong condition to
calculate strlen().

* ext/readline/readline.c: add encoding support.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 15:52:07 +00:00
matz
b6ef272d02 * ext/zlib/zlib.c: remove obsolete prototype macros.
* ext/zlib/zlib.c (struct gzfile): add encoding field to gzfile
  structure.

* ext/zlib/zlib.c (rb_gzreader_getc): now works on characters.

* ext/zlib/zlib.c (rb_gzreader_getbyte): new method to retrieve
  single byte.

* ext/zlib/zlib.c (rb_gzreader_readbyte): ditto.

* ext/zlib/zlib.c (rb_gzreader_each_byte): renamed from each_char

* ext/zlib/zlib.c (rb_gzreader_ungetc): allow unget strings.

* ext/zlib/zlib.c (rb_gzreader_ungetbyte): renamed from ungetc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 09:18:34 +00:00
matz
6259c87d02 * include/ruby/ruby.h (ExportStringValue): new macro to convert
string in internal encoding to external to export.

* string.c (rb_str_export): new function to do conversion to
  external encoding.

* ext/sdbm/init.c: encoding conversion support.

* ext/dbm/dbm.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-20 08:05:44 +00:00
matz
52b3e3b97f * string.c (rb_locale_str_new): new function to convert string
from locale to internal encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-20 07:15:19 +00:00
matz
3f0ec8887f * string.c (rb_external_str_new): a new function to convert from
external encoding to internal encoding.  if something went
  wrong, it returns a string with the external encoding.

* string.c (rb_external_str_new_with_enc): same as above besides
  you can specify the source encoding.

* ruby.c (ruby_set_argv): use rb_external_str_new()

* ruby.c (set_arg0, ruby_script): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-18 10:36:20 +00:00
matz
1e8bbf3154 * .gdbinit (rp): REGEXP handling fixed.
* string.c (rb_str_rindex_m): need not to call rb_enc_check on
  regexp.

* re.c (unescape_escaped_nonascii): try ASCII-8BIT encoding for
  broken strings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-16 22:21:42 +00:00
matz
f2f2cd5bc6 * string.c (rb_str_comparable): string comparison should be
transitive.  [ruby-dev:36484]

* test/ruby/test_m17n_comb.rb (TestM17NComb#test_str_eq): test
  updated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-06 03:22:56 +00:00
akr
bd421aa2d2 * string.c (rb_str_sub_bang): fix coderange.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-02 11:46:40 +00:00
matz
d370a79c69 * string.c (rb_str_split_m): should use rb_str_subseq() which use
offset and length by bytes.  [ruby-dev:36641]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-30 16:18:27 +00:00
akr
eace50a9d7 * string.c (rb_str_subseq): don't use rb_str_drop_bytes for short
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-29 14:39:20 +00:00
akr
ebb3ace825 * string.c (rb_str_subseq): use rb_str_drop_bytes if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-29 11:56:43 +00:00