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

519 Коммитов

Автор SHA1 Сообщение Дата
akr ca122fa53b * string.c (IS_7BIT): removed.
(single_byte_optimizable): new function to test optimizationability
  using single byte string.
  (str_strlen): use single_byte_optimizable instead of
  is_ascii_string.
  (str_nth): rename argument: asc -> singlebyte.
  (str_offset): ditto.
  (rb_str_substr): use single_byte_optimizable instead of IS_7BIT.
  (rb_str_index): ditto.
  (rb_str_rindex): ditto.
  (rb_str_splice): ditto.
  (rb_str_justify): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-31 10:39:20 +00:00
akr e21907e0f8 fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-31 05:52:59 +00:00
akr 486dd97e74 update force_encoding document.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-30 09:19:09 +00:00
nobu 5ee7f4b0b5 * re.c (rb_reg_regsub): returns the given string itself if nothing
changed.

* string.c (rb_str_sub_bang): keeps code-range as possible.

* string.c (str_gsub): adjusts code-range.  [ruby-core:14566]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-29 13:44:32 +00:00
akr ce2b982cd2 * encoding.c (rb_enc_codelen): show codepoint in error message.
* include/ruby/encoding.h (rb_enc_codelen): comment it returns
  positive integer.

* string.c (rb_str_concat): rb_enc_codelen doesn't return 0.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-27 06:27:39 +00:00
nobu 6aef04f338 * string.c (rb_str_casecmp): fixed using a wrong variable.
[ruby-list:44402]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-27 06:02:55 +00:00
nobu c2d54ce2a0 * string.c (Init_String): defines chars method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-26 07:10:20 +00:00
nobu 0ee5a49dd4 * encoding.h (rb_enc_mbc_to_codepoint): wrapper for
ONIGENC_MBC_TO_CODE().

* string.c (rb_str_succ): deal with invalid sequence as binary.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 10:01:06 +00:00
akr 0eb5c917e0 * string.c (rb_str_each_line): don't call rb_enc_codepoint with empty
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 09:28:31 +00:00
akr ead329fd8e * string.c (rb_str_inspect): don't call rb_enc_codepoint with empty
string.  fix '#'.inspect.

* encoding.c (rb_enc_codepoint): raise on empty string.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 09:07:32 +00:00
nobu f1fc4bbecb * string.c (rb_str_succ): fix for string with non-alphanumeric chars.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 06:55:16 +00:00
matz a04a812ed0 * include/ruby/encoding.h (rb_enc_left_char_head): new utility macro.
* include/ruby/encoding.h (rb_enc_right_char_head): ditto.

* io.c (appendline): does multibyte RS search in the function.

* io.c (prepare_getline_args): RS may be nil.

* io.c (rb_io_getc): should process character based on external
  encoding, when transcoding required.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-24 16:36:14 +00:00
matz 37855698ff * string.c (rb_str_comparable): fixed to keep transitivity.
[ruby-dev:32693]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-24 02:40:55 +00:00
matz 19cf57f21c * string.c (tr_trans): should associate new encoding if modified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 20:13:55 +00:00
matz 65a0050268 * string.c (str_new_shared): was setting embedding flag of wrong
string object.  [ruby-dev:32685]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 18:58:09 +00:00
matz fa1e530063 * string.c (rb_str_comparable): comparison including broken
coderange strings do not consider encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 16:07:09 +00:00
nobu e3897c538c * string.c (sym_call): use exact argument array interface.
[ruby-core:14279]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 02:26:45 +00:00
akr b2a1dc616c add rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-22 08:38:53 +00:00
nobu 7f59e105d1 * string.c (rb_str_buf_append): improvement for non-broken coded
strings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 23:29:56 +00:00
nobu 977eea57a3 * string.c (rb_str_succ): retry increasing until valid char is found.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 11:09:19 +00:00
matz 3ec3412d83 * string.c (rb_str_chomp_bang): avoid unnecessary loop using
rb_enc_prev_char().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 04:03:19 +00:00
akr 2b62714866 * string.c (rb_str_is_ascii_only_p): new method ascii_only?.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 03:18:37 +00:00
akr 4cf437519f * regerror.c, string.c, io.c, lib/getoptlong.rb, lib/net/imap.rb,
compile.c, sprintf.c, parse.y, ext/win32ole/win32ole.c,
  ext/tk/sample/demos-en/entry3.rb, ext/tk/lib/tcltk.rb,
  ext/openssl/ossl_bn.c, numeric.c, vm.c,
  benchmark/bm_so_meteor_contest.rb, bignum.c, ruby.c: don't "illegal"
  for non law violation context.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 02:31:11 +00:00
