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

760 Коммитов

Автор SHA1 Сообщение Дата
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
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
matz 0f785c3840 * file.c (rb_f_test): test(0) should not have any special
meaning.  [ruby-dev:29425]

* file.c (rb_f_test): properer error message.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-09 16:19:33 +00:00
matz 82f7f29c59 * string.c (str_alloc): should allocate a String object, even when
asked to allocate a Symbol object.  [ruby-dev:29529]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-08 07:55:51 +00:00
matz d314a7dd85 * string.c (sym_equal): override. check equivalence.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-06 16:59:10 +00:00
matz 10a0dea1f5 * string.c (Init_String): undef Symbol#new.
* struct.c (rb_struct_s_def): wrong symbol detection.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-02 15:20:24 +00:00
matz d064c0bf13 * string.c (str_to_id): a bug caused by premature optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-02 15:13:26 +00:00
matz ccf5372b25 * object.c (Init_Object): move symbol related code to string.c
* string.c (Init_String): Symbol as subclass of String.

* parse.y (rb_intern2): handle symbol as strings.

* string.c (str_new): substring of symbols are mere strings, not
  symbols.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-02 15:05:27 +00:00
matz 2156870525 * ruby.h (struct RArray): embed small arrays.
(RARRAY_LEN): defined for accessing array members.
  (RARRAY_PTR): ditto.

* array.c: use RARRAY_LEN and RARRAY_PTR.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-02 14:42:08 +00:00
matz a20d60c819 string.c (rb_str_resize): typo fixed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-01 13:11:16 +00:00
matz 9ba4002960 * string.c (rb_str_resize): should copy embedded string to
malloc'ed buffer.  a patch from <nobu at ruby-lang.org> in
  [ruby-dev:29369].  fixed: [ruby-dev:29368]

* string.c (rb_str_ord): use %ld specifier since STRING_LEN() is a
  long.  [ruby-dev:29369]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-09-01 13:07:05 +00:00
matz 54af80844f * ruby.h (struct RString): embed small strings.
(RSTRING_LEN): defined for accessing string members.
  (RSTRING_PTR): ditto.

* string.c: use RSTRING_LEN and RSTRING_PTR.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-08-31 10:47:44 +00:00
nobu 59b1cef2f1 * numeric.c (flo_hash): improve collision.
* string.c (rb_memhash): new generic function to calculate hash value
  for memory chunk.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-08-30 03:02:35 +00:00
drbrain 8b827f1a7d Describe String#split grouping behavior. Patch by Jan Svitok [ruby-core:08603].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-08-13 05:35:35 +00:00
matz 69be57eb57 * string.c (rb_str_scan): add string modification check.
[ruby-core:7216]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-07-26 07:43:16 +00:00
usa 6f535f34c5 * string.c (rb_str_dump): need to extend len for \b.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-07-11 08:34:28 +00:00
nobu 0fbcc455bd * string.c (rb_str_ord): extract lower byte. fixed: [ruby-dev:28980]
* lib/jcode.rb (String#succ!): fix for 1.9.  fixed: [ruby-dev:28979]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-07-07 08:49:34 +00:00
matz 1564ed2f0a * bignum.c: ruby 1.9 HEAD 64 bit warnings clean up from
<ville.mattila at stonesoft.com>.   [ruby-core:08120]

* ChangeLog: remove some direct reference to mail addresses
  to prevent spams.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-07-03 20:07:10 +00:00
matz d4e2d4ea96 * string.c (rb_str_inspect): encode \b (\010) for escape.
[ruby-dev:28927]

* string.c (rb_str_dump): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-07-02 16:20:16 +00:00
matz 471e41ec70 * string.c: RDoc update for =~ method. a patch from Alex Young
<alex at blackkettle.org>.  [ruby-core:08068]

* io.c (pipe_open): backout unnecessary fix on 2006-06-26.
  [ruby-dev:28865]

* eval.c (rb_yield_0): exact argument number check now done only
  for lambda Proc.

* eval.c (rb_yield_0): add check for number of arguments, if
  there's one lambda block parameter.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-27 14:14:25 +00:00
matz 66de9ef349 * string.c (rb_str_aref): "abc"[3] should not return an empty
string but nil.  [ruby-dev:28786]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-22 01:39:44 +00:00
matz 1b7465e893 * eval.c, file.c, etc.: code-cleanup patch from Stefan Huehner
<stefan at huehner.org>.  [ruby-core:08029]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-20 18:02:17 +00:00
matz d1a5aa5685 * ext/bigdecimal/lib/bigdecimal/newton.rb (Newton::nlsolve): typo
fixed: raize -> raise.  [ruby-talk:196608]

* string.c (rb_str_ord): new method.

* parse.y (rbracket): allow optional newline before closing
  brackets.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-10 16:09:12 +00:00
matz 9b383bd6cf * sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).

* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
  basename and pid.  [ruby-talk:196272]
* parse.y (do_block): remove -> style block.

* parse.y (parser_yylex): remove tLAMBDA_ARG.

* eval.c (rb_call0): binding for the return event hook should have
  consistent scope.  [ruby-core:07928]

* eval.c (proc_invoke): return behavior should depend whether it
  is surrounded by a lambda or a mere block.

* eval.c (formal_assign): handles post splat arguments.

* eval.c (rb_call0): ditto.

* st.c (strhash): use FNV-1a hash.

* parse.y (parser_yylex): removed experimental ';;' terminator.

* eval.c (rb_node_arity): should be aware of post splat arguments.

* eval.c (rb_proc_arity): ditto.

* parse.y (f_args): syntax rule enhanced to support arguments
  after the splat.

* parse.y (block_param): ditto for block parameters.

* parse.y (f_post_arg): mandatory formal arguments after the splat
  argument.

* parse.y (new_args_gen): generate nodes for mandatory formal
  arguments after the splat argument.

* eval.c (rb_eval): dispatch mandatory formal arguments after the
  splat argument.

* parse.y (args): allow more than one splat in the argument list.

* parse.y (method_call): allow aref [] to accept all kind of
  method argument, including assocs, splat, and block argument.

* eval.c (SETUP_ARGS0): prepare block argument as well.

* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]

* eval.c (error_line): print receivers true/false/nil specially.

* eval.c (rb_proc_yield): handles parameters in yield semantics.

* eval.c (nil_yield): gives LocalJumpError to denote no block
  error.

* io.c (rb_io_getc): now takes one-character string.

* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
  hashing algorithm.

* string.c (rb_str_aref): str[0] now returns 1 character string,
  instead of a fixnum.	[Ruby2]

* parse.y (parser_yylex): ?c now returns 1 character string,
  instead of a fixnum.	[Ruby2]

* string.c (rb_str_aset): no longer support fixnum insertion.

* eval.c (umethod_bind): should not update original class.
  [ruby-dev:28636]

* eval.c (ev_const_get): should support constant access from
  within instance_eval().  [ruby-dev:28327]

* time.c (time_timeval): should round for usec floating
  number.  [ruby-core:07896]

* time.c (time_add): ditto.

* dir.c (sys_warning): should not call a vararg function
  rb_sys_warning() indirectly.	[ruby-core:07886]

* numeric.c (flo_divmod): the first element of Float#divmod should
  be an integer. [ruby-dev:28589]

* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.

* re.c (rb_reg_initialize): should not allow modifying literal
  regexps.  frozen check moved from rb_reg_initialize_m as well.

* re.c (rb_reg_initialize): should not modify untainted objects in
  safe levels higher than 3.

* re.c (rb_memcmp): type change from char* to const void*.

* dir.c (dir_close): should not close untainted dir stream.

* dir.c (GetDIR): add tainted/frozen check for each dir operation.

* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
  typo fixed.  a patch from Florian Gross <florg at florg.net>.

* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
  event_hooks.	no guarantee for arbitrary hook deletion.
  [ruby-dev:28632]

* util.c (ruby_strtod): differ addition to minimize error.
  [ruby-dev:28619]

