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

415 Коммитов

Автор SHA1 Сообщение Дата
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