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

636 Коммитов

Автор SHA1 Сообщение Дата
akr bf2d82b280 * string.c (str_sublen): use rb_enc_strlen.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-17 04:04:14 +00:00
akr 35cb0f807b * string.c (rb_str_times): reduce loop overhead.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-17 00:18:16 +00:00
akr 71c5e48598 * include/ruby/re.h (struct rmatch_offset): new struct for character
offsets.
  (struct rmatch): new struct.
  (struct RMatch): reference struct rmatch.
  (RMATCH_REGS): new macro.

* re.c (match_alloc): initialize struct rmatch.
  (pair_byte_cmp): new function.
  (update_char_offset): update character offsets.
  (match_init_copy): copy regexp and character offsets.
  (match_sublen): removed.
  (match_offset): use update_char_offset.
  (match_begin): ditto.
  (match_end): ditto.
  (rb_reg_search): make character offset updated flag false.
  (match_size): use RMATCH_REGS.
  (match_backref_number): ditto.
  (rb_reg_nth_defined): ditto.
  (rb_reg_nth_match): ditto.
  (rb_reg_match_pre): ditto.
  (rb_reg_match_post): ditto.
  (rb_reg_match_last): ditto.
  (match_array): ditto.
  (match_aref): ditto.
  (match_values_at): ditto.
  (match_inspect): ditto.

* string.c (rb_str_subpat_set): use RMATCH_REGS.
  (rb_str_sub_bang): ditto.
  (str_gsub): ditto.
  (rb_str_split_m): ditto.
  (scan_once): ditto.

* gc.c (obj_free): free character offsets.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 20:08:35 +00:00
naruse 66583d9663 * string.c (rb_str_substr): optimized for UTF-8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 11:53:04 +00:00
naruse bb831578c5 * string.c (str_strlen): revert r15507. [ruby-dev:33810]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 10:06:15 +00:00
naruse 0ad3d7ce2d * string.c (str_strlen): little more optimize.
(rb_enc_nth): remove needless variable 'c'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 09:30:03 +00:00
akr 7eeba5f440 * encoding.c (rb_enc_compatible): empty strings are always compatible.
* string.c (rb_enc_cr_str_buf_cat): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 09:02:12 +00:00
akr a47e8e776c * string.c (rb_enc_strlen): UTF-8 character count moved to str_strlen.
(str_strlen): UTF-8 character count is only applicable for valid
  UTF-8 string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 07:16:36 +00:00
akr 9b3ab49b5d * string.c (rb_str_sub_bang): stringize replacing hash values.
(str_gsub): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 04:17:52 +00:00
naruse 327673a43b * string.c (rb_enc_strlen): add search_nonascii like character
counter for UTF-8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 04:05:58 +00:00
akr af75cc01bc * encoding.c (rb_enc_strlen): moved to string.c.
* string.c (rb_enc_strlen): use search_nonascii.
  (str_strlen): don't use search_nonascii.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 02:55:08 +00:00
naruse 132e3f54f2 * string.c (single_byte_optimizable): rb_enc_mbminlen must be 1
when rb_enc_mbmaxlen is 1.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 20:41:29 +00:00
akr 0831222a91 * encoding.c (rb_enc_nth): moved to string.c.
* string.c (rb_enc_nth): moved from string.c.  use search_nonascii
  for ASCII compatible string.
  (str_nth): wrong optimization removed to fix
  "a".force_encoding("EUC-JP").slice!(0,10) returns
  "a\x00\x00\x00\x00\x00\x00\x00\x00\x00"


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 18:48:27 +00:00
nobu a05337f14d * string.c (rb_str_sub_bang, str_gsub): allows hash for replacement.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 09:23:55 +00:00
matz 8b09f7015a * string.c (str_strlen): use search_nonascii() for performance.
* string.c (str_nth): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 08:14:40 +00:00
akr 12b1578cab * string.c (rb_str_getbyte): new method.
(rb_str_setbyte): new method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 06:35:20 +00:00
matz 38694016bc * string.c (rb_str_hash_cmp): lighter version of rb_str_cmp() for
hash comparison function.

* hash.c (rb_any_cmp): use rb_str_hash_cmp().

* string.c (rb_str_casecmp): should return nil for incompatible
  comparison.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-12 03:17:43 +00:00
matz 0472db84c5 * range.c (range_include): specialize single character string
case (e.g. (?a ..?z).include(?x)) for performance.
  [ruby-core:15481]

* string.c (rb_str_upto): specialize single character case.