matz cfb91bc2f5 * string.c (tr_trans): wrong encoding check for tree strings.
* test/ruby/test_m17n.rb (TestM17N::test_tr_s): "invalid mbstring
  sequence" is not an error to be tested.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-20 15:27:35 +00:00
matz 1c32ff927f * string.c (rb_str_index): wrong starting position.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-20 00:08:23 +00:00
matz d874dde282 * string.c (rb_str_each_line): should consider rslen.
* string.c (rb_str_buf_append): should propagate encoding.

* string.c (rb_str_each_line): ditto.

* test/ruby/test_m17n.rb (TestM17N::test_str_each_line): should
  check encoding as well.

* test/ruby/test_m17n.rb (TestM17N::test_str_each_line): empty
  array can not propagate encoding;  should not check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 17:46:17 +00:00
matz 77629d2cbe * string.c (rb_str_rindex_m): too much adjustment.
* re.c (reg_match_pos): pos adjustment should be based on
  characters.

* test/ruby/test_m17n.rb (TestM17N::test_str_insert): test updated
  to check negative offset behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 17:02:29 +00:00
matz a329b77348 * string.c (rb_str_rindex): comparison length should be based on
bytes, not characters.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 14:43:37 +00:00
matz 3e212b0484 * string.c (rb_str_chomp_bang): wrong adjust condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 14:38:46 +00:00
matz 1c7f24d5b1 * string.c (str_sublen): adjust position if position is not at the
head of a character.

* string.c (rb_str_chomp_bang): check if match start at the head
  of a character.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 14:15:05 +00:00
nobu 474a88f041 * re.c (rb_reg_regsub): should set checked encoding.
* string.c (rb_str_sub_bang): applied r14212 too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 12:42:19 +00:00
matz ac5250098d * string.c (rb_str_justify): should propagate encoding from pad
string too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 06:15:35 +00:00
matz ec69dddc0d * string.c (rb_str_splice): propagate encoding.
* string.c (rb_str_subpat_set): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-18 09:14:46 +00:00
matz a3a6ba9584 * string.c (str_nth): need not to raise out-of-range exception.
* test/ruby/test_m17n.rb (TestM17N::test_str_aref_len): removed
  debug print.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-18 05:44:30 +00:00
matz ebfcc5d933 * re.c (rb_reg_initialize): raise error if non-Unicode fixed
encoding option is specified for regexp literals with \u{}
  escapes.

* string.c (rb_str_squeeze_bang): should squeeze multibyte
  characters as well.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 16:06:21 +00:00
matz d6a70c4bb7 * string.c (scan_once): need no encoding compatibility check.
it's done inside of re_reg_seach().

* string.c (rb_str_split_m): ditto.

* re.c (rb_reg_regsub): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 09:44:06 +00:00
matz ea1b9d58b9 * string.c (rb_str_index): check if substring is broken.
* string.c (rb_str_rindex): ditto.

* string.c (rb_str_succ): should carry over.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 09:08:27 +00:00
akr 33ecb05d51 * string.c (rb_enc_str_asciionly_p): use rb_enc_str_coderange.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 08:08:23 +00:00
akr 0d0a8a55fc * string.c (rb_enc_str_coderange): set ENC_CODERANGE_BROKEN using
rb_enc_precise_mbclen.
  (rb_str_valid_encoding_p): just check coderange is
  ENC_CODERANGE_BROKEN or not.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 07:41:21 +00:00
akr 3f07e548fc * include/ruby/encoding.h (ENC_CODERANGE_VALID): rename from
ENC_CODERANGE_8BIT.

* string.c (rb_enc_str_coderange): follow the renaming.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 05:07:37 +00:00
matz 5a41626dea * string.c (tr_find): wrong condition fixed.
* sprintf.c (rb_str_format): check encoding based on result, not
  the format string.

* string.c (rb_str_upto): add encoding check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 05:01:47 +00:00
matz 11f3462fb7 * io.c (rb_f_p): RDoc update. a patch from murphy <murphy AT rubychan.de>.
[ruby-core:14010]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-14 08:38:18 +00:00
matz 269bd16b28 * string.c (rb_str_cmp): encoding aware comparison.
* string.c (rb_str_casecmp): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-14 08:37:39 +00:00
matz c958d9a9c6 * string.c (str_nth): direct jump if string is 7bit only. great
performance boost for worst case.

* string.c (str_strlen): direct size if string is 7bit only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 18:00:50 +00:00
akr 9595af4ad5 * string.c (rb_str_shared_replace): make str noembed after free.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 11:52:15 +00:00
matz 7987f38467 * string.c (rb_str_succ): should not enter infinite loop for
non-ASCII, non-alphanumeric character at the bottom.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 09:20:13 +00:00
matz 66bae8ad6d * string.c (str_gsub): should copy encoding to the result.
* sprintf.c (rb_str_format): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 09:05:49 +00:00
matz fb14b7eb05 * string.c (rb_str_split_m): need not to check encoding if regexp
is empty.

