mame
6bacaabffd
* string.c (rb_str_cmp): fix condition which always returned true
...
because ENCODING_GET returns unsigned long.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-29 16:30:02 +00:00
matz
3896936492
* string.c (rb_str_dump): should have removed commented out
...
unnecessary code. [ruby-cvs:27131]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-24 10:58:33 +00:00
shyouhei
78d2b00893
* string.c (rb_str_dump): do not use C++ comment.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-24 10:30:09 +00:00
matz
5a8db29b59
* string.c (rb_str_dump): use \u{ff} escape for UTF-8 encoding
...
string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-23 06:53:55 +00:00
matz
38c7a687e1
* string.c (rb_str_conv_enc_opts): new function to convert with
...
specifying ecflags and ecopts.
* ext/zlib/zlib.c (gzfile_newstr): specify ecflags and ecopts for
conversion using above function.
* ext/zlib/zlib.c (gzfile_newstr): use own rb_econv_t for dummy
encoding to handling stateful encoding (e.g. iso-2022-jp).
[ruby-dev:36857]
* ext/zlib/zlib.c (gzfile_getc): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-22 16:53:50 +00:00
matz
4a3f2a7bc5
* string.c (rb_external_str_new_with_enc): no implicit strlen call.
...
[ruby-dev:36854]
* string.c (rb_external_str_new_cstr): new function to create
string from external NUL terminated C string.
* string.c (rb_locale_str_new_cstr): ditto.
* ext/readline/readline.c: now use rb_locale_str_new_cstr().
* test/sdbm/test_sdbm.rb (TestSDBM#test_delete_with_block):
deleted key to the block may be a copy of specified key.
* test/dbm/test_dbm.rb (TestDBM#test_delete_with_block): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-22 05:55:22 +00:00
matz
fa127bbb18
* string.c (rb_external_str_new_with_enc): wrong condition to
...
calculate strlen().
* ext/readline/readline.c: add encoding support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 15:52:07 +00:00
matz
b6ef272d02
* ext/zlib/zlib.c: remove obsolete prototype macros.
...
* ext/zlib/zlib.c (struct gzfile): add encoding field to gzfile
structure.
* ext/zlib/zlib.c (rb_gzreader_getc): now works on characters.
* ext/zlib/zlib.c (rb_gzreader_getbyte): new method to retrieve
single byte.
* ext/zlib/zlib.c (rb_gzreader_readbyte): ditto.
* ext/zlib/zlib.c (rb_gzreader_each_byte): renamed from each_char
* ext/zlib/zlib.c (rb_gzreader_ungetc): allow unget strings.
* ext/zlib/zlib.c (rb_gzreader_ungetbyte): renamed from ungetc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 09:18:34 +00:00
matz
6259c87d02
* include/ruby/ruby.h (ExportStringValue): new macro to convert
...
string in internal encoding to external to export.
* string.c (rb_str_export): new function to do conversion to
external encoding.
* ext/sdbm/init.c: encoding conversion support.
* ext/dbm/dbm.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-20 08:05:44 +00:00
matz
52b3e3b97f
* string.c (rb_locale_str_new): new function to convert string
...
from locale to internal encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-20 07:15:19 +00:00
matz
3f0ec8887f
* string.c (rb_external_str_new): a new function to convert from
...
external encoding to internal encoding. if something went
wrong, it returns a string with the external encoding.
* string.c (rb_external_str_new_with_enc): same as above besides
you can specify the source encoding.
* ruby.c (ruby_set_argv): use rb_external_str_new()
* ruby.c (set_arg0, ruby_script): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-18 10:36:20 +00:00
matz
1e8bbf3154
* .gdbinit (rp): REGEXP handling fixed.
...
* string.c (rb_str_rindex_m): need not to call rb_enc_check on
regexp.
* re.c (unescape_escaped_nonascii): try ASCII-8BIT encoding for
broken strings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-16 22:21:42 +00:00
matz
f2f2cd5bc6
* string.c (rb_str_comparable): string comparison should be
...
transitive. [ruby-dev:36484]
* test/ruby/test_m17n_comb.rb (TestM17NComb#test_str_eq): test
updated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-06 03:22:56 +00:00
akr
bd421aa2d2
* string.c (rb_str_sub_bang): fix coderange.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-02 11:46:40 +00:00
matz
d370a79c69
* string.c (rb_str_split_m): should use rb_str_subseq() which use
...
offset and length by bytes. [ruby-dev:36641]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-30 16:18:27 +00:00
akr
eace50a9d7
* string.c (rb_str_subseq): don't use rb_str_drop_bytes for short
...
string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-29 14:39:20 +00:00
akr
ebb3ace825
* string.c (rb_str_subseq): use rb_str_drop_bytes if possible.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-29 11:56:43 +00:00
nobu
8d397604bf
* string.c (str_new): sets empty string to coderange 7bit.
...
[ruby-core:18993]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-28 03:04:21 +00:00
usa
00e9e27b69
* string.c (rb_str_rstrip_bang): raise exception when the encoding of
...
the string is dummy.
* string.c (rb_str_rstrip_bang): remove nul characters even if the
encoding of the string is not single byte optimizable.
fixed [ruby-core:18844], reported by Michael Selig.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-24 14:01:41 +00:00
usa
a69021a699
* string.c (rb_str_strip_bang): workaround for VC++8 x64.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-24 10:04:20 +00:00
matz
922048adee
* string.c (rb_str_rstrip_bang): removing mixed spaces and nuls at
...
the end of strings. [ruby-dev:36497]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-24 07:00:43 +00:00
akr
e7e5b731c2
* string.c (rb_str_casecmp): make the ordering consistent with
...
String#<=>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 12:27:35 +00:00
matz
c3e2e0e53f
* string.c (rb_str_comparable): make ascii8bit string to be
...
compatible with any other encoding.
* string.c (rb_str_cmp): use rb_str_comparable() instead of
rb_enc_compatible() since <=> is a comparison anyway.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-18 13:17:41 +00:00
akr
081c802cb9
* grapheme cluster implementation reverted. [ruby-dev:36375]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-18 12:53:25 +00:00
akr
635b15d662
* string.c (rb_str_casecmp): don't use rb_enc_codepoint.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-17 12:50:52 +00:00
akr
a67d4fa01c
* include/ruby/oniguruma.h (OnigEncodingTypeST): add precise_ret
...
argument for mbc_to_code.
(ONIGENC_MBC_TO_CODE): provide NULL for precise_ret.
(ONIGENC_MBC_PRECISE_CODEPOINT): defined.
* include/ruby/encoding.h (rb_enc_mbc_precise_codepoint): defined.
* regenc.h (onigenc_single_byte_mbc_to_code): precise_ret argument
added.
(onigenc_mbn_mbc_to_code): ditto.
* regenc.c (onigenc_single_byte_mbc_to_code): precise_ret argument
added.
(onigenc_mbn_mbc_to_code): ditto.
* string.c (count_utf8_lead_bytes_with_word): removed.
(str_utf8_nth): removed.
(str_utf8_offset): removed.
(str_strlen): UTF-8 codepoint oriented optimization removed.
(rb_str_substr): ditto.
(enc_succ_char): use rb_enc_mbc_precise_codepoint.
(enc_pred_char): ditto.
(rb_str_succ): ditto.
* encoding.c (rb_enc_ascget): check length with
rb_enc_mbc_precise_codepoint.
(rb_enc_codepoint): use rb_enc_mbc_precise_codepoint.
* regexec.c (string_cmp_ic): add text_end argument.
(match_at): check end of character after exact string matches.
* enc/utf_8.c (graphme_table): defined for extended graphme cluster
boundary.
(grapheme_cmp): defined.
(get_grapheme_properties): defined.
(grapheme_boundary_p): defined.
(MAX_BYTES_LENGTH): defined.
(comb_char_enc_len): defined.
(mbc_to_code0): extracted from mbc_to_code.
(mbc_to_code): use mbc_to_code0.
(left_adjust_combchar_head): defined.
(utf_8): use a extended graphme cluster as a unit.
* enc/unicode.c (onigenc_unicode_mbc_case_fold): use
ONIGENC_MBC_PRECISE_CODEPOINT to extract codepoints.
(onigenc_unicode_get_case_fold_codes_by_str): ditto.
* enc/euc_jp.c (mbc_to_code): follow mbc_to_code field change.
use onigenc_mbn_mbc_to_code.
* enc/shift_jis.c (mbc_to_code): ditto.
* enc/emacs_mule.c (mbc_to_code): ditto.
* enc/gbk.c (gbk_mbc_to_code): follow mbc_to_code field and
onigenc_mbn_mbc_to_code change.
* enc/cp949.c (cp949_mbc_to_code): ditto.
* enc/big5.c (big5_mbc_to_code): ditto.
* enc/euc_tw.c (euctw_mbc_to_code): ditto.
* enc/euc_kr.c (euckr_mbc_to_code): ditto.
* enc/gb18030.c (gb18030_mbc_to_code): ditto.
* enc/utf_32be.c (utf32be_mbc_to_code): follow mbc_to_code field
change.
* enc/utf_16be.c (utf16be_mbc_to_code): ditto.
* enc/utf_32le.c (utf32le_mbc_to_code): ditto.
* enc/utf_16le.c (utf16le_mbc_to_code): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-16 16:48:05 +00:00
naruse
8b31af74b7
* string.c (rb_str_concat): fix rdoc. (codepoint is integer)
...
* string.c (rb_str_each_codepoint): use UINT2NUM.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-16 13:23:16 +00:00
nobu
507658bd54
* string.c (rb_str_crypt): orthodox crypt() sees only first two bytes
...
of salt.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-16 12:33:40 +00:00
matz
0df867f933
* string.c (rb_str_each_codepoint): add new methods, #codepoints
...
and #each_codepoint. a patch from Michael Selig
<michael.selig at fs.com.au> in [ruby-core:18532].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-16 03:14:41 +00:00
matz
377eb14a9f
* string.c ():
...
* string.c ():
* string.c (single_byte_optimizable): make function inline. based
on a patch from Michael Selig <michael.selig at fs.com.au> in
[ruby-core:18532].
* string.c (str_modify_keep_cr): new function act as
rb_str_modify(), but don't clear coderange
* string.c (rb_str_casecmp): specialized for single byte strings.
* string.c (rb_str_splice): preserve coderange.
* string.c (rb_str_slice_bang, rb_str_reverse_bang,
rb_str_upcase_bang, rb_str_downcase_bang, tr_trans,
rb_str_capitalize_bang, rb_str_swapcase_bang,
rb_str_delete_bang, rb_str_chop_bang, rb_str_chomp_bang,
rb_str_lstrip_bang, rb_str_rstrip_bang): ditto.
* string.c (rb_str_clear): preset coderange.
* string.c (rb_str_split_m): specialized for splitting with a
string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-16 00:47:20 +00:00
naruse
b0c70a8856
* string.c (rb_str_buf_cat_ascii): codepoint is unsigned int.
...
* string.c (rb_str_concat): ditto.
* string.c (str_cat_char): ditto.
* string.c (prefix_escape): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 17:05:00 +00:00
matz
b121e47b44
* string.c (rb_str_squeeze_bang): specialized for 7bit characters in
...
ASCII compatible strings.
* string.c (rb_str_count): ditto.
* string.c (tr_trans): preserve 7bit/valid coderange flag.
* string.c (rb_str_squeeze_bang): preserve previous coderange value.
* string.c (rb_str_lstrip_bang): ditto.
* string.c (rb_str_rstrip_bang): ditto.
* encoding.c (rb_default_external_encoding): preserve
default_external_encoding in a static variable.
* string.c (single_byte_optimizable): check coderange first, to
reduce number of calling rb_enc_from_index().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 14:40:00 +00:00
naruse
0791d297dd
* encoding.c (RUBY_MAX_CHAR_LEN): defined.
...
* encoding.c (str_cat_char): use RUBY_MAX_CHAR_LEN.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 05:36:15 +00:00
akr
19416601a0
* include/ruby/oniguruma.h (OnigEncodingTypeST): add end argument for
...
left_adjust_char_head.
(ONIGENC_LEFT_ADJUST_CHAR_HEAD): add end argument.
(onigenc_get_left_adjust_char_head): ditto.
* include/ruby/encoding.h (rb_enc_left_char_head): add end argument.
* regenc.h (onigenc_single_byte_left_adjust_char_head): ditto.
* regenc.c (onigenc_get_right_adjust_char_head): follow the interface
change.
(onigenc_get_right_adjust_char_head_with_prev): ditto.
(onigenc_get_prev_char_head): ditto.
(onigenc_step_back): ditto.
(onigenc_get_left_adjust_char_head): ditto.
(onigenc_single_byte_code_to_mbc): ditto.
* re.c: ditto.
* string.c: ditto.
* io.c: ditto.
* regexec.c: ditto.
* enc/euc_jp.c: ditto.
* enc/cp949.c: ditto.
* enc/shift_jis.c: ditto.
* enc/gbk.c: ditto.
* enc/big5.c: ditto.
* enc/euc_tw.c: ditto.
* enc/euc_kr.c: ditto.
* enc/emacs_mule.c: ditto.
* enc/gb18030.c: ditto.
* enc/utf_8.c: ditto.
* enc/utf_16le.c: ditto.
* enc/utf_16be.c: ditto.
* enc/utf_32le.c: ditto.
* enc/utf_32be.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-13 19:23:52 +00:00
akr
a953d28e3c
* include/ruby/oniguruma.h (onigenc_get_prev_char_head): add end
...
argument.
* include/ruby/encoding.h (rb_enc_prev_char): ditto.
* regenc.c (onigenc_get_prev_char_head): add end argument.
* regparse.c: follow the interface change.
* regexec.c: ditto.
* string.c: ditto.
* parse.y: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-13 18:22:04 +00:00
akr
c965010582
* include/ruby/oniguruma.h (onigenc_get_right_adjust_char_head): add
...
end argument.
* include/ruby/encoding.h (rb_enc_right_char_head): add end argument.
* regenc.c (onigenc_get_right_adjust_char_head): use end argument.
* re.c (rb_reg_adjust_startpos): follow the interface change.
* string.c (rb_str_index): ditto.
* regexec.c (backward_search_range): ditto.
(onig_search): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-13 16:40:31 +00:00
naruse
d51b061565
* include/ruby/oniguruma.h (OnigCodePoint): unsigned long to unsigned int.
...
* include/ruby/encoding.h (rb_enc_codepoint): ditto.
* encoding.c (rb_enc_codepoint): signed int to unsigned int.
* encoding.c (rb_enc_ascget): ditto.
* string.c (rb_str_casecmp): ditto.
* string.c (enc_succ_alnum_char): ditto.
* string.c (rb_str_inspect): ditto.
* string.c (rb_str_upcase_bang): ditto.
* string.c (rb_str_downcase_bang): ditto.
* string.c (rb_str_capitalize_bang): ditto.
* string.c (rb_str_swapcase_bang): ditto.
* string.c (struct tr): ditto.
* string.c (trnext): ditto.
* string.c (tr_trans): ditto.
* string.c (tr_setup_table): ditto.
* string.c (tr_find): ditto.
* string.c (rb_str_delete_bang): ditto.
* string.c (rb_str_squeeze_bang): ditto.
* string.c (rb_str_count): ditto.
* string.c (rb_str_split_m): ditto.
* string.c (rb_str_each_line): ditto.
* string.c (rb_str_lstrip_bang): ditto.
* string.c (rb_str_rstrip_bang): ditto.
* string.c (rb_str_intern): ditto.
* dir.c (char_casecmp): ditto.
* sprintf.c (rb_str_format): ditto.
* enc/emacs_mule.c (mbc_to_code): to be 32bit clean.
* enc/emacs_mule.c (code_to_mbc): ditto.
* enc/gb18030.c (mbc_to_code): ditto.
* enc/gb18030.c (code_to_mbc): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-11 10:34:59 +00:00
kazu
6bf5c34cf2
* configure.in: Mac OS X's crypt(2) is broken with invalid salt.
...
[ruby-dev:35899]
* string.c (rb_str_crypt): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-07 08:57:53 +00:00
matz
31b6ea65bb
* include/ruby/ruby.h (DBL2NUM): renamed from DOUBLE2NUM.
...
a patch from Tadashi Saito <shiba at mail2.accsnet.ne.jp>
in [ruby-dev:36102].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 18:24:21 +00:00
naruse
56c3432476
* string.c (rb_str_index_m): only regexp uses byte offset.
...
* string.c (rb_str_rindex_m): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-29 09:22:17 +00:00
naruse
7fc16c2377
* encoding.c (rb_enc_compatible): ASCII compatible string and US-ASCII
...
regexp is compatible. [ruby-dev:36033]
* string.c (rb_str_index_m): second argument is position of character.
by usa. [ruby-dev:36033]
* string.c (rb_str_rindex_m): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-29 02:20:23 +00:00
mame
c543447ee0
* string.c (rb_str_shared_replace): remove corrupt noembed string
...
which causes SEGV. [ruby-dev:35989]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 14:40:53 +00:00
nobu
5f9c188d97
* include/ruby/ruby.h (rb_intern_const): tiny optimization.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 00:20:31 +00:00
nobu
a98587c0fd
* string.c (rb_str_drop_bytes): use memmove.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-15 10:34:06 +00:00
nobu
3622cd196c
* configure.in (rb_cv_gcc_function_alias): checks alias attribute.
...
* string.c (alias_func): replaced with RUBY_ALIAS_FUNCTION.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 15:43:55 +00:00
kouji
cdc2278f89
* string.c (alias_func): changed to 'weak, alias' from 'alias' for
...
Mac OSX. (closes #429 )
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 14:09:48 +00:00
shugo
f433d710d0
* object.c (rb_obj_untrusted): new method Object#untrusted?.
...
(rb_obj_untrust): new method Object#untrust.
(rb_obj_trust): new method Object#trust.
* array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c,
string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c,
ruby.c, marshal.c: fixes for Object#untrusted?.
* test/ruby/test_module.rb, test/ruby/test_array.rb,
test/ruby/test_object.rb, test/ruby/test_string.rb,
test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for
Object#untrusted?.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 07:25:05 +00:00
knu
0d242ac61a
* string.c: Apply a temporary fix to fix build on OS X. A real
...
fix will follow later.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 06:53:24 +00:00
naruse
85c41f4fbc
* error.c (rb_eEncCompatError): add Exception.
...
* include/ruby/ruby.h: ditto.
* encoding.c (rb_enc_check): use rb_eEncCompatError.
* string.c (rb_enc_cr_str_buf_cat): ditto.
* string.c (rb_str_sub_bang): ditto.
* string.c (rb_str_hex): ditto.
* string.c (rb_str_oct): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 18:17:05 +00:00
akr
c523f6f15e
* string.c (rb_str_splice_0): call rb_str_drop_bytes, not rb_str_drop.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 14:16:43 +00:00
nobu
f65719e5c6
* string.c (rb_str_drop_bytes): new function to drop first bytes.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 10:08:48 +00:00
nobu
26bc383ef8
* string.c (rb_str_drop): new function to drop first bytes.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 10:07:08 +00:00
nobu
456dc8bcee
* include/ruby/intern.h (rb_str_new2, rb_tainted_str_new2,
...
rb_usascii_str_new2): use with-length versions with strlen to
optimize strlen, if optimized.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 09:56:55 +00:00
nobu
e2159ba730
* string.c (rb_str_intern): constified.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 07:03:23 +00:00
matz
71553b91f6
* string.c (rb_str_intern): should check symbol table overflow.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 06:39:08 +00:00
nobu
3916eb783c
* marshal.c (dump_ensure), process.c (run_exec_dup2),
...
string.c (rb_str_replace), transcode.c (transcode_dispatch): fixed
memory leaks. based on patches from shinichiro.h <shinichiro.hamaji
AT gmail.com> at [ruby-dev:35751].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-04 05:08:57 +00:00
nobu
351fbaf0f7
* string.c (rb_str_shared_replace): fixed memory leak. a patch from
...
shinichiro.h <shinichiro.hamaji AT gmail.com> at [ruby-dev:35742]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-03 01:41:56 +00:00
mame
52bb9bb2d4
* string.c (sym_inspect): remove dead code.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-30 13:07:16 +00:00
nobu
70b317b9da
* include/ruby/intern.h, sprintf.c (rb_str_catf, rb_str_vcatf): new
...
functions. [ruby-dev:35597]
* string.c (rb_str_capacity): new function to return the capacity.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-22 07:48:00 +00:00
nobu
5ffd0cc80f
* include/ruby/intern.h (rb_str_buf_new2): optimization for literals.
...
* string.c (str_buf_cat): returns VALUE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-21 19:26:18 +00:00
nobu
c62db0676b
* include/ruby/intern.h (rb_str_buf_cat2, rb_str_cat2): optimization
...
for literals.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-21 17:51:49 +00:00
nobu
6e0b5f40cc
* string.c (rb_str_succ): alphabets or numerics mutually enclosing
...
non-alphanumeric characters can carry up. e.g., "1.999".succ should
be "2.000".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-08 16:38:40 +00:00
nobu
f10c88827e
* string.c (rb_str_succ): limit carrying in an alphanumeric region if
...
exists. [ruby-dev:35094]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-07 15:23:01 +00:00
akr
2950c7a919
* string.c (rb_str_format_m): make tmp volatile to avoid possible GC
...
problem.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-29 14:03:38 +00:00
akr
340cd503a7
* include/ruby/ruby.h (struct RRegexp): new field usecnt. replace
...
str and len by src.
* gc.c (gc_mark_children): mark src field of regexp.
(obj_free): don't free str field.
* re.c (REG_BUSY): removed.
(rb_reg_initialize): prohibit re-initialize regexp.
(rb_reg_search): use usecnt to prevent freeing regexp currently
using. this prevents SEGV by:
r = /\A((a.)*(a.)*)*b/
r =~ "ab" + "\xc2\xa1".force_encoding("euc-jp")
t = Thread.new { r =~ "ab"*8 + "\xc2\xa1".force_encoding("utf-8")}
sleep 0.2
r =~ "ab"*8 + "\xc2\xa1".force_encoding("euc-jp")
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-28 12:25:45 +00:00
nobu
2983df49d5
* include/ruby/intern.h (rb_str_new2, rb_tainted_str_new2,
...
rb_usascii_str_new2): use with-length versions with strlen to
optimize strlen.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-27 04:18:54 +00:00
mame
478d1da7fa
* string.c (rb_str_index_m, rb_str_rindex_m, rb_str_include): fix
...
rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-26 14:58:59 +00:00
nobu
e1a45b10b6
* array.c (rb_ary_store, rb_ary_splice): not depend on unspecified
...
behavior at integer overflow.
* string.c (str_buf_cat): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 06:42:07 +00:00
matz
6b33d77c4b
* string.c (rb_str_sub_bang): should preserve replacement points
...
since they may be altered in the yielded block.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 03:14:23 +00:00
akr
04739ba617
* string.c (rb_memhash): randomize hash to avoid algorithmic
...
complexity attacks.
(rb_str_hash): use rb_memhash.
* include/ruby/intern.h (rb_reset_random_seed): declared.
* thread.c (rb_thread_atfork): call rb_reset_random_seed.
* inits.c (rb_call_inits): call Init_RandomSeed at first.
* random.c (seed_initialized): defined.
(fill_random_seed): extracted from random_seed.
(make_seed_value): extracted from random_seed.
(rb_f_rand): initialize random seed at first.
(initial_seed): defined.
(Init_RandomSeed): defined.
(Init_RandomSeed2): defined.
(rb_reset_random_seed): defined.
(Init_Random): call Init_RandomSeed2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-20 02:46:17 +00:00
shyouhei
3af6dda231
* array.c (ary_new, rb_ary_initialize, rb_ary_store,
...
rb_ary_aplice, rb_ary_times): integer overflows should be
checked. based on patches from Drew Yao <ayao at apple.com>
fixed CVE-2008-2726
* string.c (rb_str_buf_append): fixed unsafe use of alloca,
which led memory corruption. based on a patch from Drew Yao
<ayao at apple.com> fixed CVE-2008-2726
* sprintf.c (rb_str_format): backported from trunk.
* intern.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-19 23:12:46 +00:00
matz
5336cbdfd3
* string.c (str_gsub): should preserve last successful match
...
data. [ruby-dev:35182]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-19 17:11:55 +00:00
matz
c3ab4a4b1b
* string.c (str_alloc): specify 'inline' modifier.
...
* string.c (str_alloc): remove cSymbol hack that no longer
necessary.
* string.c (scan_once): avoid retrieving encoding info unless
necessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-19 08:39:03 +00:00
matz
768380583a
* string.c (rb_str_scan): String#scan should preserve last
...
successful match data. [ruby-dev:35106]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-19 08:25:50 +00:00
matz
53f0a8ade1
* io.c (read_all): should use io_read_encoding(), not
...
io_input_encoding().
* io.c (rb_io_getline_1): reduce calling of io_read_encoding().
* string.c (rb_str_scan): need not to restore $~ value, so avoid
pinning match object.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-11 23:52:20 +00:00
nobu
5a647a3f5f
* include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.
...
* *.c: no cache in init functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 09:25:32 +00:00
ko1
72ba13aa8e
* array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
...
enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c,
io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c,
string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c,
vm.c, gc.c:
allocated memory objects by xmalloc (ruby_xmalloc) should be
freed by xfree (ruby_xfree).
* ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c,
ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c,
ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c,
ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c:
ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-08 10:01:40 +00:00
ko1
9eec758a1e
* string.c (hash): should be "static".
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-04 23:13:27 +00:00
nobu
075530a685
* suppress warnings with -Wwrite-string.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00
naruse
102f94455c
* string.c (rb_usascii_str_new): use rb_str_new.
...
* string.c (rb_enc_str_new): ditto.
* string.c (rb_usascii_str_new2): use rb_str_new2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-20 22:48:49 +00:00
matz
8405033139
* string.c (rb_enc_strlen_cr): need to set ENC_CODERANGE_7BIT if
...
search_nonascii() fails. [ruby-dev:34751]
* string.c (rb_str_reverse): preserve coderange info if the
receiver is 7bit string.
* string.c (rb_str_reverse_bang): ditto.
* string.c (rb_str_reverse_bang): should have called
single_byte_optimizable before rb_str_modify() that clears
coderange info.
* string.c (tr_trans): handle single bytes more eagerly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-20 07:59:33 +00:00
matz
44cd8e457b
* regparse.c (PINC): use optimized enclen() instead of
...
ONIGENC_MBC_ENC_LEN().
* regparse.c (PFETCH): ditto.
* regparse.c (PFETCH): small optimization.
* regexec.c (slow_search): single byte encoding optimization.
* regenc.h (enclen): avoid calling function when encoding's
min_len == max_len.
* re.c (rb_reg_regsub): rb_enc_ascget() optimization for single
byte encoding.
* re.c (rb_reg_search): avoid allocating new re_registers if we
already have MatchData.
* re.c (match_init_copy): avoid unnecessary onig_region_free()
before onig_region_copy.
* encoding.c (rb_enc_get_index): remove implicit enc_capable check
each time.
* encoding.c (rb_enc_set_index): ditto.
* encoding.c (enc_compatible_p): small refactoring.
* include/ruby/encoding.h (rb_enc_dummy_p): inline
rb_enc_dummy_p() and export related code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 08:25:03 +00:00
mame
41bf214fd7
* string.c (tr_find): String#delete returned wrong result when multiple
...
utf-8 arguments are passed.
* test/ruby/test_m17n.rb (test_delete): add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-15 14:03:21 +00:00
matz
5f0e8f582b
* string.c (rb_str_cat): fixed buffer overrun reported by
...
Christopher Thompson <cthompson at nexopia.com> in [ruby-core:16746]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-13 01:13:55 +00:00
matz
d34ad36c52
* string.c (sym_to_i): really removed. [ruby-dev:34641]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 12:26:15 +00:00
matz
4aa3454607
* string.c (tr_trans): should not turn on modify flag if no
...
modification happens. [ruby-dev:34631]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-10 17:10:46 +00:00
matz
e08f245464
* string.c (tr_trans): should check src size, not str size.
...
[ruby-dev:34637]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-10 17:10:10 +00:00
matz
ef14215c51
* string.c (tr_trans): single '^' does not mean negation.
...
[ruby-dev:34632]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-10 13:15:13 +00:00
matz
9139a48f0e
* string.c (rb_str_each_line): zero length record separator should
...
split a string into paragraphs. [ruby-dev:34586]
* string.c (rb_str_each_line): RDoc updated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-10 09:17:59 +00:00
nobu
86afcfe402
* thread.c (rb_thread_key_p): thread local storage stores ID.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-07 21:27:34 +00:00
matz
60219a0aa3
* string.c (tr_trans): should squeeze properly. [ruby-dev:34587]
...
* string.c (tr_trans): had a bug in treating multi-byte character
replacement.
* string.c (rb_str_delete_bang): need not to do anything for empty
strings.
* test/ruby/test_m17n_comb.rb (TestM17NComb::test_str_delete): add
test for empty receiver.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-07 16:15:45 +00:00
akr
7ef9aba753
* string.c (rb_str_each_line): return original string.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-04 03:59:01 +00:00
shyouhei
322d8dfb0e
* string.c (rb_enc_cr_str_buf_cat): do not use C++ comment.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-22 07:08:41 +00:00
matz
5572494524
* string.c (rb_str_intern): need not to check if tainted.
...
[ruby-dev:34219]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-06 17:19:11 +00:00
naruse
e58adeae0f
* re.c (rb_memsearch_ss): simple shift search.
...
* re.c (rb_memsearch_qs): quick search.
* re.c (rb_memsearch_qs_utf8): quick search for UTF-8 string.
* re.c (rb_memsearch_qs_utf8_hash): hash functions for above.
* re.c (rb_memsearch): use above functions.
* string.c (rb_str_index): give enc to rb_memsearch.
* include/ruby/intern.h (rb_memsearch): move to encoding.h.
* include/ruby/encoding.h (rb_memsearch): move from intern.h.
* common.mk (PREP): add dependency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-17 19:04:29 +00:00
matz
2694b2f937
* encoding.c (rb_enc_associate_index): pass unnecessary enc_capable().
...
* string.c (rb_str_cmp): reduce invocation of rb_enc_compatible().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-15 09:19:38 +00:00
nobu
657429b75b
* include/ruby/ruby.h (inttypes.h): includes always if available.
...
* string.c, ext/digest/defs.h: moved inttypes.h to ruby.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-14 08:04:45 +00:00
nobu
c0b8e82296
* string.c (UNALIGNED_WORD_ACCESS): IA64 cannot access unaligned word.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-14 01:04:02 +00:00
nobu
fab87736fd
* trunk/configure.in (AC_CHECK_HEADERS): stdint.h is not needed to check.
...
* trunk/configure.in (rb_cv_type_uint32_t): unqouted. [ruby-dev:34030]
* trunk/string.c (hash): use inttypes.h instead of stdint.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-13 05:14:21 +00:00
nobu
db49143cda
* configure.in (stdint.h): check if presence.
...
* configure.in (uint32_t): check if defined.
* string.c (hash): fix for portability. [ruby-dev:34020]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-12 16:45:28 +00:00
matz
3e51715596
* string.c (hash): replaced by MurmurHash described in
...
<http://murmurhash.googlepages.com/ >.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-11 01:20:25 +00:00
matz
923a661a7a
* string.c (rb_str_comparable): empty strings in any encoding are
...
compatible each other.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-11 00:55:02 +00:00
naruse
f55b10c001
* string.c (rb_str_index): if t == s + pos, the character beginning
...
from s + pos is valid.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-09 18:51:46 +00:00
akr
861219ce4a
fix doc.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-09 01:04:46 +00:00
naruse
a39feece85
* string.c (search_nonascii): Use VALUE instead of unsigned long
...
because VALUE can be the fastest unsigned integer type.
On LLP64 unsigned long isn't the fastest.
* string.c (str_strlen): ditto.
* string.c (str_utf8_nth): ditto.
* string.c (count_utf8_lead_bytes_with_ulong): ditto.
* string.c (count_utf8_lead_bytes_with_word): renamed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-08 09:05:34 +00:00
naruse
98cbcf1bd7
* string.c (count_utf8_lead_bytes_with_ulong): fix shift size.
...
[ruby-dev:33993]
* string.c (str_utf8_nth) fix wrong counting.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-05 19:34:15 +00:00
naruse
fff981ee6d
* string.c (is_utf8_lead_byte, count_utf8_lead_bytes_with_ulong):
...
defined for UTF-8 optimization.
* string.c (str_strlen): use is_utf8_lead_byte and
count_utf8_lead_bytes_with_ulong.
* string.c (str_utf8_nth) ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-05 13:54:36 +00:00
matz
39787ea14d
* numeric.c (fix_to_s): avoid rb_scan_args() when no argument
...
given.
* bignum.c (rb_big_to_s): ditto.
* enum.c (enum_first): ditto.
* eval_jump.c (rb_f_catch): ditto.
* io.c (rb_obj_display): ditto.
* class.c (rb_obj_singleton_methods): ditto.
* object.c (rb_class_initialize): ditto.
* random.c (rb_f_srand): ditto.
* range.c (range_step): ditto.
* re.c (rb_reg_s_last_match): ditto.
* string.c (rb_str_to_i): ditto.
* string.c (rb_str_each_line): ditto.
* string.c (rb_str_chomp_bang): ditto.
* string.c (rb_str_sum): ditto.
* string.c (str_modifiable): declare inline.
* string.c (str_independent): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-05 05:22:17 +00:00
matz
88d9f7aeac
* string.c (sym_inspect): use rb_str_inspect() instead of
...
rb_str_dump(). [ruby-dev:33946]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-01 03:42:06 +00:00
nobu
79f1b9e93b
* string.c (tr_setup_table, rb_str_split_m, rb_str_chomp_bang):
...
simplified with rb_enc_ascget(). [ruby-dev:33944]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-01 01:09:43 +00:00
matz
d5fec27d8e
* string.c (rb_str_coderange_scan_restartable): should not return
...
offset in the middle of a character.
* string.c (rb_str_coderange_scan_restartable): should not return
invalid cr value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-01 01:02:30 +00:00
matz
99de7f24f7
* test/ruby/test_m17n_comb.rb (TestM17NComb::test_str_chomp): test
...
updated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-29 14:57:04 +00:00
matz
2d97d3ddac
* string.c (rb_str_chomp_bang): now works on UTF-16.
...
* string.c (tr_setup_table): negation should work on non ASCII
compatible strings as well.
* string.c (rb_str_split_m): awk split should work on non ASCII
compatible strings as well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-29 13:33:26 +00:00
matz
daa622aed0
* time.c (time_strftime): format should be ascii compatible.
...
* parse.y (rb_intern3): non ASCII compatible symbols.
* re.c (rb_reg_regsub): add encoding check.
* string.c (rb_str_chomp_bang): ditto.
* test/ruby/test_utf16.rb (TestUTF16::test_chomp): raises exception.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-29 09:19:15 +00:00
matz
deff2a3e24
* string.c (rb_str_rpartition): calculation was done in byte indexing.
...
* test/ruby/test_m17n_comb.rb (TestM17NComb::test_str_start_with):
allow start_with? matching on broken strings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-29 06:19:21 +00:00
naruse
50a860d006
* string.c (str_new): remove encoding assumption of empty string.
...
* hash.c ( rb_f_getenv, env_fetch, env_inspect): result of ENV should
be always ASCII-8BIT.
* object.c (nil_to_s): nil.to_s should be US-ASCII.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 18:13:45 +00:00
naruse
7bb2b2f431
* string.c (rb_enc_str_copy): removed.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 05:38:16 +00:00
nobu
d3545f0d3c
* string.c (rb_str_reverse_bang): removed unsed variables.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 02:19:53 +00:00
nobu
c015c6fa8e
* include/ruby/encoding.h (rb_str_coderange_scan_restartable): added
...
prototype.
* string.c (rb_str_coderange_scan_restartable, rb_str_times): removed
unsed variables.
* string.c (rb_enc_str_copy): unused now. may be used in future?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 02:13:51 +00:00
naruse
4dd9fd71b3
* string.c (rb_str_coderange_scan_restartable): coderange scaning
...
for partial read.
* io.c (read_all): set coderange when not convert encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-27 15:19:22 +00:00
naruse
c1d3465081
* string.c (str_sublen): removed.
...
* string.c (rb_str_reverse, rb_str_reverse_bang): use
single_byte_optimizable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-23 11:18:07 +00:00
naruse
386aa4c0a1
* string.c (rb_enc_cr_str_copy_for_substr): renamed from
...
rb_enc_cr_str_copy.
* string.c: use rb_enc_cr_str_copy_for_substr and keep coderange.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-23 10:29:13 +00:00
naruse
7b218308e0
* fix missing STR_ENC_GET.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-22 15:02:40 +00:00
naruse
70eea8fd26
* add ascii incompatible case.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-22 12:56:21 +00:00
naruse
bdb14b5bb6
* string.c (rb_enc_cr_str_copy): check string's coderange is 7bit or
...
valid.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-22 12:15:56 +00:00
akr
81fc1cf201
* encoding.c (rb_enc_mbclen): return minlen instead of 1 when
...
a character is not found properly.
* string.c (rb_enc_strlen): round up string length with fixed
multibyte encoding such as UTF-32.
(rb_enc_strlen_cr): ditto.
(rb_str_substr): fix substring with fixed multibyte encoding.
(rb_str_justify): check number of characters.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-22 06:52:54 +00:00
naruse
a532dcafe6
* string.c (rb_str_inspect): string of ascii incompatible encoding
...
should be escaped and returned as US-ASCII encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-22 03:16:52 +00:00
naruse
7a9cf391cd
* string.c (rb_str_substr): copy encoding although empty string.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-22 02:18:23 +00:00
naruse
b62df564a6
* string.c (rb_str_times): empty string's coderange is CODERANGE_7BIT.
...
* string.c (rb_str_substr): ditto.
* encoding.c (rb_enc_compatible): empty string is compatible with not
only nonasciicompatible strings. [ruby-dev:33895]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-21 19:54:48 +00:00
naruse
3ce61d2a63
* string.c: replace rb_enc_copy by rb_enc_cr_str_copy or
...
rb_enc_cr_str_exact_copy.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-21 02:42:51 +00:00
naruse
492f431a46
* string.c (rb_enc_str_copy): added for wrapper for rb_enc_copy.
...
this also copy coderange when ptr and len is equal.
* string.c (rb_enc_cr_str_copy): added for wrapper for rb_enc_copy.
this always copy coderange.
* string.c (str_replace_shared): use rb_enc_str_copy.
* string.c (str_new3): don't rb_enc_copy because encoding is copied
at str_replace_shared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-20 10:20:43 +00:00
naruse
f1c975b87a
* string.c (rb_enc_strlen_cr): get length with coderange scan.
...
* string.c (str_strlen): use rb_enc_strlen_cr. [ruby-dev:33849]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-19 12:18:03 +00:00
akr
8efc7ea9ad
* string.c (rb_str_each_line): fix newline size.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-18 06:18:31 +00:00
naruse
8dd8dfce21
* encoding.c (ENC_CODERANGE_AND): fix broken case. [ruby-dev:33826]
...
* string.c (rb_str_times): fix broken case. [ruby-dev:33826]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-17 13:01:52 +00:00
naruse
7a257b0110
* encoding.c (ENC_CODERANGE_AND): added.
...
* string.c (rb_str_plus, srb_str_times): keep coderange.
* parse.y (STR_NEW0) use rb_usascii_str_new.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-17 06:49:11 +00:00
akr
a906fce838
* string.c (str_strlen): rb_enc_strlen doesn't fail.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-17 05:08:43 +00:00
akr
bf2d82b280
* string.c (str_sublen): use rb_enc_strlen.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-17 04:04:14 +00:00
akr
35cb0f807b
* string.c (rb_str_times): reduce loop overhead.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-17 00:18:16 +00:00
akr
71c5e48598
* include/ruby/re.h (struct rmatch_offset): new struct for character
...
offsets.
(struct rmatch): new struct.
(struct RMatch): reference struct rmatch.
(RMATCH_REGS): new macro.
* re.c (match_alloc): initialize struct rmatch.
(pair_byte_cmp): new function.
(update_char_offset): update character offsets.
(match_init_copy): copy regexp and character offsets.
(match_sublen): removed.
(match_offset): use update_char_offset.
(match_begin): ditto.
(match_end): ditto.
(rb_reg_search): make character offset updated flag false.
(match_size): use RMATCH_REGS.
(match_backref_number): ditto.
(rb_reg_nth_defined): ditto.
(rb_reg_nth_match): ditto.
(rb_reg_match_pre): ditto.
(rb_reg_match_post): ditto.
(rb_reg_match_last): ditto.
(match_array): ditto.
(match_aref): ditto.
(match_values_at): ditto.
(match_inspect): ditto.
* string.c (rb_str_subpat_set): use RMATCH_REGS.
(rb_str_sub_bang): ditto.
(str_gsub): ditto.
(rb_str_split_m): ditto.
(scan_once): ditto.
* gc.c (obj_free): free character offsets.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 20:08:35 +00:00
naruse
66583d9663
* string.c (rb_str_substr): optimized for UTF-8.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 11:53:04 +00:00
naruse
bb831578c5
* string.c (str_strlen): revert r15507. [ruby-dev:33810]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 10:06:15 +00:00
naruse
0ad3d7ce2d
* string.c (str_strlen): little more optimize.
...
(rb_enc_nth): remove needless variable 'c'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 09:30:03 +00:00
akr
7eeba5f440
* encoding.c (rb_enc_compatible): empty strings are always compatible.
...
* string.c (rb_enc_cr_str_buf_cat): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 09:02:12 +00:00
akr
a47e8e776c
* string.c (rb_enc_strlen): UTF-8 character count moved to str_strlen.
...
(str_strlen): UTF-8 character count is only applicable for valid
UTF-8 string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 07:16:36 +00:00
akr
9b3ab49b5d
* string.c (rb_str_sub_bang): stringize replacing hash values.
...
(str_gsub): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 04:17:52 +00:00
naruse
327673a43b
* string.c (rb_enc_strlen): add search_nonascii like character
...
counter for UTF-8.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 04:05:58 +00:00
akr
af75cc01bc
* encoding.c (rb_enc_strlen): moved to string.c.
...
* string.c (rb_enc_strlen): use search_nonascii.
(str_strlen): don't use search_nonascii.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 02:55:08 +00:00
naruse
132e3f54f2
* string.c (single_byte_optimizable): rb_enc_mbminlen must be 1
...
when rb_enc_mbmaxlen is 1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 20:41:29 +00:00
akr
0831222a91
* encoding.c (rb_enc_nth): moved to string.c.
...
* string.c (rb_enc_nth): moved from string.c. use search_nonascii
for ASCII compatible string.
(str_nth): wrong optimization removed to fix
"a".force_encoding("EUC-JP").slice!(0,10) returns
"a\x00\x00\x00\x00\x00\x00\x00\x00\x00"
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 18:48:27 +00:00
nobu
a05337f14d
* string.c (rb_str_sub_bang, str_gsub): allows hash for replacement.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 09:23:55 +00:00