* util.c (ruby_strtod): should not raise ERANGE when the input
  string does not have any digits.  [ruby-dev:28629]

* eval.c (proc_invoke): should restore old ruby_frame->block.
  thanks to ts <decoux at moulon.inra.fr>.  [ruby-core:07833]
  also fix [ruby-dev:28614] as well.

* signal.c (trap): sig should be less then NSIG.  Coverity found
  this bug.  a patch from Kevin Tew <tewk at tewk.com>.
  [ruby-core:07823]

* math.c (math_log2): add new method inspired by
  [ruby-talk:191237].

* math.c (math_log): add optional base argument to Math::log().
  [ruby-talk:191308]

* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
  uninitialized array element.	a patch from Pat Eyler
  <rubypate at gmail.com>.  [ruby-core:07809]

* array.c (rb_ary_fill): initialize local variables first.  a
  patch from Pat Eyler <rubypate at gmail.com>.	 [ruby-core:07810]

* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
  type_tag.  a patch from Pat Eyler <rubypate at gmail.com>.
  [ruby-core:07808]

* ext/socket/socket.c (make_hostent_internal): accept ai_family
  check from Sam Roberts <sroberts at uniserve.com>.
  [ruby-core:07691]

* util.c (ruby_strtod): should not cut off 18 digits for no
  reason.  [ruby-core:07796]

* array.c (rb_ary_fill): internalize local variable "beg" to
  pacify Coverity.  [ruby-core:07770]

* pack.c (pack_unpack): now supports CRLF newlines.  a patch from
  <tommy at tmtm.org>.	[ruby-dev:28601]

* applied code clean-up patch from Stefan Huehner
  <stefan at huehner.org>.  [ruby-core:07764]

* lib/jcode.rb (String::tr_s): should have translated non
  squeezing character sequence (i.e. a character) as well.  thanks
  to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]

* ext/socket/socket.c: document update patch from Sam Roberts
  <sroberts at uniserve.com>.  [ruby-core:07701]

* lib/mathn.rb (Integer): need not to remove gcd2.  a patch from
  NARUSE, Yui <naruse at airemix.com>.	[ruby-dev:28570]

* parse.y (arg): too much NEW_LIST()

* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.

* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
  [ruby-dev:28585]

* parse.y (arg): use NODE_ARGSCAT for placeholder.

* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
  mathew <meta at pobox.com>.  [ruby-core:07738]

* variable.c (rb_const_set): raise error when no target klass is
  supplied.  [ruby-dev:28582]

* prec.c (prec_prec_f): documentation patch from
  <gerardo.santana at gmail.com>.  [ruby-core:07689]

* bignum.c (rb_big_pow): second operand may be too big even if
  it's a Fixnum.  [ruby-talk:187984]

* README.EXT: update symbol description.  [ruby-talk:188104]

* COPYING: explicitly note GPLv2.  [ruby-talk:187922]

* parse.y: remove some obsolete syntax rules (unparenthesized
  method calls in argument list).

* eval.c (rb_call0): insecure calling should be checked for non
  NODE_SCOPE method invocations too.

* eval.c (rb_alias): should preserve the current safe level as
  well as method definition.

* process.c (rb_f_sleep): remove RDoc description about SIGALRM
  which is not valid on the current implementation. [ruby-dev:28464]

 Thu Mar 23 21:40:47 2006  K.Kosako  <sndgk393 AT ybb.ne.jp>

* eval.c (method_missing): should support argument splat in
  super.  a bug in combination of super, splat and
  method_missing.  [ruby-talk:185438]

* configure.in: Solaris SunPro compiler -rapth patch from
  <kuwa at labs.fujitsu.com>.  [ruby-dev:28443]

* configure.in: remove enable_rpath=no for Solaris.
  [ruby-dev:28440]

* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
  of converting  OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
  String object.

* ruby.1: a clarification patch from David Lutterkort
  <dlutter at redhat.com>.  [ruby-core:7508]

* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
  directories.	a patch from Eric Hodel <drbrain at segment7.net>.
  [ruby-core:07423]

* eval.c (rb_clear_cache_by_class): clearing wrong cache.

* ext/extmk.rb: use :remove_destination to install extension libraries
  to avoid SEGV.  [ruby-dev:28417]

* eval.c (rb_thread_fd_writable): should not re-schedule output
  from KILLED thread (must be error printing).

* array.c (rb_ary_flatten_bang): allow specifying recursion
  level.  [ruby-talk:182170]

* array.c (rb_ary_flatten): ditto.

* gc.c (add_heap): a heap_slots may overflow.  a patch from Stefan
  Weil <weil at mail.berlios.de>.

* eval.c (rb_call): use separate cache for fcall/vcall
  invocation.

* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
  functions.

* eval.c (rb_mod_local): a new method to specify newly added
  visibility "local".

* eval.c (search_method): search for local methods which are
  visible only from the current class.

* class.c (rb_class_local_methods): a method to list local methods.

* object.c (Init_Object): add BasicObject class as a top level
  BlankSlate class.

* ruby.h (SYM2ID): should not cast to signed long.
  [ruby-core:07414]

* class.c (rb_include_module): allow module duplication.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 21:20:17 +00:00
kosako 2025346077 RDoc description updated
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-03-24 12:14:18 +00:00
kosako 0fa1086760 add back reference by name in replace string
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-03-22 15:03:40 +00:00
ocean 7621057054 * string.c: fixed typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-02-14 11:38:29 +00:00
akr 5b8e80e9eb unused function uscore_get removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-12-29 17:03:27 +00:00
matz de3bff164c * eval.c (rb_mod_define_method): should save safe_level in the
proc object.  [ruby-dev:28146]

* test/drb/drbtest.rb (DRbService::self.ext_service): increase
  timeout limit.  a patch from Kazuhiro NISHIYAMA
  <zn at mbf.nifty.com>. [ruby-dev:28132]

* eval.c (ev_const_get): fixed a bug in constant reference during
  instance_eval.  [yarv-dev:707]

* eval.c (ev_const_defined): ditto.

* lib/yaml.rb (YAML::add_domain_type): typo fixed.  a patch from
  Joel VanderWerf <vjoel at path.berkeley.edu>.
  [ruby-talk:165285] [ruby-core:6995]

* ext/digest/sha2/sha2.c (ULL): support AIX C.  a patch from
  Kailden <kailden at gmail.com>.  [ruby-core:06984]

* ext/syck/rubyext.c (rb_syck_compile): avoid potential memory
  leak.

* ext/syck/rubyext.c (syck_set_ivars): avoid potential memory
  leak by explicit symbol allocation.

* lib/delegate.rb (Delegator::method_missing): should delegate
  block as well.

* lib/cgi.rb (CGI::QueryExtension::MorphingBody): fix criteria to
  use Tempfile.  A fix from Zev Blut <rubyzbibd at ubit.com>.
  [ruby-core:06076]

* string.c: remove global functions work on $_.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-12-29 12:05:16 +00:00
matz c6b9f16231 * string.c (scan_once): wrong condition to use mbclen2().
[ruby-dev:27535]

* time.c (time_sunday): added predicate methods for the days of the
  week.  [ruby-list:41340]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-27 08:18:38 +00:00
matz ffe2293998 * test/socket/test_tcp.rb (TestTCPSocket::test_recvfrom): typo
fixed.  [ruby-dev:27123]

* string.c (rb_str_substr): should propagate taintness even for
  empty strings.  [ruby-dev:27121]

* string.c (rb_str_aref): should infect result if range argument
  is tainted.  [ruby-dev:27121]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-17 14:40:06 +00:00