* string.c (rb_str_justify): associate encoding of original to the
  result. 

* string.c (rb_str_chomp_bang): need to check encoding of record
  separator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 08:28:40 +00:00
akr b92cee1ddb * re.c, regerror.c, string.c, parse.y, ruby.c, file.c:
use capital letter for \xHH notation.  [ruby-dev:32511]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-12 14:30:54 +00:00
nobu ad72efa269 * re.c (rb_reg_regsub): should copy encoding.
* string.c (rb_str_sub_bang, str_gsub): should check and copy encoding
  to be replaced.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-12 03:11:44 +00:00
nobu 3a3bda73dd * string.c (rb_str_tmp_new): creates hidden temporary buffer.
* transcode.c (transcoding): added a pointer to function to flush.

* transcode.c (transcode_loop): do not use string internal.
  [ruby-dev:32512]

* transcode.c (str_transcode): allow Encoding objects.

* transcode_data.h (BYTE_LOOKUP): use actual struct name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 08:46:06 +00:00
nobu c26e32ec16 * string.c (rb_str_insert): should not add length in bytes to index in
chars.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 07:52:19 +00:00
matz 7ded13f54b * transcode.c: new file to provide encoding conversion features.
code contributed by Martin Duerst.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 05:01:47 +00:00
nobu 38a24d73c8 * re.c (rb_reg_search): return byte offset. [ruby-dev:32452]
* re.c (rb_reg_match, rb_reg_match2, rb_reg_match_m): convert byte
  offset to char index.

* string.c (rb_str_index): return byte offset.  [ruby-dev:32472]

* string.c (rb_str_split_m): calculate in byte offset.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 04:50:35 +00:00
akr f4592d7bb0 * re.c (rb_reg_expr_str): use \xHH instead of \OOO.
* regerror.c (to_ascii): ditto.
  (onig_snprintf_with_pattern): ditto.
  (onig_snprintf_with_pattern): ditto.

* string.c (rb_str_inspect): ditto.
  (rb_str_dump): ditto.

* parse.y (parser_yylex): ditto.

* ruby.c (proc_options): ditto.

* file.c (rb_f_test): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 21:48:05 +00:00
nobu 45fa4a4b63 * string.c (tr_find): returns true if no characters to be removed is
specified.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 03:12:25 +00:00
nobu 54c146d2c3 * string.c (tr_trans): get rid of segfaults when has mulitbytes but
source sets have no mulitbytes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 02:29:24 +00:00
akr f1b7e60cb9 * encoding.c (rb_enc_mbclen): make it never fail.
(rb_enc_nth): don't check the return value of rb_enc_mbclen.
  (rb_enc_strlen): ditto.
  (rb_enc_precise_mbclen): return needmore(1) if e <= p.
  (rb_enc_get_ascii): new function for extracting ASCII character.

* include/ruby/encoding.h (rb_enc_get_ascii): declared.

* include/ruby/regex.h (ismbchar): removed.

* re.c (rb_reg_expr_str): use rb_enc_get_ascii.
  (unescape_escaped_nonascii): use rb_enc_precise_mbclen to determine
  the termination of escaped non-ASCII character.
  (unescape_nonascii): use rb_enc_precise_mbclen.
  (rb_reg_quote): use rb_enc_get_ascii.
  (rb_reg_regsub): use rb_enc_get_ascii.

* string.c (rb_str_reverse) don't check the return value of
  rb_enc_mbclen.
  (rb_str_split_m): don't call rb_enc_mbclen with e <= p.

* parse.y (is_identchar): use ISASCII.
  (parser_ismbchar): removed.
  (parser_precise_mbclen): new macro.
  (parser_isascii): new macro.
  (parser_tokadd_mbchar): use parser_precise_mbclen to check invalid
  character precisely.
  (parser_tokadd_string): use parser_isascii.
  (parser_yylex): ditto.
  (is_special_global_name): don't call is_identchar with e <= p.
  (rb_enc_symname_p): ditto.

  [ruby-dev:32455]

* ext/tk/sample/tkextlib/vu/canvSticker2.rb: remove coding cookie
  because the encoding is not UTF-8.  [ruby-dev:32475]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-08 02:50:43 +00:00
akr 69406aad50 * encoding.c (rb_enc_precise_mbclen): new function for mbclen with
validation.

* include/ruby/encoding.h (rb_enc_precise_mbclen): declared.
  (MBCLEN_CHARFOUND): new macro.
  (MBCLEN_INVALID): new macro.
  (MBCLEN_NEEDMORE): new macro.

