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

271 Коммитов

Автор SHA1 Сообщение Дата
naruse 3da3230f0c * encoding.c (Init_Encoding): undef Encoding.new because
a class which is rb_undef_alloc-func-ed can't call new method.
  [ruby-dev:39862]

* vm.c (Init_VM): undef RubyVM.new and RubyVM::Env.new.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-21 10:12:21 +00:00
naruse 07f81c06ca Add rdoc and test of Encoding#replicate.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-12 16:35:10 +00:00
naruse 614a8427ce * encoding.c (enc_replicate): add Encoding#replicate(name).
* encoding.c (enc_replicate_with_index): renamed from old
  enc_replicate.

* encoding.c (rb_enc_from_encoding_index): split from
  rb_enc_from_encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-10 03:59:34 +00:00
nobu 4d786d21e3 * removed spaces just before tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-26 05:25:08 +00:00
naruse a7db2c1efd * encoding.c (enc_set_default_encoding): reset filesytem
encoding because on resetting default_external because
  Unix's filesystem encoding depends on default_external.

* encoding.c (enc_set_filesystem_encoding): added.

* ruby.c (process_options): don't call rb_filesystem_encoding
  because filesystem encoding is reset when default_external
  is reset.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-18 03:38:20 +00:00
akr 1aba3f9d76 * encoding.c (rb_filesystem_encindex): use default external encoding
instead of locale encoding in Unix.

* ruby.c (process_options): delay inifilesystem encoding
  initialization after default external encoding initialization.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-15 16:37:38 +00:00
naruse 0859e7cb87 * encoding.c (rb_filesystem_encindex): add fallback to
ASCII-8BIT on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-06 00:33:56 +00:00
akr b9e0294eda fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-03 17:46:28 +00:00
naruse 2f2e8455e3 Revert set locale and filesystem encindex in Init_Encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-29 09:40:25 +00:00
naruse 06346d5849 * encoding.c (Init_Encoding): set locale and filesystem encindex.
* ruby.c (process_options): move setting func of filesystem
  encoding to Init_Encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-29 08:14:09 +00:00
nobu feb34709fe * encoding.c (enc_find): fixed rdoc formatting.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-28 08:02:02 +00:00
naruse 7a884fe466 * encoding.c (get_filesystem_encoding): removed.
* encoding.c (rb_locale_encindex): added.

* encoding.c (rb_filesystem_encindex): added.

* encoding.c (rb_filesystem_encindex): add an alias 'filesystem'.
  [ruby-dev:39574]

* encoding.c (enc_find): add rdoc about special aliases.

* gem_prelude.rb (Gem.set_home): use Encoding.find('filesystem').

* gem_prelude.rb (Gem.set_paths): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-28 07:34:24 +00:00
naruse 8d9e64fb38 * encoding.c (get_filesystem_encoding):
add Encoding.filesystem_encoding [ruby-dev:39546]
  also see [ruby-core:25959]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-28 06:06:10 +00:00
akr 525be7f048 fix a typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-23 13:30:29 +00:00
naruse f7554133b2 * encoding.c (rb_enc_unicode_p): defined.
Returns 1 when the encoding is Unicode series
  other than UTF-7 else 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-29 00:34:00 +00:00
naruse 5f5706c38f * encoding.c (rb_filesystem_encoding): On Unix systems,
filesystem encoding should be locale encoding.
  [ruby-dev:39393] and see also [ruby-dev:35617]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-28 19:24:24 +00:00
nobu b46cd0e400 * include/ruby/ruby.h (rb_data_type_struct): constified dsize.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-09 02:11:35 +00:00
naruse e666111955 * encoding.c (rb_enc_compatible): If a string is empty and
other's encoding is US-ASCII, returns the empty string's encoding.
  [ruby-list:46274]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-11 22:52:39 +00:00
naruse 8b83fc2704 * encoding.c (is_data_encoding): fix condition.
* encoding.c (enc_capable): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-11 22:39:54 +00:00
naruse e56bf07b16 New API Encoding#ascii_compatible?.
* encoding.c (enc_ascii_compatible_p): added. [ruby-core:24793]
  (Init_Encoding): New API Encoding#ascii_compatible?.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-08 23:25:32 +00:00
nobu a809077956 * encoding.c (rb_enc_associate_index): cannot set encoding on
special constants.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-06 07:36:29 +00:00
nobu a2393c3e53 * encoding.c (valid_encoding_name_p): rejects too long encoding
names.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-06 07:26:49 +00:00
nobu 30995c6594 * encoding.c (encoding_data_type): typed data.
* encoding.c (enc_capable, rb_enc_get_index): Symbol is encoding
  capable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-06 07:25:13 +00:00