ocean 08c1738c51 * bignum.c: changed `foo _((boo))' to `foo(boo)`. [ruby-dev:27056]
* defines.h, dir.c, dln.h, enumerator.c, env.h, error.c, eval.c, file.c,
  gc.c, hash.c, inits.c, intern.h, io.c, lex.c, marshal.c, missing.h,
  node.h, numeric.c, pack.c, process.c, re.h, ruby.c, ruby.h, rubyio.h,
  rubysig.h, signal.c, sprintf.c, st.h, string.c, struct.c, time.c,
  util.c, util.h, variable.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-14 06:32:32 +00:00
ocean 54b23dd6b5 * string.c, missing.h: failed to build on powerpc-apple-darwin7.9.0
because of crypt argument's constness mismatch. (I hope this works)
  (http://mput.dip.jp/autobuild/ruby-trunk/log/20050913T110001.gz)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-13 05:35:27 +00:00
ocean dda5dc00cf * array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
   other platforms. And  `foo _((boo))' stuff is still there)
   [ruby-dev:26975]

* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
  io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
  prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
  regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
  sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
  version.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 10:44:21 +00:00
nobu 7d41159212 * string.c (rb_str_times): make empty strings to keep taintness,
and a little improvement.  [ruby-dev:26900]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-09 07:35:31 +00:00
matz f1efc08bb1 * missing/strchr.c (strrchr): fixed a bug for detecting NUL in a
string.  [ruby-dev:26985]

* string.c (rb_str_times): should taint empty strings as well.

* object.c (Init_Object): make class_variable_{get,set} public.
  [ruby-dev:26965]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-08 04:42:46 +00:00
nobu 8dcf7f931f * string.c (rb_str_scan): already String#scan behaves differently
regarding if block is given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-08-30 21:59:12 +00:00
nobu 74433fd300 * array.c, dir.c, enum.c, hash.c, io.c, range.c, string.c, struct.c:
let enumerable methods return Enumerator.  [ruby-dev:26924]

* intern.h (RETURN_ENUMERATOR): utility macro for enumerable methods.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-08-30 14:49:51 +00:00
nobu 6524f34a26 * sprintf.c (rb_vsprintf, rb_sprintf): new functions return new String,
using missing/vsnprintf.c.  [ruby-dev:26580]

*  missing/vsnprintf.c: made the output changeable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-07-23 01:02:18 +00:00
matz 70bbad3cfd * array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.

* eval.c (rb_exec_recursive): new function.

* array.c (rb_ary_join): use rb_exec_recursive().

* array.c (rb_ary_inspect, rb_ary_hash): ditto.

* file.c (rb_file_join): ditto.

* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.

* io.c (rb_io_puts): ditto.

* object.c (rb_obj_inspect): ditto

* struct.c (rb_struct_inspect): ditto.

* lib/set.rb (SortedSet::setup): a hack to shut up warning.
  [ruby-talk:132866]

* lib/time.rb (Time::strptime): add new function.  inspired by
  [ruby-talk:132815].

* lib/parsedate.rb (ParseDate::strptime): ditto.

* regparse.c: move st_*_strend() functions from st.c.  fixed some
  potential memory leaks.

* exception error messages updated.  [ruby-core:04497]

* ext/socket/socket.c (Init_socket): add bunch of Socket
  constants.  Patch from Sam Roberts <sroberts@uniserve.com>.
  [ruby-core:04409]

* array.c (rb_ary_s_create): no need for negative argc check.
  [ruby-core:04463]

* array.c (rb_ary_unshift_m): ditto.

* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
  of StandardError class, not Exception class.  [ruby-core:04429]

* parse.y (fcall_gen): lvar(arg) will be evaluated as
  lvar.call(arg) when lvar is a defined local variable. [new]

* object.c (rb_class_initialize): call inherited method before
  calling initializing block.

* eval.c (rb_thread_start_1): initialize newly pushed frame.

* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
  fixed: [ruby-core:04444]

* eval.c (is_defined): NODE_IASGN is an assignment.

* ext/readline/readline.c (Readline.readline): use rl_outstream
  and rl_instream.  [ruby-dev:25699]

* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
  [ruby-dev:25675]

* misc/ruby-mode.el: [ruby-core:04415]

* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]

* lib/rdoc/generators/ri_generator.rb: ditto.

* struct.c (make_struct): fixed: [ruby-core:04402]

* ext/curses/curses.c (window_color_set): [ruby-core:04393]

* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
  [ruby-talk:130092]

* object.c: [ruby-doc:818]

* parse.y (open_args): fix too verbose warnings for the space
  before argument parentheses.  [ruby-dev:25492]

* parse.y (parser_yylex): ditto.

* parse.y (parser_yylex): the first expression in the parentheses
  should not be a command.  [ruby-dev:25492]

* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]

* object.c (Init_Object): remove Object#type.  [ruby-core:04335]

* st.c (st_foreach): report success/failure by return value.
  [ruby-Bugs-1396]

* parse.y: forgot to initialize parser struct.  [ruby-dev:25492]

* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
  [ruby-talk:127711]

* document updates - [ruby-core:04296], [ruby-core:04301],
  [ruby-core:04302], [ruby-core:04307]

* dir.c (rb_push_glob): should work for NUL delimited patterns.

* dir.c (rb_glob2): should aware of offset in the pattern.

* string.c (rb_str_new4): should propagate taintedness.

* env.h: rename member names in struct FRAME; last_func -> callee,
  orig_func -> this_func, last_class -> this_class.

* struct.c (rb_struct_set): use original method name, not callee
  name, to retrieve member slot.  [ruby-core:04268]

* time.c (time_strftime): protect from format modification from GC
  finalizers.

* object.c (Init_Object): remove rb_obj_id_obsolete()

* eval.c (rb_mod_define_method): incomplete subclass check.
  [ruby-dev:25464]

* gc.c (rb_data_object_alloc): klass may be NULL.
  [ruby-list:40498]

* bignum.c (rb_big_rand): should return positive random number.
  [ruby-dev:25401]

* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
  random bignums.  [ruby-dev:25396]

* variable.c (rb_autoload): [ruby-dev:25373]

* eval.c (svalue_to_avalue): [ruby-dev:25366]

* string.c (rb_str_justify): [ruby-dev:25367]

* io.c (rb_f_select): [ruby-dev:25312]

* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]

* struct.c (make_struct): [ruby-dev:25249]

* dir.c (dir_open_dir): new function.  [ruby-dev:25242]

* io.c (rb_f_open): add type check for return value from to_open.