* string.c (rb_str_hash): omit coderange scan for performance.

* object.c (rb_check_to_integer): check Fixnum first.

* object.c (rb_to_integer): ditto.

* string.c (rb_str_equal): inline memcmp to avoid unnecessary
  rb_str_comparable(). 

* parse.y (rb_intern2): use US-ASCII encoding.

* parse.y (rb_intern_str): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-11 17:46:52 +00:00
akr 8f9fb1a820 * string.c (rb_str_new4): copy encoding from orig, instead of shared
one.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-09 01:04:29 +00:00
nobu 1809782c3e * string.c (rb_str_replace): makes frozen shared string before
sharing.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-07 10:11:40 +00:00
nobu fb506c3000 * string.c (rb_str_dup): reverted unneeded change. [ruby-dev:33634]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-07 09:57:06 +00:00
nobu 89941dffb5 * string.c (str_replace_shared): replaces string with sharing.
* string.c (rb_str_new4, rb_str_associate, rb_str_associated): allows
  associated strings shared.

* string.c (rb_str_dup, rb_str_substr, rb_str_replace): shares memory.
  [ruby-core:15400]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-07 07:33:50 +00:00
nobu 6c6ae98663 * string.c (rb_str_end_with): compares with the suffix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-07 06:42:44 +00:00
akr 84fe384383 * string.c (rb_str_succ): use wrapped character as a carry for
ASCII incompatible encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-30 05:29:37 +00:00
naruse 3c6969ec11 * string.c, parse.y, re.c: use rb_ascii8bit_encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-28 09:03:09 +00:00
akr fc208c1bd5 * include/ruby/oniguruma.h: precise mbclen API redesigned to avoid
inline functions.
  (onigenc_mbclen_charfound): removed.
  (onigenc_mbclen_needmore): removed.
  (onigenc_mbclen_recover): removed.
  (ONIGENC_MBCLEN_CHARFOUND): removed.
  (ONIGENC_MBCLEN_CHARFOUND_P): defined.
  (ONIGENC_MBCLEN_CHARFOUND_LEN): defined.
  (ONIGENC_MBCLEN_INVALID): removed.
  (ONIGENC_MBCLEN_INVALID_P): defined.
  (ONIGENC_MBCLEN_NEEDMORE): removed.
  (ONIGENC_MBCLEN_NEEDMORE_P): defined.
  (ONIGENC_MBCLEN_NEEDMORE_LEN): defined.
  (ONIGENC_MBC_ENC_LEN): use onigenc_mbclen_approximate.

* regenc.c (onigenc_mbclen_approximate): defined.

* include/ruby/encoding.h (MBCLEN_CHARFOUND): removed.
  (MBCLEN_INVALID): removed.
  (MBCLEN_NEEDMORE): removed.
  (MBCLEN_CHARFOUND_P): defined.
  (MBCLEN_INVALID_P): defined.
  (MBCLEN_NEEDMORE_P): defined.
  (MBCLEN_CHARFOUND_LEN): defined.
  (MBCLEN_NEEDMORE_LEN): defined.

* encoding.c: use new API.

* re.c: ditto.

* string.c: ditto.