nobu 87c1a07d6a * encoding.c (rb_enc_get_index): fixed indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-06 07:08:42 +00:00
naruse b3d7273dc1 Add functions and macros for second encoding definitions.
* encoding.c (rb_enc_set_base): Add for setting base encoding
  with their names. this is internal function.

* template/encdb.h.tmpl: specify ENC_SET_BASE for second
  encodings in each encoding files.

* enc/encdb.c (rb_enc_set_base): add a declaration.
  (ENC_SET_BASE): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-04 00:50:59 +00:00
nobu e07cb859cc * suppressed shorten-64-to-32 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-18 08:05:32 +00:00
akr 98aac1e651 * ruby.c (process_options): don't specify .so for encdb here.
"." is replaced by "_" in load_encoding.

* encoding.c (load_encoding): add .so here. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-22 16:21:09 +00:00
matz cb699fc930 * encoding.c (rb_enc_name_list): update RDoc. [ruby-core:23926]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-06-19 11:54:37 +00:00
yugui a1b5cd1ca2 * rb_enc_get_index: allows an arbitrary RData as the argument but not
only what points a rb_encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-20 12:16:23 +00:00
matz 0980fe7903 * encoding.c (rb_enc_fast_mbclen): faster mbclen for strings known
to be valid.

* string.c (enc_strlen): coderange specified version of
  rb_enc_strlen().  use rb_enc_fast_mbclen() if coderange is 7bit
  or valid.

* string.c (str_gsub): use rb_enc_fast_mbclen().

* string.c (rb_str_reverse, rb_str_split_m, rb_str_each_char,
  scan_once): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-20 04:44:36 +00:00
matz 91e5ba1cb8 * encoding.c (rb_enc_codepoint_len): combine rb_enc_codepoint()
and rb_enc_codelen() in one function to reduce calls.

* encoding.c (rb_enc_codepoint): compatibility function.

* sprintf.c (rb_str_format): use rb_enc_codepoint_len().

* string.c (rb_str_inspect, rb_str_upcase_bang,
  rb_str_downcase_bang, rb_str_capitalize_bang,
  rb_str_swapcase_bang, trnext, tr_trans, rb_str_delete_bang,
  rb_str_squeeze_bang, rb_str_count, rb_str_split_m,
  rb_str_each_line, rb_str_each_codepoint, rb_str_lstrip_bang,
  sym_printable): ditto.

* transcode.c (make_econv_exception): use rb_enc_mbc_to_codepoint()

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-19 16:59:22 +00:00
naruse f7bfe5f2df * encoding.c (rb_filesystem_encoding): Change filesystem_encoding of
Mac OS X to UTF-8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-04-30 02:38:47 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
usa 9bd77cfd77 * encoding.c (rb_filesystem_encoding): Windows' filesystem encoding is
sometimes ANSI code page and sometimes OEM code page. we should check
	  whether code page is used.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-01 21:53:14 +00:00
matz 80088a55fc * encoding.c (enc_set_default_encoding): should not treat US-ASCII
special here.  a patch from Yui NARUSE in [ruby-dev:37769].
  [ruby-dev:37699]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-15 06:57:55 +00:00
nobu 994293bc81 * encoding.c (rb_locale_charmap): fixed typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-15 04:21:59 +00:00
nobu ece0628ebe * configure.in, win32/Makefile.sub (MISSING): added langinfo on mingw
and mswin.

* encoding.c (rb_locale_charmap): use environments on mingw and mswin.

* missing/langinfo.c (nl_langinfo_codeset): MS-Windows Japanese
  environment uses Windows-31J derived from Shift_JIS, not EUC-JP.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-15 04:10:16 +00:00
nobu 22e711c4bf * encoding.c (rb_locale_charmap): fallback to codepage if no
locale is found.  [ruby-core:21110]

* missing/langinfo.c (nl_langinfo_codeset): returns NULL if no
  locale is found.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-14 14:57:34 +00:00
akr f0e91e54a3 describe Encoding.find("locale") in rdoc of Encoding.locale_charmap.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-12 17:28:40 +00:00
usa c123952745 * encoding.c (rb_locale_charmap): use GetConsoleCP() instead of
GetACP() because external encoding should be console's one.

	* encoding.c (rb_filesystem_encoding): use GetOEMCP() instead of
	  GetACP() because VFAT/FAT32 uses OEM CP.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-05 08:44:10 +00:00
nobu 49ef25b151 * encoding.c (rb_filesystem_encoding): use ANSI codepage for file
system on cygwin.