* include/ruby/oniguruma.h (OnigEncodingTypeST): replace mbc_enc_len
  by precise_mbc_enc_len.
  (ONIGENC_PRECISE_MBC_ENC_LEN): new macro.
  (ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND): new macro.
  (ONIGENC_CONSTRUCT_MBCLEN_INVALID): new macro.
  (ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE): new macro.
  (ONIGENC_MBCLEN_CHARFOUND): new macro.
  (ONIGENC_MBCLEN_INVALID): new macro.
  (ONIGENC_MBCLEN_NEEDMORE): new macro.
  (ONIGENC_MBC_ENC_LEN): use ONIGENC_PRECISE_MBC_ENC_LEN.

* enc/euc_jp.c: validation implemented.

* enc/sjis.c: ditto.

* enc/utf8.c: ditto.

* string.c (rb_str_inspect): use rb_enc_precise_mbclen for invalid
  encoding.
  (rb_str_valid_encoding_p): new method String#valid_encoding?.

* io.c (rb_io_getc): use rb_enc_precise_mbclen.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-06 09:28:26 +00:00
akr f5ee0fd521 * include/ruby/encoding.h, encoding.c, re.c, string.c, parse.y:
rename ENC_CODERANGE_SINGLE to ENC_CODERANGE_7BIT.
  rename ENC_CODERANGE_MULTI to ENC_CODERANGE_8BIT.
  Because single byte 8bit character, such as Shift_JIS 1byte katakana,
  is represented by ENC_CODERANGE_MULTI even if it is not multi byte.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-27 02:21:17 +00:00
akr b2e60b2ce7 * include/ruby/encoding.h (rb_enc_str_asciionly_p): declared.
(rb_enc_str_asciicompat_p): defined.

* re.c (rb_reg_initialize_str): use rb_enc_str_asciionly_p.
  (rb_reg_quote): return ascii-8bit string if the argument is
  ascii-only to generate encoding generic regexp if possible.
  (rb_reg_s_union): fix encoding handling.  [ruby-dev:32094]

* string.c (rb_enc_str_asciionly_p): defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-25 13:25:34 +00:00
ko1 25c0cb981a * include/ruby/ruby.h: introduce 2 macros:
RFLOAT_VALUE(v), DOUBLE2NUM(dbl).
  Rename RFloat#value -> RFloat#double_value.
  Do not touch RFloat#double_value directly.
* bignum.c, insns.def, marshal.c, math.c, numeric.c, object.c,
  pack.c, parse.y, process.c, random.c, sprintf.c, string.c,
  time.c: apply above changes.
* ext/dl/mkcallback.rb, ext/json/ext/generator/generator.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 16:00:53 +00:00
akr 098a563935 * string.c (tr_trans): cast to unsigned char after dereference
a pointer to a char to avoid SEGV with "\377".tr("a", "b").
  on FreeBSD/amd64.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-10 14:53:26 +00:00
nobu 03d68e3ba4 * string.c (rb_str_squeeze_bang): initialize squeezing table if no
arguments given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-09 06:20:15 +00:00
davidflanagan f6fb4b3e8e * string.c (tr_setup_table, tr_trans): fix test failures in test/ruby/test_string.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-07 22:07:13 +00:00
matz 19c4d26c51 * string.c (tr_setup_table): use C array for characters that fit
in a byte to gain performance.

* string.c (rb_str_delete_bang): ditto.

* string.c (rb_str_squeeze_bang): ditto.

* string.c (rb_str_count): ditto.

* string.c (tr_trans): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-03 19:04:53 +00:00
nobu 2ae60f1634 * string.c (rb_str_substr): perfomance improvement. [ruby-dev:31806]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-29 08:58:17 +00:00
nobu b1d53d10e2 * string.c (rb_str_ord): use encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 17:50:51 +00:00
nobu eb6e9c15bd * string.c (rb_str_new4): should copy encoding. a patch from NARUSE,
Yui <naruse AT airemix.com>.  [ruby-dev:32076]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 04:25:47 +00:00
nobu 9c24fed339 * encoding.c (rb_cEncoding): new Encoding class.
* encoding.c (rb_to_encoding, rb_to_encoding_index): helper functions.

* encoding.c (rb_obj_encoding): return Encoding object now.

* gc.c (garbage_collect): mark Encoding objects.

* string.c (rb_str_force_encoding): accept Encoding object as well as
  encoding name.

* include/ruby/encoding.h (rb_to_encoding_index, rb_to_encoding):
  prototypes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-13 16:32:40 +00:00