* parse.y: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-27 14:27:07 +00:00
akr b8b0f6fd46 * string.c (rb_str_inspect): avoid exception by
"\#\xa1".force_encoding("euc-jp").inspect.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-27 11:09:41 +00:00
akr 36b4d1a1dc * string.c (rb_str_succ): warning suppressed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-27 10:08:58 +00:00
akr b1e6c052cd * string.c (rb_str_succ): don't increment/decrement codepoint.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-27 08:21:24 +00:00
naruse df17bd4313 * string.c (rb_str_new): set US-ASCII and ENC_CODERANGE_7BIT when
empty string (len == 0).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-26 00:18:50 +00:00
naruse 42dcda08ae * string.c (rb_str_usascii_new{,2}: defined.
(rb_str_new): set US-ASCII and ENC_CODERANGE_7BIT when empty
  string.

* encoding.c (rb_usascii_encoding, rb_usascii_encindex): defined.
  (rb_enc_inspect, enc_name, rb_locale_charmap, rb_enc_name_list_i):
  use rb_str_ascii_new.

* array.c (recursive_join, inspect_ary): ditto.

* object.c (nil_to_s, nil_inspect, true_to_s, false_to_s,
  rb_mod_to_s): ditto.

* hash.c (inspect_hash, rb_hash_inspect, rb_f_getenv, env_fetch,
  env_clear, env_to_s, env_inspect): ditto.

* numeric.c (flo_to_s, int_chr, rb_fix2str): ditto.

* bignum.c (rb_big2str): ditto.

* file.c (rb_file_ftype, rb_file_s_dirname, rb_file_s_extname,
  file_inspect_join, Init_file): ditto.

* test/ruby/test_ruby_m17n.rb: add checks for encoding of string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-25 16:40:02 +00:00
akr 3a783ba707 * string.c (rb_str_buf_cat_ascii): use rb_enc_cr_str_buf_cat.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-25 12:50:12 +00:00
akr 1e41069754 * include/ruby/intern.h (rb_str_buf_cat_ascii): declared.
* string.c (rb_str_buf_cat_ascii): defined.

* re.c (rb_reg_s_union): use rb_str_buf_cat_ascii to support ASCII
  incompatible encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-25 07:35:27 +00:00
akr 968e404220 * string.c (rb_enc_cr_str_buf_cat): ASCII incompatible encoding is
not compatible with any other encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-24 02:17:26 +00:00
matz 9580a9ca91 * string.c (rb_str_each_line): use memchr(3) for faster newline
search.

* io.c (appendline): remove unused arguments

* io.c (rb_io_getline_fast): make much simpler (and faster).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-23 18:43:51 +00:00
nobu e94ece76d8 * string.c (str_make_independent): should set length.
* string.c (rb_str_associate): hide associated array from ObjectSpace.

* string.c (rb_str_associated): return associated array with freezing
  instead of false.  [ruby-dev:33282]

* string.c (rb_str_freeze): freeze associated array together.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-23 06:04:13 +00:00
nobu 0c8106ded6 * string.c (str_mod_check, str_nth, str_offset): consitfied.
* string.c (rb_str_dump): dump in ASCII-8BIT always.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-23 02:53:28 +00:00
matz 65a8185eb2 * configure.in (MINIRUBY): remove -I$(EXTOUT)/$(arch) from
MINIRUBY since miniruby might not be able to load DLL.

* test/ruby/test_m17n.rb: move tests from bootstrap test.

* encoding.c (enc_find): should check name if ASCII compatible.

* string.c (rb_str_end_with): should check character boundary.

* encoding.c (rb_enc_compatible): encoding must be ASCII
  compatible before checking ENC_CODERANGE_7BIT.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-22 03:59:53 +00:00
nobu 157664b9f3 * string.c (rb_str_each_char): iterates over a shadow.
[ruby-dev:33243]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-22 00:26:49 +00:00
matz 56be84e293 * parse.y (rb_intern3): do not call rb_enc_mbclen() if *m is
ASCII.  [ruby-talk:287225]

* string.c (rb_str_each_line): use rb_enc_is_newline() to gain
  performance if the record separator ($/) is not modified.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-21 19:47:26 +00:00
nobu 76e19bc534 * string.c (rb_str_each_char): move forward. [ruby-dev:33231]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-21 02:59:02 +00:00
nobu ea64014c56 * string.c (rb_str_each_char): advance offset before get next char
length.  [ruby-dev:33211]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-20 18:45:51 +00:00
nobu 00190701e0 * string.c (rb_str_each_char): performance improvement, and stop if
shortened in the block.  [ruby-dev:33189]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-20 04:06:03 +00:00
akr 35a4fb5ef6 * string.c (coderange_scan): don't call mbclen functions for ASCII
characters with ASCII compatible encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-19 13:42:50 +00:00
matz c58736dbdc * string.c (rb_str_dump): preserve the encoding of source string
if it is ASCII compatible.  otherwise, add '.force_encoding()'
  for ugly work around.  maybe we should implement some other way
  to keep non ASCII encoding in dumped string.  [ruby-dev:33142]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-18 04:49:14 +00:00
akr e350fe247a * string.c (string.c): call rb_str_buf_append to update encoding of
str1, even if str2 is empty.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-11 14:26:26 +00:00
nobu 1267156698 * string.c (rb_str_append): performance improvement.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-11 07:55:23 +00:00
akr 0ada40e2b1 update rdoc: force_encoding doesn't accept nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-11 06:03:51 +00:00
akr 8786b8a282 * string.c (rb_enc_cr_str_buf_cat): fix self appending.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-09 08:00:26 +00:00
nobu 9874fdbc86 * string.c (rb_enc_cr_str_buf_cat, rb_str_buf_append): deal with self
appending.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-09 05:52:20 +00:00
matz 251dec5cf1 * string.c (rb_enc_cr_str_buf_cat): do not recalculate coderange
value if it's given from outside.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-09 04:07:11 +00:00
akr 389abf1b3b * string.c (str_gsub): avoid appending empty pre-match substr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-08 06:04:26 +00:00
akr fc5a26c2d4 * string.c (rb_str_buf_append): fix append itself.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-07 22:57:00 +00:00
akr 7425f59f10 * string.c (STR_ENC_GET): defined. same as rb_enc_get without
enc_capable.
  (coderange_scan): ASCII-8BIT test refined.
  (rb_enc_cr_str_buf_cat): new internal function to accumulate
  strings with encoding.
  (rb_enc_str_buf_cat): use rb_enc_cr_str_buf_cat.
  (rb_str_buf_append): ditto
  (str_gsub): use rb_str_buf_append.
  (rb_str_hash): use ENCODING_GET.
  (rb_str_comparable): ditto.
  (rb_str_cmp): compare encoding index, not rb_encoding address.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-07 16:28:43 +00:00
matz f2707db2dc * string.c (Init_String): sym_match arity spec was wrong. a patch
from Hiroyuki Iwatsuki <don at na.rim.or.jp> in [ruby-dev:32957].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-07 10:12:45 +00:00
akr 3e2fe4a1eb * string.c (str_gsub): move rb_enc_get(str) to out of loop.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-07 09:11:28 +00:00
akr 063beac343 * encoding.c (rb_enc_internal_get_index): extracted from
rb_enc_get_index.
  (rb_enc_internal_set_index): extracted from rb_enc_associate_index

* include/ruby/encoding.h (ENCODING_SET): work over ENCODING_INLINE_MAX.
  (ENCODING_GET): ditto.
  (ENCODING_IS_ASCII8BIT): defined.
  (ENCODING_CODERANGE_SET): defined.

* re.c (rb_reg_fixed_encoding_p): use ENCODING_IS_ASCII8BIT.

* string.c (rb_enc_str_buf_cat): use ENCODING_IS_ASCII8BIT.

* parse.y (reg_fragment_setenc_gen): use ENCODING_IS_ASCII8BIT.

* marshal.c (has_ivars): use ENCODING_IS_ASCII8BIT.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-07 02:49:01 +00:00
akr 9f808343c8 * string.c (coderange_scan): avoid rb_enc_to_index.
(rb_enc_str_buf_cat): ditto.
  (str_cat_char): use rb_enc_str_buf_cat.
  (rb_str_inspect): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 17:37:54 +00:00
akr b2168c5a2a * string.c (coderange_scan): optimize ASCII-8BIT string.
(rb_enc_str_buf_cat): don't call coderange_scan if possible.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 16:38:04 +00:00
akr 6cdef2dc7e * $Date$ keyword removed to avoid inclusion of locale dependent
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 15:49:38 +00:00
akr 8987b97ca9 * include/ruby/encoding.h (rb_enc_str_buf_cat): declared.
* string.c (coderange_scan): extracted from rb_enc_str_coderange.
  (rb_enc_str_coderange): use coderange_scan.
  (rb_str_shared_replace): copy encoding and coderange.
  (rb_enc_str_buf_cat): new function for linear complexity string
  accumulation with encoding.
  (rb_str_sub_bang): don't conflict substituted part and replacement.
  (str_gsub): use rb_enc_str_buf_cat.
  (rb_str_clear): clear coderange.

* re.c (rb_reg_regsub): use rb_enc_str_buf_cat.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 09:25:09 +00:00
nobu 76c2550b5b * string.c (rb_str_resize): copy if old data is not empty
[ruby-core:14785]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-05 07:50:50 +00:00
nobu 80de7a2fe1 * string.c (rb_str_resize): copy at old length but not new length.
[ruby-core:14785]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-05 05:45:40 +00:00
akr 8702c4d0d7 update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-05 03:35:13 +00:00
matz f3fa37e8e5 * string.c (trnext): should enable backslash escape.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-04 17:15:22 +00:00
matz 96e7713754 * string.c (rb_str_substr): offset movement bug. a patch from
Vincent Isambart <vincent.isambart at gmail.com> in
  [ruby-core:14647].  [ruby-core:14644]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-01 05:16:49 +00:00
nobu de3f2adb53 * string.c (rb_str_resize): embeds if ptr is null. [ruby-dev:32819]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-31 14:27:20 +00:00
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