* encoding.c (rb_locale_charmap): reverted.  [ruby-core:21110]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-05 07:26:51 +00:00
nobu ef7057fe2f * encoding.c (rb_filesystem_encoding, rb_locale_charmap): uses
codepage on cygwin.  [ruby-core:20994]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-04 06:41:43 +00:00
yugui 87f6de3e18 * encoding.c (default_external): endless recursion during
loading a locale encoding on some locale.
  fixed by Nobuyuki Nakada.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-13 07:08:56 +00:00
yugui 58740ef881 * encoding.c (rb_enc_set_default_external): default_internal can be
nil, but default_external cannot.

* encoding.c (rb_set_default_internal): adds rdoc.

* encoding.c (enc_find): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-12 10:35:39 +00:00
yugui aa06e69000 * encoding.c (enc_get_default_encoding): removed.
Generalizing rb_default_{external,internal}_encoding seems to be
  difficult. 
  default_external cannot be NULL even before detected. [ruby-dev:37390]

* encoding.c (rb_default_external_encoding): has its own
  implementation again.

* encoding.c (rb_default_internal_encoding): ditto.

* gem_prelude.rb: added notice.

* ruby.c (rubylib_mangled_path, rubylib_mangled_path2): uses locale
  encoding but not ASCII-8BIT.

* ruby.c (process_options): refers less to default_external.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-12 05:25:39 +00:00
nobu e5f1572583 * encoding.c (rb_enc_aliases_enc_i): skips default internal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-11 11:05:21 +00:00
nobu 28d1621d10 * encoding.c (enc_set_default_encoding): allowed to set default
encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-11 04:36:20 +00:00
nobu 31c163e4c8 * encoding.c (rb_enc_set_default_internal): defines internal
encoding as nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-11 04:17:10 +00:00
nobu 84b5d04bed * encoding.c (rb_locale_encoding): removed Encoding::LOCALE.
* encoding.c (rb_enc_set_default_external): ditto.

* encoding.c (rb_enc_set_default_internal): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-11 02:51:46 +00:00
nobu b1c07ee240 * encoding.c (rb_enc_set_default_internal): no alias "internal" if
defalt internal is not set.  [ruby-dev:37000]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-31 02:35:41 +00:00
nobu 2db25b6ba0 * encoding.c (rb_locale_encoding): makes an alias for locale.
[ruby-dev:36976]

* encoding.c (rb_enc_set_default_external): ditto for external.

* encoding.c (rb_enc_set_default_internal): ditto for internal.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-30 00:31:47 +00:00
nobu 017ff9bfa2 * encoding.c (enc_names): minor improvement.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-09 16:55:51 +00:00
naruse 517a1c3406 * encoding.c (Init_Encoding): new instance method Encoding#names,
returns its name and alias names.

* encoding.c (enc_names): defined for Encoding#names.

* encoding.c (enc_names_i): defined for enc_names.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-09 02:52:39 +00:00
matz baeeebf474 * encoding.c (rb_default_internal_encoding): merged a patch from
Michael Selig <michael.selig at fs.com.au> in [ruby-core:18985].

* io.c (rb_io_ext_int_to_encs): ditto.

* ruby.c (proc_options): support default internal encoding in -E
  option.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-07 17:39:44 +00:00