nobu 8c19ecbeeb * string.c (rb_enc_str_coderange): fixed checkfor non-ascii.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-10 05:31:08 +00:00
matz 026568c915 * 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/trunk@13645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-06 14:17:35 +00:00
nobu 597974c21f * encoding.c (rb_enc_register): returns new index or -1 if failed.
* encoding.c (rb_enc_alias): check if original name is registered.

* encoding.c (rb_enc_init): register in same order as kcode options in
  re.c.  added new aliases.

* string.c (rb_str_force_encoding): check if valid encoding name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-06 05:56:09 +00:00
nobu 6845578c92 * insns.def (opt_eq): get rid of gcc bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-06 05:32:37 +00:00
matz c953283d7e revert rb_memcmp() change to pacify GCC optimizer
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 09:54:53 +00:00
matz 1677425e9d * re.c (rb_memcmp): no longer useful without ruby_ignorecase.
* re.c (rb_reg_prepare_re): revert recompile condition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 09:24:00 +00:00
matz dbcc539602 * re.c (ignorecase_setter): change warning message.
* re.c (ignorecase_getter): now gives warning.

* string.c (rb_str_cmp_m): update RDoc document.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 08:09:06 +00:00
nobu 19dee8af57 * encoding.c (rb_obj_encoding): returns encoding of the given object.
* re.c (Init_Regexp): new method Regexp#encoding.

* string.c (str_encoding): moved to encoding.c


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 06:57:19 +00:00
nobu eb64f5de06 * string.c (rb_str_append): always set encoding, and coderange
cache bits.

* include/ruby/encoding.h (ENC_CODERANGE_SET): fixed a bug not to
  set chache bits.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-30 08:13:28 +00:00
matz 43c4d80930 * array.c (rb_ary_combination): new method to give all combination
of elements from an array.  [ruby-list:42671]

* array.c (rb_ary_product): a new method to get all combinations
  of elements from two arrays.  can be extended to combinations of
  n-arrays, e.g. a.product(b,c,d).  anyone volunteer?

* array.c (rb_ary_permutation): empty function body to calculate
  permutations of array elements.  need volunteer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-29 08:43:59 +00:00
nobu c351afc372 * encoding.c (rb_enc_alias): allow encodings multiple aliases.
* encoding.c (rb_enc_find_index): search the encoding which has the
  given name and return its index if found, or -1.

* st.c (type_strcasehash): case-insensitive string hash type.

* string.c (rb_str_force_encoding): force encoding of self.  this name
  comes from [ruby-dev:31894] by Martin Duerst.  [ruby-dev:31744]

* include/ruby/encoding.h (rb_enc_find_index, rb_enc_associate_index):
  prototyped.

* include/ruby/encoding.h (rb_enc_isctype): direct interface to ctype.

* include/ruby/st.h (st_init_strcasetable): prototyped.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 19:27:10 +00:00
matz 335fe1ee7b * string.c (rb_str_comparable): need not to check asciicompat here.
* encoding.c (rb_enc_check): ditto.

* string.c (rb_enc_str_coderange): tuned a bit; no broken check.

* encoding.c (rb_enc_check): new encoding comparison criteria.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 09:07:02 +00:00
nobu 19d8793ef4 * string.c (rb_str_associate_encoding): commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-26 19:51:00 +00:00
nobu e41b84895e * encoding.c (rb_enc_associate_index): deal with ASCII compatible
flags.

* encoding.c (rb_enc_check): allow ASCII compatible strings.

* parse.y (rb_intern_str): use ASCII encoding for ASCII string.

* string.c (rb_enc_str_coderange): check for code-range.

* string.c (rb_str_modify): clear code-range flags.

* string.c (rb_str_hash, rb_str_eql): ASCII compatible strings are
  comparable.

* include/ruby/encoding.h: added code-range flags.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-26 19:46:58 +00:00
nobu 94a0db11e7 * encoding.c (rb_enc_check): check for ASCII-compatibilities.
* parse.y (parser_tokadd_string, parser_parse_string,
  parser_here_document, parser_yylex): set encoding to US-ASCII.

* parse.y (rb_enc_symname_p): check if valid with encoding.

* parse.y (rb_intern3): let symbols have encoding.

* string.c (rb_str_hash): add encoding index.

* string.c (rb_str_comparable, rb_str_equal, rb_str_eql): check if
  compatible encoding.

* string.c (sym_inspect): made encoding aware.

* insns.def (opt_eq): compare with encoding.

* include/ruby/encoding.h (rb_enc_asciicompat): check if ASCII
  compatible.

* include/ruby/encoding.h (rb_enc_get_index): added prototype.

* include/ruby/intern.h (rb_str_comparable, rb_str_equal): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-26 09:39:08 +00:00
matz 5376745fb6 * re.c (rb_reg_match_m): evaluate a block if match. it would make
condition statement much shorter, if no else clause is needed.

