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

295 Коммитов

Автор SHA1 Сообщение Дата
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
nobu f2bd108d8d * configure.in (enc/Makefile): add external encoding objects list.
* common.mk (BUILTIN_ENCOBJS): renamed from ENCOBJS.

* Makefile.in (BUILTIN_ENCOBJS): substitued by autoconf.

* enc/Makefile.in: new file to compile external encoding sources.

* encoding.c (rb_enc_find_index): auto-load external encoding objects
  as "ext/ENCODING_NAME".  [ruby-dev:32606]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-15 09:56:59 +00:00
nobu 8063edd4c9 * encoding.c (rb_enc_register, rb_enc_replicate, rb_enc_alias): check
if already registered.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-15 03:58:02 +00:00
matz e0334fb250 * encoding.c (rb_enc_compatible): 1st argument (typically the
receiver) would have higher priority in encoding detection.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 17:30:54 +00:00
matz a648fc802b * encoding.c (rb_enc_compatible): encoding should never fall back
to ASCII-8BIT unless both encodings are ASCII-8BIT.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 13:44:02 +00:00
nobu e18e893846 * encoding.c (enc_get_encoding): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 08:05:00 +00:00
nobu af69c73087 * encoding.c (rb_enc_compatible): should swap encoding indexes too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 08:03:31 +00:00
matz 02501dbe91 * encoding.c (rb_enc_compatible): should not judge compatibility
based on rb_enc_asciicompat().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 07:44:52 +00:00
akr 646f27b822 * encoding.c (rb_enc_ascget): renamed from rb_enc_get_ascii.
* include/ruby/encoding.h: follow the renaming.

* re.c: ditto. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-11 07:39:16 +00:00
akr 5802768b40 * encoding.c (rb_enc_get_ascii): add an argument to provide the
length of the returned character.

* include/ruby/encoding.h (rb_enc_get_ascii): add the argument.

* re.c (rb_reg_expr_str): modify rb_enc_get_ascii call.
  (rb_reg_quote): ditto.
  (rb_reg_regsub): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-11 03:08:50 +00:00
akr 78eae5da62 * encoding.c (rb_enc_precise_mbclen): return needmore if underlying
implementation returns a length longer than e-p.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-08 19:10:58 +00:00
akr cde5b2a9cf * encoding.c (rb_enc_mbclen): return 1 if underlying implementation
returns a length longer than e-p.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-08 18:41:47 +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
matz d5bd9d1593 * encoding.c: rename primary_encoding -> default_external (encoding).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-01 14:05:53 +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
nobu 7bfed9613c * encoding.c (enc_check_encoding, rb_set_primary_encoding): ENCODING
is no longer in FL_USERS flags.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-09 06:52:02 +00:00
matz 4ab384be2d * test/ruby/test_basicinstructions.rb: updated for new class
behavior.  [ruby-dev:32192]

* encoding.c (enc_name): Encoding should not rely on ENCODING in
  the FL_USERS flags.

* encoding.c (rb_enc_from_encoding): do not call rb_enc_associate
  for encoding itself.

* encoding.c (enc_register_at): ditto.

* marshal.c (r_ivar): do not set real instance variable for
  encoding data associated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-09 04:37:36 +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 b088414390 * encoding.c (rb_enc_replicate): new function to replicate encoding.
* encoding.c (enc_based_encoding): Encoding#base_encoding returns
  based encoding of replica.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-29 08:20:13 +00:00
nobu 3dacfd3fe4 * encoding.c (rb_enc_compatible): ASCII encoding is compatible with
ASCII-compatible encoding, even for non-string objects.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-29 08:18:36 +00:00
nobu d0cbfbd995 * encoding.c (rb_to_encoding_index, rb_to_encoding): commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-22 02:06:50 +00:00
nobu 3cb10b32bb * encoding.c (enc_check_encoding): returns index now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-22 02:03:10 +00:00
nobu 00befb4b3f * encoding.c (rb_enc_compatible): check if two objects have compatible
encodings.

* encoding.c (enc_compatible_p): added Encoding.compatible?.

* include/ruby/encoding.h (rb_enc_compatible): prototype.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-22 01:57:08 +00:00
nobu b2c81746ac * encoding.c (rb_enc_default, rb_enc_primary): return pointers to
rb_encoding of default and primary respectively.  [ruby-core:12795]

* encoding.c (set_primary_encoding): removed primary_encoding setter.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-21 09:29:19 +00:00
nobu 5d5d0b5c38 * encoding.c (rb_id_encoding): returns ID "encoding".
* marshal.c (w_encoding): dump encoding name.

* marshal.c (r_ivar): load encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-19 11:08:16 +00:00
nobu 2d1d6c4705 * encoding.c (rb_enc_from_encoding, rb_enc_register): associate index
to self.

* encoding.c (enc_capable): Encoding objects are encoding capable.

* re.c (rb_reg_s_union): check if encoding matching by exact encoding
  objects.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-17 02:30:57 +00:00
nobu 5daecbc0e1 * encoding.c (rb_enc_alias, rb_enc_find_index): changed
enc_table_alias to a name-to-index hash.

* encoding.c (rb_enc_init): use upper case names for aliases to use as
  constant names.

* encoding.c (enc_find): allow symbols.

* encoding.c (Init_Encoding): define encoding constants.

* st.c (strcasehash): fix wrong code range condition.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 21:18:09 +00:00
nobu de46b903a9 * encoding.c (enc_list): seems a commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 20:26:29 +00:00
nobu 3cd040b6ef * encoding.c (rb_primary_encoding): added Encoding.primary_encoding.
* parse.y (rb_parser_encoding): added.

* ruby.c (proc_options): added -E and --encoding options.

* ruby.c (process_options): set primary encoding from command line
  option if set, or source encoding.

* include/ruby/encoding.h (rb_enc_from_encoding,
  rb_get_primary_encoding, rb_set_primary_encoding): prototypes.

* include/ruby/node.h (rb_parser_encoding): prototype.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 20:07:20 +00:00
matz 4ad19a7dee * encoding.c (enc_to_s): rename function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 04:50:16 +00:00
matz ff3859899d * encoding.c (Init_Encoding): define #to_s to show encoding name
in to_s representation as well as #inspect.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-15 16:28:18 +00:00
nobu b314d3e999 * encoding.c (rb_obj_encoding): rdoc update. a patch from David
Flanagan <david AT davidflanagan.com>.  [ruby-core:12664]

* encoding.c (enc_dump, enc_load): marshaling feature.  a patch from
  David Flanagan.  [ruby-core:12665]

* encoding.c (Init_Encoding): undefine allocator of Encoding.
  [ruby-core:12665], [ruby-core:12666]

* test/ruby/test_encoding.rb: tests for Encoding from David Flanagan
  [ruby-core:12665]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-14 08:31:51 +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
akr ee624f97ac * encoding.c (rb_enc_init): don't alias iso-8859-1 to ascii.
* ascii.c (OnigEncodingASCII): change the name US-ASCII to ASCII-8BIT.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-10 06:50:33 +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 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 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 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
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
matz 4461bd2f1f * encoding.c (rb_enc_codelen): raises invalid sequence exception
if ONIGENC_CODE_TO_MBCLEN() returns zero.  [ruby-dev:31661]

* encoding.c (rb_enc_mbclen): check invalid sequence.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-27 13:48:09 +00:00
matz 5678ab5182 encoding.c: added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 04:07:20 +00:00