* lib/pstore.rb (PStore#transaction): Use the empty content when a
  file is not found.  [ruby-dev:24561]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 06:47:45 +00:00
nobu afd7aea857 * string.c (rb_str_justify): create buffer string after argument type
conversion.  fixed: [ruby-dev:25341]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-28 13:32:28 +00:00
nobu e326946b35 * string.c (rb_str_inspect): escape # which starts an expression
substitution.  fixed: [ruby-core:03922]

* string.c (rb_str_dump): not escape # which isn't a substitution.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-12-09 05:38:59 +00:00
matz 83cb605d69 * object.c (convert_type): [ruby-core:03845]
* eval.c (rb_funcall_rescue): new function.

* object.c (rb_Array): avoid using rb_respond_to().

* object.c (rb_Integer): ditto.

* eval.c (get_backtrace): no conversion for nil.

* parse.y (reduce_nodes): empty body should return nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-29 06:09:40 +00:00
matz 51c48c29d8 * configure.in: AC_PREREQ(2.53) [ruby-core:03800]
* io.c (read_all): [ruby-dev:24955]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-25 01:58:31 +00:00
matz 688c69b1f7 * string.c (rb_str_splice): should place index wrapping after
possible modification.  [ruby-dev:24940]

* eval.c (error_print): nicer traceback at interrupt.
  [ruby-core:03774]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-20 15:18:35 +00:00
matz 77a23fba35 * string.c (str_gsub): internal buffer should not be listed by
ObjectSpace.each_object() by String#gsub.  [ruby-dev:24931]

* lib/cgi/session.rb (CGI::Session::FileStore::initialize): raise
  exception if data corresponding to session specified from the
  client does not exist.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-19 16:59:11 +00:00
matz 5e2c8a40c3 * string.c (str_gsub): internal buffer should not be listed by
ObjectSpace.each_object().  [ruby-dev:24919]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-18 16:02:08 +00:00
matz 288ceaeec2 * re.c (rb_reg_initialize_m): should raise exception instead of
compile error.  [ruby-core:03755]

* string.c (rb_str_splice): move rb_str_modify() after
  StringValue(), which may alter the receiver.  [ruby-dev:24878]

* error.c (rb_error_frozen): now raise RuntimeError instead of
  TypeError.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-17 02:27:38 +00:00
matz b93479b8d9 * string.c (str_mod_check): frozen check should be separated.
[ruby-core:3742]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-16 04:55:14 +00:00
matz 67d54f209d * array.c (rb_ary_update): pedantic check to detect
rb_ary_to_ary() to modify the receiver.  [ruby-dev:24861]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-15 16:45:03 +00:00
matz 0f36ecebe0 * string.c (rb_str_clear): avoid revealing NULL pointer.
[ruby-dev:24766]

* string.c (str_gsub): add paranoid check. [ruby-dev:24827]

* string.c (str_mod_check): check frozen status as well.
  [ruby-dev:24801]

* lib/mathn.rb (Integer::gcd2): faster implementation by
  <erlercw@siu.edu>. [ruby-talk:120232]

* ext/gdbm/gdbm.c (fgdbm_store): StringValue() may alter string
  pointer.  [ruby-dev:24783]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-14 15:41:40 +00:00
matz 683400f427 * dir.c (rb_glob2): do not allocate buffer from heap to avoid
memory leaks.  use string object for buffering instead.
  [ruby-dev:24738]

* dir.c (join_path): ditto.

* io.c (io_read): external input buffer may be modified even after
  rb_str_locktmp().  [ruby-dev:24735]

* dir.c (fnmatch): p or s may be NULL.  [ruby-dev:24749]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-10 07:17:53 +00:00
matz 28d67a0bfe * string.c (str_gsub): should have removed rb_str_unlocktmp(str).
[ruby-dev:24708]

* ext/socket/socket.c (s_recvfrom): buffer modification check.
  [ruby-dev:24708]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 23:43:40 +00:00
matz 67ae0fb9ac * string.c (str_gsub): string modify check no longer based on
tmplock.  [ruby-dev:24706]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 12:27:57 +00:00
matz 27715649f4 * gc.c (gc_mark): enable GC stack checking.
* string.c (str_gsub): lock strings temporarily.  [ruby-dev:24687]

* ext/socket/socket.c (s_recvfrom): tmplock input buffer.
  [ruby-dev:24705]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-04 00:53:21 +00:00
matz 3be03e9294 * array.c (rb_ary_uniq_bang): do not push frozen string from hash
table.  [ruby-dev:24695]

* array.c (rb_ary_and): ditto.

* array.c (rb_ary_or): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-11-03 11:34:57 +00:00
matz 8db864c999 * io.c (rb_f_open): create copy of popen specifier. [ruby-dev:24656]
* string.c (rb_str_locktmp): lock string temporarily.

* string.c (str_independent): add tmplock check.

* io.c (io_write): lock output string temporarily.
  [ruby-dev:24649]

* io.c (io_write): use rb_str_locktmp().

* io.c (read_all): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-31 17:37:52 +00:00
nobu 4fabf11840 * string.c (str_gsub): use STR_NOCAPA.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-27 15:23:16 +00:00
matz 018837b84f * node.h (NODE_TYPESHIFT): allow 4 more bits for line numbers.
[ruby-talk:117841]

* ruby.h (FL_ABLE): nodes are not subject for flag operations.

* io.c (ARGF_FORWARD): should have specified argv explicitly,
  since we no longer have frame->argv saved.  [ruby-dev:24602]

* string.c (RESIZE_CAPA): check string attribute before modifying
  capacity member of string structure.  [ruby-dev:24594]

* ext/zlib/zlib.c (gzreader_gets): use memchr() to to gain
  performance.  [ruby-talk:117701]

* sprintf.c (rb_f_sprintf): raise ArgumentError for extra
  arguments, unless (digit)$ style used.

* io.c (rb_io_fptr_finalize): leave stdin/stdout/stderr open in
  interpreter termination.  [ruby-dev:24579]

* eval.c (frame_free): Guy Decoux solved the leak problem.
  Thanks.  [ruby-core:03549]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-27 09:29:26 +00:00
nobu ee51d0f9fd * string.c (str_gsub): use a string object for exception safeness.
[ruby-dev:24601]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-27 00:18:08 +00:00
nobu 0f3decb071 * string.c (rb_str_include): should not treat char as negative value.
[ruby-dev:24558]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-21 15:21:08 +00:00
matz 7d7d82463d * parse.y (lex_getline): should not touch ruby_debug_lines if
RIPPER is defined.  [ruby-dev:24547]

* string.c (str_gsub): 	reentrant check.  [ruby-dev:24432]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-20 15:44:06 +00:00
matz 1057902ac7 * io.c (read_all): block string buffer modification during
rb_io_fread() by freezing it temporarily. [ruby-dev:24479]

* dir.c (rb_push_glob): block call at once the end of method.
  [ruby-dev:24487]

* ext/enumerator/enumerator.c (enum_each_slice): remove
  rb_gc_force_recycle() to prevent potential SEGV.
  [ruby-dev:24499]

* ext/zlib/zlib.c (zstream_expand_buffer): hide internal string
  buffer by clearing klass.  [ruby-dev:24510]

* ext/socket/socket.c (sock_s_getservbyaname): protocol string
  might be altered.  [ruby-dev:24503]

* string.c (rb_str_upto): check if return value from succ is a
  string.  [ruby-dev:24504]

* io.c (rb_io_popen): get mode string via rb_io_flags_mode() to
  avoid mode string modification.  [ruby-dev:24454]

* io.c (rb_io_getline_fast): should take delim as unsigned char to
  distinguish EOF and '\377'.  [ruby-dev:24460]

* io.c (rb_io_getline): add check for RS modification.
  [ruby-dev:24461]

* enum.c (enum_sort_by): use qsort() directly instead using
  rb_iterate().  [ruby-dev:24462]

* enum.c (enum_each_with_index): remove rb_gc_force_recycle() to
  prevent access to recycled object (via continuation for
  example).  [ruby-dev:24463]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-19 10:25:23 +00:00
nobu 9bd744a092 * indent and tabify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-19 00:03:01 +00:00
nobu 39324f819f * string.c (rb_str_upto): method result must be checked. [ruby-dev:24504]
* eval.c (error_print): ditto.  [ruby-dev:24519]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-18 23:47:32 +00:00
matz fbb88b011a * io.c (rb_io_mode_flags): preserve append mode flag.
[ruby-dev:24436]

* io.c (rb_io_modenum_mode): do not use external output buffer.

* string.c (rb_str_justify): differ pointer retrieval to prevent
  padding string modification.  [ruby-dev:24434]

* range.c (range_each_func): allow func to terminate loop by
  returning RANGE_EACH_BREAK.

* range.c (member_i): use RANGE_EACH_BREAK. [ruby-talk:114959]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-06 07:40:06 +00:00
matz 77636d0364 * string.c (rb_str_sum): should use bignums when bits is greater
than or equals to sizeof(long)*CHAR_BITS. [ruby-dev:24395]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-02 11:30:40 +00:00
matz 779f3d6d11 * string.c (rb_str_sum): wrong cast caused wrong result.
[ruby-dev:24385]

* enum.c (enum_sort_by): hide temporary array from
  ObjectSpace.each_object.  [ruby-dev:24386]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-02 07:57:32 +00:00
matz 9d923be604 * string.c (rb_str_sum): check was done with false pointer.
[ruby-dev:24383]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-02 03:49:15 +00:00
matz 1b4d97ddba * string.c (rb_str_sum): string may be altered. [ruby-dev:24381]
* eval.c (rb_f_eval): defer pointer retrieval to prevent unsafe
  sourcefile string modification.  [ruby-dev:24373]

* io.c (io_read): block string buffer modification during
  rb_io_fread() by freezing it temporarily. [ruby-dev:24366]

* io.c (rb_io_s_popen): mode argument may be altered.
  [ruby-dev:24375]

* file.c (rb_file_s_basename): ext argument may be altered.
  [ruby-dev:24377]

* enum.c (enum_sort_by): use NODE instead of 2 element arrays.
  [ruby-dev:24378]

* string.c (rb_str_chomp_bang): StringValue() may change the
  receiver.  [ruby-dev:24371]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-10-01 15:56:05 +00:00
matz c0a998d027 * parse.y (rb_parser_append_print): should handle prelude.
[llama@u01.gate0]

* parse.y (rb_parser_while_loop): ditto.

* array.c (rb_ary_subseq): original object might be modified after
  sharing data creation.  [ruby-dev:24327]

* array.c (rb_ary_replace): ditto.

* array.c (ary_make_shared): freeze shared array. [ruby-dev:24325]

* struct.c (struct_members): always check struct size and size of
  members list in the class.  [ruby-dev:24320]

* string.c (rb_str_sub_bang): check if string is not modified
  during iteration.  [ruby-dev:24315]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-09-24 05:53:43 +00:00
matz e77ddaf0d1 * array.c (rb_ary_delete): element comparison might change array
size. [ruby-dev:24273]

* parse.y: make ruby parser reentrant. merge ripper parser to the
  real one.  this change makes ruby require bison.

* file.c (rb_file_truncate): clear stdio buffer before truncating
  the file.  [ruby-dev:24191]

* ext/digest/digest.c: use rb_obj_class() instead of CLASS_OF
  which might return singleton class.  [ruby-dev:24202]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-09-17 09:24:13 +00:00
matz d73fa69935 * dir.c (free_dir): fix memory leak. reported by yamamoto
madoka.

* eval.c (bind_eval): new method. [RCR 251]

* string.c (rb_str_clear): new method. [ruby-dev:24104]

* io.c (rb_io_reopen): should clear allocated OpenFile.  pointed
  out by Guy Decoux. [ruby-core:03288]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-08-19 07:33:15 +00:00
matz 67232b2151 * io.c (rb_io_reopen): should clear allocated OpenFile. pointed
out by Guy Decoux. [ruby-core:03288]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-08-17 09:02:40 +00:00
matz 280d014d6d * range.c (rb_range_beg_len): returns Qnil only when "beg" points
outside of a range.  No boundary check for "end".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-07-24 09:48:21 +00:00
matz 83fa0928d7 * string.c (rb_str_match_m): String#match should also take
optional argument.  [ruby-core:03205]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-07-17 08:02:20 +00:00
matz 4b33ed994b * string.c (str_new4): should share shared instance if it already
exists.  [ruby-dev:23665]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-06-05 02:33:01 +00:00
matz 6a60393280 * range.c (range_each_func): terminates loop if generating value
is same to @end.  [ruby-talk:100269]

* string.c (rb_str_new4): should not reuse frozen shared string if
  the original is not an instance of String. [ruby-talk:100193]

* time.c (time_mdump): preserve GMT bit in the marshal data.
  [ruby-talk:100213]

* eval.c (is_defined): do not protect exception during receiver
  evaluation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-05-14 16:39:15 +00:00
matz 1b0f90ca33 * parse.y (string_content): turn off NODE_NEWLINE flag to avoid
unnecessary line trace for inlined expression.
  (ruby-bugs PR#1320)

* numeric.c (flo_to_s): tweak output string based to preserve
  decimal point and to remove trailing zeros.  [ruby-talk:97891]

* string.c (rb_str_index_m): use unsigned comparison for T_FIXNUM
  search.  [ruby-talk:97342]

* hash.c (rb_hash_equal): returns true if two hashes have same set
  of key-value set.  [ruby-talk:97559]

* hash.c (rb_hash_eql): returns true if two hashes are equal and
  have same default values.

* string.c (rb_str_equal): always returns true or false, never
  returns nil. [ruby-dev:23404]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-05-07 08:44:24 +00:00
nobu d952e33003 * array.c, enum.c, eval.c, file.c, io.c, numeric.c, object.c, prec.c,
process.c, re.c, string.c: typos in RDoc comments.  [ruby-core:02783]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-04-14 04:06:52 +00:00
matz 919f456de8 * exception message clean-up by Ian Macdonald <ian@caliban.org>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-03-29 07:54:38 +00:00
matz 2fab242f66 * eval.c (rb_yield_0): should not re-submit TAG_BREAK if this
yield is not break destination. [ruby-dev:23197]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-03-15 02:27:29 +00:00
usa d255aa7b69 * string.c (rb_str_match): raise TypeError when both arguments are
strings. [ruby-dev:22851]

* string.c (rb_str_match2): removed.

* Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub,
  wince/Makefile.sub (string.c): now not depend on version.h.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2004-02-10 05:36:34 +00:00
dave 349f4e7db7 Add RDoc for kernel functions, and tidy up
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-12-30 16:38:32 +00:00
usa 3e16f5a3f0 * string.c (rb_str_update): don't return any value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-12-25 13:30:39 +00:00
matz f7d46c8860 * string.c (rb_str_update): call rb_str_modify().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-12-25 08:49:20 +00:00
dave 2d83cd85ee MG added RDoc comments to string.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-12-24 21:14:46 +00:00
nobu a503181049 * string.c (rb_str_update): get rid of SEGV at just allocated String.
[ruby-core:01812]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-30 00:35:28 +00:00
usa 81160e93c9 * string.c: add #include "version.h". this file still depends on it.
* Makefile.in, bcc32/Makefile.sub, win32/Makefile.sub,
  wince/Makefile.sub: add version.h dependency to string.c.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-05 02:15:27 +00:00
eban da191c4547 * class.c, hash.c, string.c: remove #include "version.h".
* Makefile.in: remove needless version.h dependency.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-04 14:40:30 +00:00
matz a4934a42cb * io.c (read_all): fptr->f may be NULL, if IO is closed in the
signal handler.

* io.c (io_read): ditto.

* string.c (get_pat): remove 1.8.0 warning code.

* string.c (rb_str_match): extend warning until 1.8.2.

* string.c (rb_str_match2): ditto.

* class.c (class_instance_method_list): remove 1.8.0 warnings.
  method_list now recurs.  [ruby-dev:21816]

* class.c (rb_obj_singleton_methods): ditto.

* array.c (rb_ary_select): remove select with block.
  [ruby-dev:21824]

* hash.c (rb_hash_select): ditto.

* hash.c (env_select): ditto.

* re.c (match_select): ditto.

* struct.c (rb_struct_select): ditto.

* process.c (check_uid_switch): remove duplicated error messages.

* process.c (check_gid_switch): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-04 09:13:57 +00:00
knu fe85bcd644 * string.c (rb_str_hash): Update the HASH_PERL alternative hash
algorithm in sync with Perl 5.8.

* st.c (strhash): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-01 16:16:31 +00:00
matz 231d3e9654 * string.c (rb_str_upto): ("a"..."a").to_a should return [].
[ruby-core:01634]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-16 08:01:15 +00:00
matz 1184373d86 * string.c (str_new4): should not preserve FL_TAINT status in the
internal shared string. [ruby-dev:21601]

* string.c (rb_str_new4): ditto.

* eval.c: use EXIT_SUCCESS and EXIT_FAILURE for exit values.

* process.c: ditto. [ruby-dev:38521]

* lib/debug.rb (debug_command): should enter emacs mode when
  assigned any value to the environment variable "EMACS".
  On Meadow, (getenv "EMACS") is "meadow".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-13 13:05:24 +00:00
matz c492b9b085 * eval.c (mark_frame_adj): need to adjust argv pointer if using
system's alloca. [ruby-core:01503]

* io.c (rb_f_gets): should call next_argv() before type check
  current_file. [ruby-list:38336]

* eval.c (proc_invoke): should retrieve retval when pcall is true.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-09-05 05:07:54 +00:00
matz 22b955d9bf * eval.c (rb_eval): *a = [1,2] now assigns [[1,2]] to a.
consistent with *a = [1], which set [[1]] to a.

* node.h: merge NODE_RESTARY to NODE_SPLAT.

* parse.y: rules simplified a bit by removing NODE_RESTARY.

* sample/test.rb: updated for new assignment behavior.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-08-27 19:43:50 +00:00
matz 7ff7bcbf9d * enum.c (inject_i): use rb_yield_values.
* enum.c (each_with_index_i): ditto.

* eval.c (rb_yield_splat): new function to call "yield *values".

* string.c (rb_str_scan): use rb_yield_splat().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-08-22 08:09:58 +00:00
matz 808aa5f318 * lib/shell/command-processor.rb (Shell::CommandProcessor::rmdir):
simple typo.

* string.c (str_new4): ptr may refer null_str.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-08-05 09:27:21 +00:00
matz 029e9449ce * ruby.c (proc_options): -F set compiled regular expression to $;.
[ruby-talk:77381]

* string.c (Init_String): no setter type check for $;


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-30 07:08:56 +00:00
matz dbe85f1ef0 * string.c (rb_str_chomp_bang): defer rb_str_modify() to actual
modify point.  other methods, replace, tr, delete, squeeze,
  lstrip, and rstrip as well.

* string.c (rb_str_rstrip_bang): remove trailing '\0' at the end
  of string.

* string.c (rb_str_lstrip_bang): do not strip '\0' from the left.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-27 17:20:29 +00:00
matz e02b469de1 * eval.c (thgroup_add): no warning for terminated threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-24 05:18:47 +00:00
matz 2436525ed8 * string.c (rb_str_lstrip_bang): strip NUL along with white
spaces. [ruby-talk:76659]

* string.c (rb_str_rstrip_bang): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-23 06:48:52 +00:00
matz fa284f8127 * string.c (rb_str_equal): should return nil for non string
operand to conform comparable convention. [ruby-dev:20759]

* object.c (rb_equal): preserve nil if "==" returns nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-21 18:37:07 +00:00
matz e4de8e7566 * string.c: use StringValueCStr to retrieve paths to system calls.
* string.c (rb_string_value_cstr): check null byte in the string
  before retrieving C ptr.  accessed via macro StringValueCStr.

* file.c (sys_fail2): raise error for two operand system calls
  such as rename, link, symlink.  (ruby-bugs PR#1047)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-20 17:17:52 +00:00
matz fe4de8b4b8 * string.c (rb_str_match2): add warning to "~string".
[ruby-list:37751]

* lib/net/ftp.rb (Net::FTP::open): takes block.  suggested by Gavin
  Sinclair in [ruby-core:01237].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-19 17:26:04 +00:00
matz 9d22a06ea0 * array.c (rb_values_at): extract common procedure from
rb_ary_values_at.  follow DRY principle.

* re.c (match_values_at): values_at should understand ranges.

* struct.c (rb_struct_values_at): ditto.

* struct.c (inspect_struct): inspect format changed; add "struct "
  at the top.

* sprintf.c (rb_f_sprintf): "%p" specifier for inspect output.
  (RCR#68)

* eval.c (rb_mod_undef_method): allow "undef_method" to accept
  multiple arguments. (RCR#146)

* lib/timeout.rb: put timeout in Timeout module. (RCR#121)
  [ruby-talk:61028]

* re.c (match_groups): new method added. (RCR#139)

* variable.c (rb_mod_const_of): should exclude constant defined
  in Object, unless retrieving constants of Object.

* string.c (rb_str_new4): do not allocate new string if original
  is frozen or already have copy-on-write entry. [ruby-talk:74940]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-03 11:02:53 +00:00
matz 447578a8a0 * string.c (rb_str_shared_replace): clear flags before copy.
* string.c (rb_str_replace): ditto.

* eval.c (rb_yield_0): override visibility mode for module_eval
  etc. (ruby-bugs-ja PR#505)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-07-02 04:27:29 +00:00
nobu 057dcc0495 * string.c (rb_str_split_m): remove white spaces on the head of
the last element, when limit is specified.  [ruby-talk:74506]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-27 05:41:28 +00:00
nobu 7a425f71e3 * io.c (io_fflush): need to check if closed after thread switch.
[ruby-dev:20351]

* io.c (fptr_finalize): ditto.

* string.c (rb_str_rindex_m): fixed wrong fix.  should move backward
  first only when matching from the end.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-26 18:24:58 +00:00
nobu d061e2aab7 sorry, typo again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-23 08:45:59 +00:00
nobu 61927637e8 typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-23 08:45:09 +00:00
nobu 69459d98ef * dir.c (find_dirsep): get rid of warnings.
* eval.c (error_print): temporary value might be disposed by GC.

* hash.c (env_has_value, env_index): should not increment NULL.

* io.c (io_read, rb_io_sysread): not read when length is 0.

* io.c (rb_io_reopen): ensure initialized IO.

* io.c (rb_io_init_copy): sychronize file pointer.

* io.c (rb_io_s_pipe): make exception proof.

* string.c (rb_str_rindex_m): Fixnum 0 matched end of string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-23 08:41:07 +00:00
matz 67dcad92b7 * string.c (rb_str_upto): generate sequence according to "succ"
order.  formerly check was done by dictionary order.
  [ruby-talk:74138]

* string.c (rb_string_value): fill constant empty string along
  with setting ELTS_SHARED if str->ptr is NULL. [ruby-core:01179]

* string.c (rb_string_value_ptr): ditto.

* string.c (rb_check_string_type): ditto.

* string.c (str_gsub): move END(0) check before mbclen2().

* string.c (scan_once): reduce END(0) check.

* io.c (rb_io_initialize): accept fixnum mode.

* eval.c (error_print): replace strchr() by memchr(), einfo may
  contain "\0".

* pack.c (pack_unpack): range check for "@" move; initialize check
  for "m".

* error.c (syserr_initialize): avoid buffer overflow.

* file.c (rb_file_s_readlink): expand buffer until readlink
  succeed.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-23 06:52:39 +00:00
matz b4fd4d6018 * eval.c (Init_Proc): Block/Proc separation. [huge change]
* eval.c (block_arity): returns exact arity number for Procs out
  of methods. also gives 1 for {|a|..}.

* string.c (rb_str_match): revert use of String#index for
  invocation like string =~ string.

* eval.c (rb_Array): move Object#to_a exclusion hack from
  splat_value().  need to be in eval.c for a while.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-26 08:22:33 +00:00
aamine e08bc0a22a * class.c: add #include "version.h".
* hash.c: ditto.
* string.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-19 07:11:48 +00:00
matz 6e52d10fe6 * object.c (init_copy): rename copy_object as initialize_copy,
since it works as copy constructor.

* eval.c (rb_add_method): initialize_copy should always be
  private, like initialize.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-19 05:41:08 +00:00
matz 776e2693e7 * string.c (rb_str_ljust): now takes optional argument to specify
pad string. [ruby-talk:70482]

* string.c (rb_str_rjust): ditto.

* string.c (rb_str_center): ditto.

* string.c (rb_str_justify): utility function.

* eval.c (rb_add_method): call singleton_method_added or
  method_added for every method definition (after ruby_running).
  [ruby-talk:70471]

* array.c (rb_ary_reverse_bang): Array#reverse! should not return
  nil even for arrays sized less than 2.

* io.c (argf_eof): should not block after reading all argument
  files. (ruby-bugs-ja PR#449)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-02 06:41:33 +00:00
nobu 93695ed08a * string.c (rb_str_to_i): disallow negative radix.
[ruby-dev:20087]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-04-27 14:13:25 +00:00
matz f34f20ebc5 * rubyio.h (struct OpenFile): add error raise flag to finalizer.
* io.c (Init_IO): define $/, $-0, and $\ as string-only
  variables.

* string.c (rb_str_split_m): does not generate empty string if
  there's no match in the receiver.

* io.c (fptr_finalize): should raise error on EBADF for readable
  IOs as well.

* file.c (rb_stat): use rb_check_convert_type() to retrieve IO.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3679 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-04-14 09:04:43 +00:00
nobu 3f4472433d * bignum.c (rb_cstr_to_inum, rb_big2str): allow 2-36 as radix.
* numeric.c (rb_fix2str): ditto.

* string.c (rb_str_to_i): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-04-14 06:54:27 +00:00
nobu 1072ad1c2b * string.c (rb_str_capitalize_bang): check length before upcase
first character.  (ruby-bugs:PR#697)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-03-26 18:26:45 +00:00
matz 9d77639f30 * parse.y (dsym): :"symbol string" style should not contain `\0'.
* process.c (proc_detach): new method Proc#detach(pid) which
  create background watcher thread to issue waitpid. [new]

* process.c (rb_detach_process): utility function to detach
  process from C code.

* ext/pty/pty.c (pty_finalize_syswait): terminate watcher thread,
  and detach child process (by creating new idle waitpid watcher
  thread).

* ext/pty/pty.c (pty_syswait): may lost signal stopped child.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-03-07 05:59:42 +00:00
matz e5c5576aeb * string.c (str_new): need no MEMZERO().
* numeric.c (fix_gt): use rb_num_coerce_cmp() instead of
  rb_num_coerce_bin.

* numeric.c (fix_ge, fix_lt, fix_le): ditto.

* numeric.c (flo_gt, flo_ge, flo_lt, flo_le): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-27 08:04:32 +00:00
matz ca014ae071 * string.c (rb_str_cmp_m): should use LONG2NUM().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-21 09:32:18 +00:00
matz b3686317a7 * string.c (rb_str_cmp_m): two small bugs fixed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-21 03:52:27 +00:00
matz 64db238388 * string.c (rb_str_cmp_m): return nil if str2 does not respond to
both "to_str" and "<=>".

* compar.c (cmp_gt): return nil if "<=>" returns nil (means
  incomparable).

* compar.c (cmp_ge): ditto.

* compar.c (cmp_lt): ditto.

* compar.c (cmp_between): use RTEST(), since cmp_lt and cmp_gt may
  return nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-20 20:40:20 +00:00
matz ab24be4e98 * array.c (rb_ary_to_a): return value should be an Array if the
receiver is an instance of subclass of Array.

* string.c (rb_str_to_s): return value should be a String if the
  receiver is an instance of subclass of String.

* eval.c (rb_call): calls method_missing when superclass method
  does not exist.

* eval.c (rb_f_missing): now handles "no super" case.

* object.c (rb_obj_ivar_get): Object#instance_variable_get: new
  method to get instance variable value without eval(). [new]

* object.c (rb_obj_ivar_set): Object#instance_variable_set: new
  method to set instance variable value without eval(). [new]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-10 09:40:13 +00:00
nobu a4d9a91b96 re-indented.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-07 06:36:53 +00:00
nobu 34033db665 * intern.h, re.c (rb_memsearch): returns long.
* string.c (rb_str_index): should return offset position.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-07 06:35:26 +00:00
matz e2b92403d5 * re.c (rb_reg_initialize_m): 3rd argument was ignored.
* string.c (rb_str_count): return 0 for empty string (was
  returning nil).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-06 08:25:12 +00:00
matz 1d5e19f624 * array.c (rb_ary_equal): a == b is true when b is non T_ARRAY
object, if b has "to_ary" and b == a.

* hash.c (rb_hash_equal): a == b is true when b is non T_HASH
  object, if b has "to_hash" and b == a.

* string.c (rb_str_equal): a == b is true when b is non T_STRING
  object, if b has "to_str" and b == a.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-04 07:27:43 +00:00
matz 467035750e * object.c (Init_Object): default Object#=== now calls "=="
internally.

* re.c (rb_reg_initialize_m): should honor option status of
  original regexp.

* array.c (rb_ary_equal): ary2 should be T_ARRAY (no to_ary
  conversion).

* array.c (rb_ary_eql): ditto.

* string.c (rb_str_equal): str2 should be T_STRING (no to_str
  conversion).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-03 08:45:26 +00:00
matz 0c90036fd1 * re.c (rb_memsearch): algolithm body of String#index.
* error.c (Init_Exception): "to_str" removed.

* eval.c (eval): should not rely on Exception#to_str

* eval.c (compile_error): ditto.

* error.c (err_append): ditto.

* hash.c (rb_hash_merge): Hash#merge, non destructive "update".
  now there's also Hash#merge! which is an alias to "update".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-03 05:34:16 +00:00
matz d18922065b * string.c (rb_str_index): search using Karp-Rabin algolithm.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-31 06:48:54 +00:00
matz 74d5623029 * variable.c (rb_obj_classname): new function.
* string.c (rb_str_dup): should preserve original's class (but not
  hidden singleton class).

* string.c (rb_str_substr): ditto.

* parse.y: backout EXPR_CMDARG removal.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-31 04:00:17 +00:00
matz f758195486 * parse.y (yylex): remove EXPR_CMDARG according to the RHG book.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-31 03:15:33 +00:00
michal 9df466b287 Updated Copyrights of Matz to 2003.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-16 07:34:03 +00:00
nobu c39a8e326a * string.c (rb_str_substr): should share the shared string if
present, instead of the original string.  (ruby-bugs:PR#528)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-30 07:55:17 +00:00
usa b469f3155a * array.c (ary_alloc), dir.c (dir_s_alloc), eval.c (thgroup_s_alloc),
file.c (rb_stat_s_alloc), hash.c (hash_alloc), io.c (io_alloc),
  object.c (rb_module_s_alloc, rb_class_allocate_instance),
  re.c (match_alloc, rb_reg_s_alloc), string.c (str_alloc),
  time.c (time_s_alloc), ext/digest/digest.c (rb_digest_base_alloc),
  ext/tcltklib/tcltklib.c (ip_alloc),
  ext/win32ole/win32ole.c (fole_s_allocate, fev_s_allocate)
  : add prototype to get rid of VC++ warnings.

* ext/sdbm/init.c (fsdbm_alloc): allocator takes only one argument.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-21 18:02:01 +00:00
matz bc49bc7c6b * parse.y (do_block): split "do" block and tLBRACE_ARG block.
* parse.y (cmd_brace_block): new tLBRACE_ARG block rule

* parse.y (command): can take optional cmd_brace_block; use %prec
  to resolve shift/reduce conflict. (ruby-bugs-ja PR#372)

* eval.c (ruby_finalize): trace_func should be cleared here (after
  executing exit procs and finalizers).

* eval.c (rb_define_alloc_func): new allocation framework, based
  on Nobu's work [ruby-dev:19116].  "allocate" method is no longer
  used for object allocation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-20 08:33:17 +00:00
matz baa00aa250 * numeric.c (num_step): use DBL_EPSILON.
* array.c (rb_check_array_type): new function: return an array
  (convert if possible), or nil.

* string.c (rb_check_string_type): new function: return a string
  (convert if possible), or nil.

* numeric.c (rb_dbl_cmp): returns nil if values are not
  comparable.

* numeric.c (fix_cmp,flo_cmp): use rb_num_coerce_cmp()

* bignum.c (rb_big_cmp): ditto.

* numeric.c (rb_num_coerce_cmp): new coercing function for "<=>",
  which does not raise TypeError.

* numeric.c (do_coerce): can be supress exception now.

* object.c (rb_mod_cmp): should return nil for non class/module
  objects.

* re.c (rb_reg_eqq): return false if the argument is not a
  string.  now returns boolean value.

* class.c (rb_include_module): argument should be T_MODULE, not
  T_class, nor T_ICLASS.

* eval.c (is_defined): "defined?" should return "assignment" for
  attribute assignment (e.g. a.foo=b) and indexed assignment
  (e.g. a[2] = 44).

* parse.y (aryset): use NODE_ATTRASGN.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-19 09:20:20 +00:00
nobu f8c8a38d30 * string.c (rb_str_dup_frozen): handle tail shared string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-18 11:50:49 +00:00
nobu f4b8bbb143 * string.c (rb_str_new4): handle tail shared string.
(ruby-bugs-ja:PR#370)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-17 18:20:46 +00:00
nobu 86db656415 * node.h (NODE_ATTRASGN): new node, assignment to attribute.
[ruby-core:00637].

* eval.c (is_defined, rb_eval): ditto.

* parse.y (attrset, node_assign): ditto.

* string.c (rb_str_substr): tail sharing.  [ruby-core:00650]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-17 10:34:30 +00:00
matz 60b2446bea * sprintf.c (rb_f_sprintf): preceding ".." for negative numbers
still left;  removed.

* sprintf.c (rb_f_sprintf): should not prepend '0' if width > prec
  for example "%5.3d".

* process.c (Init_process): add Process.exit and Process.abort

* pack.c (utf8_to_uv): raise ArgumentError for malformed/redundant
  UTF-8 sequences.

* process.c (last_status_set): add pid attribute to Process::Status.

* pack.c (uv_to_utf8): limit maximum length of the encoded string
  to 6 bytes, even when the platform supports 8 bytes long integers.

* pack.c (utf8_to_uv): do not decode sequences longer than 6 bytes.

* object.c (copy_object): use "copy_object" method, not "become".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-10 06:23:44 +00:00
matz aae36756dc * object.c (Init_Object): added Object#object_id, new name for
Object#id. [new]

* object.c (rb_obj_id_obsolete): give warning for Object#id.

* numeric.c (fix_intern): added Fixnum#to_sym. [new]

* object.c (sym_to_sym): rename from Symbol#intern

* enum.c (enum_zip): added Enumerable#zip. [new]

* array.c (rb_ary_zip): added Array#zip.

* error.c (init_syserr): remove sys_nerr dependency.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-11-03 11:04:35 +00:00
aamine 42e292ae33 * string.c (rb_str_split_m): RSTRING(str)->ptr might become NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-10-24 17:54:53 +00:00
nobu d4f2f6a7f7 * eval.c (rb_eval): added NODE_DSYM, symbol literal with
interpolation.

* node.h: ditto.

* intern.h: prototypes; rb_is_junk_id, rb_str_dump, rb_str_intern

* object.c (sym_inspect): escape and quote for non-alphanumeric
  symbols.

* parse.y (dsym, tokadd_string, yylex): extended symbol literals.

* parse.y (rb_is_junk_id): added.

* string.c (rb_str_dump, rb_str_intern) : make extern.

* lib/mkmf.rb (create_makefile): deffile should be removed by
  distclean, not clean.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-10-23 10:17:30 +00:00
matz 4b9a7eac05 * io.c (appendline): forget to terminate with nul.
* eval.c (ruby_run): should set toplevel visibility again here.

* eval.c (rb_eval): should not rely on ruby_class == rb_cObject
  check.   Besides allow implicit publicity for attribute set
  methods.

* parse.y (primary): need not to check class_nest, just set
  whether method is an attrset or not.

* string.c (rb_str_each_line): p might be at the top of the
  string.

* class.c (rb_make_metaclass): class of metaclass should be
  metaclass of superclass, unless class itself is a metaclass;
  class of metaclass of metaclass should point back to self.
  eh, confusing, isn't it.

* class.c (rb_singleton_class): check if its class is singleton
  AND attached to self.

* eval.c (rb_eval): should define class/module under ruby_cbase.

* eval.c (rb_eval): should set class/module path based on
  ruby_cbase, not ruby_class.

* eval.c (module_setup): use ruby_cbase instead of ruby_class.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-25 07:03:05 +00:00
michal 449f885d62 Fix-Addons [ruby-core:483] with corrections from [ruby-core:484]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-13 08:26:35 +00:00
matz b031fdbc0e * dir.c (glob_helper): prevent memory leak using rb_protect().
* string.c (rb_str_associate): no need to check freeze flag.

* string.c (rb_str_resize): should honor STR_ASSOC flag on
  resize.

* string.c (rb_str_resize): proper STR_ASSOC handling.  pointed
  out by Michal Rokos.

* string.c (rb_str_buf_cat): ditto.

* string.c (rb_str_cat): ditto.

* string.c (rb_str_buf_append): ditto.

* string.c (rb_str_append): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-12 06:27:15 +00:00
knu b9e3aa30f7 * string.c (get_pat): Add an extra argument "quote".
* string.c (rb_str_match_m): Do not bother to convert if a regexp
  is given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-11 04:05:36 +00:00
matz 6f484e4930 * variable.c (rb_copy_generic_ivar): remove old generic instance
variable table if it existes.

	* class.c (rb_make_metaclass): metaclass of a metaclass is a
	  metaclass itself.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-03 05:20:14 +00:00
matz 40bc4f5ae4 * array.c (rb_ary_become): should not free ptr if it's shared.
* eval.c (rb_alias): prohibit making an alias named "allocate" if
  klass is a metaclass.

* string.c (rb_string_value_ptr): StringValuePtr() should never
  return NULL pointer.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-29 09:08:18 +00:00
michal 0d0ae37e50 Int vs Long cleanup #3 (ruby-core:352)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-28 08:05:23 +00:00
matz 1a44a463af * string.c (rb_str_delete_bang): should check if str->ptr is 0.
* string.c (rb_str_squeeze_bang): ditto.

* string.c (rb_str_count): ditto.

* string.c (rb_str_lstrip_bang): ditto.

* string.c (rb_str_rstrip_bang): ditto.

* string.c (rb_str_intern): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-28 06:01:58 +00:00
eban 087f010ddb * string.c (rb_str_rstrip_bang): don't access address -1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-27 10:24:24 +00:00
matz c45908e41f * file.c (rb_find_file): $LOAD_PATH must not be empty.
* file.c (rb_find_file_ext): ditto.

* range.c (range_eq): class check should be based on range.class,
  instead of Range to work with Range.dup.

* range.c (range_eql): ditto.

* class.c (rb_mod_dup): need to preserve metaclass and flags.

* object.c (rb_cstr_to_dbl): had a buffer overrun.

* marshal.c (w_class): integrate singleton check into a funciton
  to follow DRY principle.

* marshal.c (w_uclass): should check singleton method.

* object.c (rb_obj_dup): dmark and dfree functions must be match
  for T_DATA type.

* object.c (rb_obj_dup): class of the duped object must be match
  to the class of the original.

* re.c (rb_reg_quote): do not escape \t, \f, \r, \n, for they are
  not regular expression metacharacters.

* time.c (time_s_alloc): use time_free instead of free (null check,
  also serves for type mark).

* time.c (time_s_at): check dfree function too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-27 08:31:08 +00:00
michal ffc13a6525 *.c: Int vs Long cleanup
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-21 15:47:54 +00:00
usa fc2a1ad79f * string.c (rb_str_rindex): must return -1 if unmatched.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-08-06 06:20:43 +00:00
matz 7194b66fb2 * random.c: replace with Mersenne Twister RNG.
* eval.c (jump_tag_but_local_jump): preserve retval in
  LocalJumpError exceptions.

* parse.y (command): no more check for "super outside of method".

* eval.c (rb_mod_define_method): should set last_class and
  last_func in the block->frame.

* eval.c (error_handle): should handle TAG_THROW as well.

* parse.y (yylex): new decimal notation '0d4567'.

* parse.y (yylex): new octal notation '0o777'.

* parse.y (string_content): every string_content node should
  return string only.  use NODE_EVSTR to coercing.

* eval.c (rb_eval): NODE_EVSTR support.

* re.c (rb_reg_quote): avoid unnecessary string allocation.

* string.c (get_pat): quote metachracters before compiling a
  string into a regex.

* string.c (rb_str_split_m): special treatment of strings of size
  1, but AWK emulation.  now uses get_pat().

* string.c (rb_str_match_m): quote metacharacters.

* string.c (rb_str_match2): ditto.

* ext/socket/socket.c (sock_addrinfo): make all 3 versions of
  getaddrinfo happy.  [ruby-core:00184]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-07-26 06:12:39 +00:00