* string.c (rb_str_match_m): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-20 17:14:01 +00:00
kou 740e1b66c8 * string.c (rb_str_rstrip_bang): fixed too much rstrip. [ruby-dev:31786]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-15 09:26:06 +00:00
nobu 26adfc185f * encoding.c (rb_enc_associate_index, rb_enc_get_index): check if
object is encoding capable.  [ruby-dev:31780]

* string.c (rb_str_subpat_set): check for if the argument is a String.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-15 08:04:10 +00:00
matz edd7c787ad * array.c (rb_ary_cycle): typo in rdoc. a patch from Yugui
<yugui@yugui.sakura.ne.jp>.  [ruby-dev:31748]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-06 12:33:45 +00:00
nobu 629b1e4324 * string.c (rb_str_succ, rb_str_chop_bang, rb_str_chop): m17n support.
[ruby-dev:31734]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-06 03:42:12 +00:00
matz c349959778 * string.c (rb_str_splice): integer overflow for length.
[ruby-dev:31739]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-05 13:06:01 +00:00
nobu b58f080349 * string.c (tr_trans, rb_str_squeeze_bang, rb_str_split_m): suppress
warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-30 02:44:20 +00:00
matz 3d7f8c2320 * string.c (str_gsub): should not use mbclen2() which has broken API.
* re.c: remove rb_reg_mbclen2().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-29 19:16:02 +00:00
matz 51b4cc11d1 * string.c (rb_str_subseq): retrieve substring based on byte offset.
* string.c (rb_str_rindex_m): was confusing character offset and
  byte offset.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-28 06:45:32 +00:00
nobu 53635dea12 * string.c (rb_str_splice_0): should check to modify. [ruby-dev:31665]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-28 05:23:33 +00:00
matz 51fb5511e0 * string.c (rb_str_each_line): should swallow sequence of newlines
if rs (optional argument) is an empty string.  [ruby-dev:31652]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 14:32:15 +00:00
matz 9166bd2bc9 * string.c (rb_str_rstrip_bang): wrong strip point. [ruby-dev:31652]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 14:17:28 +00:00
nobu 3ca07d8718 * string.c (sym_encoding): return the encoding of a Symbol.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 06:56:49 +00:00
matz fa02a6cedd * string.c (tr_trans): wrong condition for mbmaxlen==1 strings.
[ruby-dev:31652]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 04:51:45 +00:00
ko1 5ba27573a0 * string.c, include/ruby/intern.h: export rb_str_length().
* insns.def: use rb_str_lengt() in opt_length.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 08:54:29 +00:00
nobu 10f56f8fd0 * string.c (rb_str_splice): return from void funtion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 07:14:01 +00:00
matz a25fbe3b3e * encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.

* parse.y (pragma_encoding): encoding specification pragma.

* parse.y (rb_intern3): encoding specified symbols.

* string.c (rb_str_length): length based on characters.  
  for older behavior, bytesize method added.

* string.c (rb_str_index_m): index based on characters.  rindex as
  well.

* string.c (succ_char): encoding aware succeeding string.

* string.c (rb_str_reverse): reverse based on characters.

* string.c (rb_str_inspect): encoding aware string description.

* string.c (rb_str_upcase_bang): encoding aware case conversion.
  downcase, capitalize, swapcase as well.

* string.c (rb_str_tr_bang): tr based on characters.  delete,
  squeeze, tr_s, count as well.

* string.c (rb_str_split_m): split based on characters.

* string.c (rb_str_each_line): encoding aware each_line.

* string.c (rb_str_each_char): added.  iteration based on
  characters.

* string.c (rb_str_strip_bang): encoding aware whitespace
  stripping.  lstrip, rstrip as well.

* string.c (rb_str_justify): encoding aware justifying (ljust,
  rjust, center).

* string.c (str_encoding): get encoding attribute from a string. 

* re.c (rb_reg_initialize): encoding aware regular expression

* sprintf.c (rb_str_format): formatting (i.e. length count) based
  on characters.

* io.c (rb_io_getc): getc to return one-character string.
  for older behavior, getbyte method added.

* ext/stringio/stringio.c (strio_getc): ditto.

* io.c (rb_io_ungetc): allow pushing arbitrary string at the
  current reading point.

* ext/stringio/stringio.c (strio_ungetc): ditto.

* ext/strscan/strscan.c: encoding support.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 03:29:39 +00:00
matz 5e1c401ff5 * array.c (rb_ary_s_try_convert): a new class method to convert
object or nil if it's not target-type.  this mechanism is used
  to convert types in the C implemented methods.

* hash.c (rb_hash_s_try_convert): ditto.

* io.c (rb_io_s_try_convert): ditto.