naruse 163ac54f13 * encoding.c (get_default_external): add description.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-21 17:52:18 +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 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 b73891b5f1 * encoding.c (Encoding#base_encoding): removed. [ruby-dev:36270]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 15:53:50 +00:00
ko1 69029b90fe * gc.c, include/ruby/ruby.h: rename rb_register_mark_object()
to rb_gc_register_mark_object().
* eval.c, vm.c: initialize vm->mark_object_ary at
  Init_top_self().
* bignum.c, complex.c, encoding.c, ext/win32ole/win32ole.c,
  io.c, load.c, marshal.c, rational.c, ruby.c, vm.c:
  use rb_gc_register_mark_object() instead of
  rb_global_variable() or rb_gc_register_address().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 14:59:14 +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
akr a517395056 * encoding.c (rb_enc_get_index): don't return -1.
* io.c (rb_scan_open_args): call FilePathValue before encoding
  conversion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 14:29:09 +00:00
naruse 5fc383f9a3 * encoding.c (rb_enc_compatible): accepst other than strings and
regexps. [ruby-core:18595]

* encoding.c (rb_enc_get_index): works files and encodings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 05:17:18 +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
naruse 727625d9d4 * encoding.c (enc_compatible_p): use TYPE not BUILTIN_TYPE.
[ruby-dev:36048]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-29 23:10:25 +00:00
naruse 5159f500fd * encoding.c (enc_compatible_p): add SPECIAL_CONST_P check.
* test/ruby/test_m17n.rb (test_compatible): fix test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-29 22:50:16 +00:00
naruse 889acc8185 * encoding.c (enc_compatible_p): raise TypeError when argument is not
String nor Regexp.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-29 09:37:00 +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
naruse 33dd0c35f1 * encoding.c (enc_compatible_p): raise TypeError when argument is Encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 21:12:32 +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
akr d46728ec0e * encoding.c (rb_filesystem_encoding): use default external encoding
for Unix.

* dir.c (dir_initialize): don't cache fs_encoding.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 12:11:14 +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
mame 4d763fb8ee * encoding.c: include util.h. [ruby-dev:35715]
* common.mk: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-10 13:25:34 +00:00
nobu c97a842391 * encoding.c (rb_to_encoding_index, rb_to_encoding): check if the name
is ascii compatible as well as Encoding.find.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-05 20:31:59 +00:00
akr 4fb4516af8 * encoding.c (rb_filesystem_encoding): use locale encoding on Unix.
[ruby-dev:35617]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-21 08:16:34 +00:00
nobu 28b216ac45 * include/ruby/oniguruma.h (OnigEncoding): removed auxiliary_data.
* include/ruby/encoding.h (ENC_DUMMY_P): moved dummy encoding flag to
  rb_encoding from Encoding instance.

* encoding.c (rb_encoding_list): list of Encoding instances.

* encoding.c (struct rb_encoding_entry): moved base encoding from
  instance variable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-04 11:44:05 +00:00
naruse 04d83114a6 * encoding.c (rb_utf8_encindex): defined.
* include/ruby/encoding.h (rb_utf8_encindex): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-29 17:33:01 +00:00
naruse 2755479bd9 * encoding.c (rb_filesystem_encoding): defined.
* include/ruby/encoding.h (rb_filesystem_encoding): added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-16 21:28:03 +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
nobu 7c5e3348f7 * suppress warnings on cygwin, mingw and mswin.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-01 19:55:25 +00:00
naruse 19337db497 * fix for (rb_enc_get_index(obj) == idx) case.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-20 22:50:01 +00:00
naruse fe8bb86125 * encoding.c, include/ruby/encoding.h
(rb_enc_associate, rb_enc_associate_index):
  returns obj. [ruby-dev:34778]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-20 22:26:14 +00:00
naruse 13f20ccda7 * encoding.c (rb_ascii8bit_encoding): use ENCINDEX_ASCII.
* encoding.c, include/ruby/encoding.h (rb_ascii8bit_encindex):
  added.

* encoding.c (rb_locale_encoding): use rb_usascii_encoding().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-20 19:21:26 +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
nobu 1369cfd16e * encoding.c (enc_init_db): moved to enc/encdb.c.
* transcode.c (init_transcoder_table): moved to enc/trans/transdb.c.

* enc/depend (enc/encdb.o enc/trans/transdb.o): depend on
  corresponding headers.

* common.mk (COMMONOBJS): moved transcode.o from OBJS


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-07 06:51:33 +00:00
nobu 555eb7ded4 * encoding.c (enc_check_encoding): should not load autoloaded encoding
directly, instead use rb_enc_find_index() which deal with alias and
  replica.  [ruby-core:15957]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-19 05:08:49 +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 cd89edc065 * encoding.c (rb_enc_dummy_p): bootstrap encodings can not be dummy.
* encoding.c (rb_enc_ascget): no needs to call rb_enc_precise_mbclen()
  twice.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-29 15:29:09 +00:00
naruse 5eafc201d8 * encoding.c (enc_capable): IMMEDIATE_P doesn't include Qnil and Qfalse.
use SPECIAL_CONST_P.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 13:22:29 +00:00
naruse 6f99342c92 * encoding.c (enc_find): check type of argument and convert to String
if it is StringValue. [ruby-cvs:22866]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 11:58:11 +00:00
duerst ad3577b59b Mon Feb 25 10:41:41 2008 Martin Duerst <duerst@it.aoyama.ac.jp>
* encoding.c (Encoding#dummy): minor grammatical fixes
	  in rdoc documentation.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-25 01:42:47 +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 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 1e0958098f * encoding.c (rb_enc_associate_index): doesn't clear coderange
when new encoding equals to old one.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-20 10:44:28 +00:00
akr 8bcfa698a0 * encoding.c (rb_enc_compatible): check encoding incapable arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-16 11:43:12 +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 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
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
matz 8b09f7015a * string.c (str_strlen): use search_nonascii() for performance.
* string.c (str_nth): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 08:14:40 +00:00
nobu f3ed7fa233 * encoding.c (encdb_{replicate,alias,dummy,declare}): define only if
NO_ENCDB_H is not defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-29 09:05:50 +00:00