* re.c (rb_reg_s_try_convert): ditto.

* string.c (rb_str_s_try_convert): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 17:47:09 +00:00
matz b6449f6080 * string.c (Init_String): remove Symbol.intern and Symbol#dump.
[ruby-dev:31525]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-20 14:30:12 +00:00
nobu c2a41b3a71 * insnhelper.ci, string.c: fixed indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-18 05:11:49 +00:00
nobu 4b40f2c516 * string.c (rb_str_resize): fix indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-21 14:54:51 +00:00
nobu 6c12b69fda * 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/trunk@12805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-16 09:29:35 +00:00
matz 99c58e9ebc * string.c (rb_str_clear): need to check STR_EMBED_P() before
free()ing memory.  a patch from Yusuke ENDOH <mame AT tsg.ne.jp>.
  [ruby-dev:31062]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-26 15:19:39 +00:00
akr fe377d3b8e update document to follow MatchData#inspect implementation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-23 08:34:21 +00:00
matz 115410ecde * string.c (rb_str_upto): add optional argument to specify
exclusiveness.

* range.c (range_step): use String#upto with optional argument.

* range.c (range_each): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-22 16:23:16 +00:00
nobu 2b592580bf * include/ruby: moved public headers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 03:06:15 +00:00
matz b83ed6d1bd * parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
object.c, string.c, variable.c, vm_macro.def: revert private
  instance variable feature, which is postponed until next major
  release.

* marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
  8th version.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 02:49:41 +00:00
matz 0c882f4c9d * string.c (rb_str_ord): need not to check string length; ord
returns a codepoint for the first character in the string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 01:21:49 +00:00
matz 3098d80818 * re.c (reg_operand): allow symbols to be operands for regular
expression matches.

* string.c (Init_String): allow Symbol#===.

* lib/date/format.rb (Date::Format::Bag::to_hash): string
  added prefixes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-14 04:57:25 +00:00
matz 72f2d2a00d * parse.y (rb_compose_ivar2): function to create a new ivar2
symbol from a symbol and a class.  back-ported from matzruby.

* parse.y (rb_decompose_ivar2): reverse function of
  rb_compose_ivar2(). 

* marshal.c (w_symbol): support class local instance variables.

* marshal.c (r_object0): ditto.

* compile.c (defined_expr): ditto.

* compile.c (iseq_compile_each): ditto.

* insns.def: add two new instructions: getinstancevariable2 and
  setinstancevariable2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-04 19:17:33 +00:00
matz 6e0fed271c * ruby.h (SYMBOL_P): make Symbol immediate again for performance.
* string.c: redesign symbol methods.

* parse.y (rb_id2str): store Strings for operator symbols.
  [ruby-dev:30235]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 13:19:44 +00:00
usa 2fc900dac8 * 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/trunk@11598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-30 08:02:30 +00:00
ko1 7eb928624f * eval_proc.c (rb_proc_new): added.
* string.c (sym_to_proc): supported.
* vm.c (invoke_block, th_invoke_yield, th_invoke_proc): fix to support
  rb_proc_new.
* yarvcore.c: add a test code.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-16 03:06:01 +00:00
matz 0143945146 * string.c (rb_str_upto): use RSTRING_LEN().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-08 20:11:40 +00:00
matz af040cb612 * 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/trunk@11513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-01-08 18:58:31 +00:00
ko1 a3e1b1ce7e * Merge YARV
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-31 15:02:22 +00:00
matz 2126364501 * string.c (rb_str_ord): typo fixed. reported from Kornelius
Kalnbach <murphy@rubychan.de>.  [ruby-core:09621]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-21 16:47:01 +00:00
matz 2b38c2e0fb * string.c (rb_str_slice_bang): rdoc description bug fixed.
[ruby-core:09754]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-21 16:41:17 +00:00
matz f70c171f8c * string.c (rb_str_aset): index double decode problem.
[ruby-core:09695]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-12-11 00:45:32 +00:00
matz 0ee03fefad * string.c (Init_String): remove duplicated definition of
Symbol#to_s.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-11-06 13:24:57 +00:00
matz 6d32246b31 * parse.y (arg_dup_check): vid may be nameless internal id.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-11-06 06:37:40 +00:00
matz 030204ccf3 * string.c: class Symbol is no longer subclass of String. also
covers [ruby-core:09366]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-11-02 01:27:58 +00:00
matz 11e562f34a * string.c (hash): use Bob Jenkins' hash algorithm.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-11-01 14:23:42 +00:00
matz be21791e57 * string.c (rb_str_upcase, rb_str_downcase, rb_str_downcase,
rb_str_upcase_bang, rb_str_downcase_bang, rb_str_swapcase_bang):
  add RDoc description that case conversion to be effective only
  in ASCII region.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-22 08:06:16 +00:00
nobu 1366131642 * string.c (rb_str_substr): should be infected with only original
string, but not the shared string.  fixed: [ruby-core:09152]

* strnig.c (rb_str_new4): keep shared string untainted when orignal
  string is tainted.  fixed: [ruby-dev:29672]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-22 07:48:53 +00:00
matz f87431ce95 * string.c (rb_str_each_line): String#lines now works when a block
is given.  in other words, lines become an alias to each_line.
  [ruby-core:09218]

* string.c (rb_str_each_byte): ditto for bytes in place of lines.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-18 04:30:40 +00:00
matz 24691fa633 * string.c (rb_str_lines): now takes optional argument for the
line separator.

* io.c (rb_io_lines, rb_io_bytes): new methods.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-16 23:07:07 +00:00
matz 7df8b0501a * string.c (rb_str_partition): RDoc update. a patch from
Mauricio Fernandez <mfp at acm.org>.  [ruby-core:09160]

* hash.c (rb_hash_compare_by_id): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-12 16:07:21 +00:00
matz d2133ab996 * string.c (rb_str_scan): small documentation fix.
[ruby-core:09007]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-07 15:55:17 +00:00
matz 4392e94d96 * string.c (rb_str_lines): returns an Enumerator instead of an
array of lines.

* string.c (rb_str_bytes): a new method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-10-02 16:39:21 +00:00
matz 62ad417517 * string.c (rb_str_startwith): rename startwith? to start_with?,
endwith? to endwith?, respectively.  [ruby-talk:216685]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-27 12:45:29 +00:00
matz 1113d54ede * array.c (rb_ary_shift): shift/unshift performance boost patch,
based on the patch from Eric Mahurin <eric_mahurin at yahoo.com>.
  [ruby-core:05861]

* array.c (rb_ary_unshift_m): ditto.

* array.c (ary_make_shared): ditto.

* array.c (RESIZE_CAPA): ditto.

* array.c (rb_ary_free): new function to free memory.  code moved
  from gc.c.

* string.c (rb_str_free): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-26 22:46:16 +00:00
matz a2fc608087 * string.c (rb_str_partition): no need to call rb_call_super(),
since String is no longer includes Enumerable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-22 09:08:58 +00:00
matz 5b950717b7 * string.c (str_new3): embed shorter strings more eagerly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-21 22:50:32 +00:00
matz f5ec2b0d75 * string.c (rb_str_startwith): a new method to check if a string
starts with given prefix.

* string.c (rb_str_endwith): the opposite of String#startwith?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-21 08:47:03 +00:00
matz 4e37427ee5 * string.c (Init_String): Strings are no longer Enumerable. use
each_lines or lines method explicitly.

* string.c (Init_String): remove each method. use each_lines.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-21 05:57:20 +00:00
matz 77fef79f10 * string.c (rb_str_partition): RDoc typo fixed. [ruby-core:08898]
* string.c (rb_str_rpartition): fixed separation seek bug.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-21 01:10:25 +00:00
matz e79002a022 * string.c (rb_str_lines): new method to split a string into lines.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-21 00:43:16 +00:00
matz 71afefd5d1 * string.c (rb_str_partition): a new method to separate the string
by a separator.  taken from Python 2.5.

* string.c (rb_str_rpartition): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-20 16:41:56 +00:00
matz 803591e900 * string.c (sym_eql): fail early to gain performance.
* string.c (sym_hash): cache hash value in aux.shared if possible.

* gc.c (rb_obj_id): no need to treat symbols specially.

* lib/fileutils.rb (FileUtils::FileUtils): singleton_methods() no
  longer return an array of strings, but of symbols.

* lib/delegate.rb (DelegateClass): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-20 04:18:25 +00:00
matz 2a23c281a1 * string.c (rb_str_intern): allow zero length symbols.
[ruby-core:08861]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-14 07:36:53 +00:00
matz 23d2c8b624 * string.c (rb_str_intern): raise SecurityError only when $SAFE
level is greater than zero.  [ruby-core:08862]

* parse.y (rb_interned_p): new function to check if a string is
  already interned.

* string.c (str_to_id): use rb_str_intern().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-14 07:27:14 +00:00
matz e6340674d1 * string.c (rb_str_intern): allow symbols to contains nul.
* string.c (sym_inspect): symbol may contain nul.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-13 08:19:54 +00:00
matz 96a8a44317 * string.c (rb_str_intern): prohibit interning tainted string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-13 08:15:21 +00:00
matz a36197bd58 * string.c (sym_equal): "sym == str" should compare them as
strings.  [ruby-dev:29554]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-10 22:41:52 +00:00