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

240 Коммитов

Автор SHA1 Сообщение Дата
akr b82a05989e * re.c (ARG_ENCODING_NONE): defined for /.../n option.
(REG_ENCODING_NONE): ditto.
  (rb_char_to_option_kcode): return ARG_ENCODING_NONE for n.
  (rb_reg_prepare_re): warn /ascii/n =~ "non-ascii".
  (rb_reg_initialize): set REG_ENCODING_NONE from ARG_ENCODING_NONE.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 16:39:36 +00:00
akr e667720bd4 * re.c (append_utf8): use rb_utf8_encoding() instead of
rb_enc_find("utf-8").


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 07:07:21 +00:00
matz 668bd7d992 * test/ruby/test_system.rb (TestSystem::valid_syntax): apply
ASCII-8BIT encoding explicitly.

* re.c (rb_reg_prepare_re): add encoding name in the message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 05:03:14 +00:00
akr 59dca19910 * re.c: change "character encodings differ" error messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 04:54:54 +00:00
matz 77629d2cbe * string.c (rb_str_rindex_m): too much adjustment.
* re.c (reg_match_pos): pos adjustment should be based on
  characters.

* test/ruby/test_m17n.rb (TestM17N::test_str_insert): test updated
  to check negative offset behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 17:02:29 +00:00
nobu 474a88f041 * re.c (rb_reg_regsub): should set checked encoding.
* string.c (rb_str_sub_bang): applied r14212 too.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-19 12:42:19 +00:00
akr 2d01290cfd * parse.y (arg tMATCH arg): call reg_named_capture_assign_gen if regexp
literal is used.
  (reg_named_capture_assign_gen): assign the result of named capture
  into local variables.
  [ruby-dev:32588]

* re.c: document the assignment by named captures.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-18 11:26:24 +00:00
matz ebfcc5d933 * re.c (rb_reg_initialize): raise error if non-Unicode fixed
encoding option is specified for regexp literals with \u{}
  escapes.

* string.c (rb_str_squeeze_bang): should squeeze multibyte
  characters as well.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 16:06:21 +00:00
matz d6a70c4bb7 * string.c (scan_once): need no encoding compatibility check.
it's done inside of re_reg_seach().

* string.c (rb_str_split_m): ditto.

* re.c (rb_reg_regsub): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-17 09:44:06 +00:00
matz 7bb3ea6afa * re.c (rb_reg_initialize): embedded string may override encoding
of the regular expression.

* re.c (rb_reg_initialize): fix encoding of regular expression if
  embedded string has its own encoding specified.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 16:09:53 +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
akr b92cee1ddb * re.c, regerror.c, string.c, parse.y, ruby.c, file.c:
use capital letter for \xHH notation.  [ruby-dev:32511]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-12 14:30:54 +00:00
nobu ad72efa269 * re.c (rb_reg_regsub): should copy encoding.
* string.c (rb_str_sub_bang, str_gsub): should check and copy encoding
  to be replaced.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-12 03:11:44 +00:00
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
matz f6a9c859be * re.c (rb_reg_match): should calculate offset by converted
operand.  [ruby-cvs:21416]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 10:03:48 +00:00
nobu 38a24d73c8 * re.c (rb_reg_search): return byte offset. [ruby-dev:32452]
* re.c (rb_reg_match, rb_reg_match2, rb_reg_match_m): convert byte
  offset to char index.

* string.c (rb_str_index): return byte offset.  [ruby-dev:32472]

* string.c (rb_str_split_m): calculate in byte offset.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-10 04:50:35 +00:00
akr f4592d7bb0 * re.c (rb_reg_expr_str): use \xHH instead of \OOO.
* regerror.c (to_ascii): ditto.
  (onig_snprintf_with_pattern): ditto.
  (onig_snprintf_with_pattern): ditto.

* string.c (rb_str_inspect): ditto.
  (rb_str_dump): ditto.

* parse.y (parser_yylex): ditto.

* ruby.c (proc_options): ditto.

* file.c (rb_f_test): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 21:48:05 +00:00
akr 08eb58d3dd * re.c (rb_reg_names): new method Regexp#names.
(rb_reg_named_captures): new method Regexp#named_captures
  (match_regexp): new method MatchData#regexp.
  (match_names): new method MatchData#names.

* lib/pp.rb (MatchData#pretty_print): show names of named captures.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 21:44:19 +00:00
akr e56e8c758d * re.c (rb_reg_s_last_match): accept named capture's name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 13:35:38 +00:00
akr 2d101f0a87 Regexp#fixed_encoding? documented.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 11:57:06 +00:00
akr 7a7c26be73 document named capture of MatchData#{offset,begin,end,inspect}.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 07:35:54 +00:00
akr 18d8fbac54 * re.c (match_backref_number): new function for converting a backref
name/number to an integer.
  (match_offset): use match_backref_number.
  (match_begin): ditto.
  (match_end): ditto.
  (name_to_backref_number): raise IndexError instead of RuntimeError.
  (match_inspect): show capture index.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 07:12:44 +00:00
akr 5a1c2b2677 * re.c (append_utf8): check unicode range.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 03:50:11 +00:00
akr b12bb50149 * re.c (rb_reg_check_preprocess): new function for validating regexp
fragment.

* parse.y (regexp): invoke reg_fragment_check.
  (reg_fragment_check): defined.
  (reg_fragment_check_gen): defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-08 07:21:05 +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 6af5227ec0 fix Regexp#inspect document.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-02 15:46:21 +00:00
akr 7f65110b53 document MatchData#inspect.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-02 14:42:05 +00:00
akr c650096adf * re.c (unescape_escaped_nonascii): fix mbclen argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-02 11:45:02 +00:00
akr 9bd11f24b3 s/unicode/Unicode/ in error messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-02 02:53:46 +00:00
akr 7ff702406a * include/ruby/intern.h (rb_uv_to_utf8): declared.
* re.c (rb_reg_preprocess): new function for dynamic regexp with
  \u{} such as Regexp.new("\\u{6666}").
  (rb_reg_prepare_re): preprocess regexp for recompiling.
  (read_escaped_byte): new function.
  (unescape_escaped_nonascii): new function.
  (append_utf8): new function.
  (unescape_unicode_list): new function.
  (unescape_unicode_bmp): new function.
  (unescape_nonascii): new function.
  (rb_reg_initialize): preprocess regexp.

* pack.c (rb_uv_to_utf8): renamed from uv_to_utf8.

* parse.y (STR_NEW3): take func instead of has8 and hasmb.
  (parser_str_new): use default coderange mechanism except for regexp.
  (parser_tokadd_utf8): copy regexp source as-is.
  (parser_read_escape): UTF-8 stuff removed.
  (parser_tokadd_escape): has8bit and hasmb removed.
  (parser_tokadd_string): fix 8-bit single byte character with \u.
  (parser_parse_string): has8bit and hasmb removed.
  (parser_here_document): has8bit and hasmb removed.
  (parser_yylex): call parser_tokadd_utf8 instead of read_escape for
  UTF-8 character.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-01 16:56:19 +00:00
akr f5ee0fd521 * include/ruby/encoding.h, encoding.c, re.c, string.c, parse.y:
rename ENC_CODERANGE_SINGLE to ENC_CODERANGE_7BIT.
  rename ENC_CODERANGE_MULTI to ENC_CODERANGE_8BIT.
  Because single byte 8bit character, such as Shift_JIS 1byte katakana,
  is represented by ENC_CODERANGE_MULTI even if it is not multi byte.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-27 02:21:17 +00:00
akr cbd72b86da * re.c (Init_Regexp): new method Regexp#fixed_encoding?
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-26 08:33:11 +00:00
akr 0dc9be63a5 * re.c (rb_reg_fixed_encoding_p): extracted from rb_reg_prepare_re and
rb_reg_s_union.
  (rb_reg_s_union): refactored.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-26 02:27:59 +00:00
akr b2e60b2ce7 * include/ruby/encoding.h (rb_enc_str_asciionly_p): declared.
(rb_enc_str_asciicompat_p): defined.

* re.c (rb_reg_initialize_str): use rb_enc_str_asciionly_p.
  (rb_reg_quote): return ascii-8bit string if the argument is
  ascii-only to generate encoding generic regexp if possible.
  (rb_reg_s_union): fix encoding handling.  [ruby-dev:32094]

* string.c (rb_enc_str_asciionly_p): defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-25 13:25:34 +00:00
akr 2109a52503 * re.c (REG_CASESTATE): unused macro removed.
(rb_reg_prepare_re): check encoding difference.
  (rb_reg_initialize): check 8bit byte.

* parse.y (parser_tokadd_escape): fix has8bit.

  [ruby-dev:32113]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-23 06:30:26 +00:00
matz d73f08d56d * re.c (match_begin): should return offset by character.
[ruby-dev:32331]

* re.c (match_end): ditto.

* re.c (rb_reg_search): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-23 02:10:44 +00:00
akr af9c868eae * re.c (rb_reg_quote): quote \v as well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-04 15:03:31 +00:00
akr 794fc684e8 * re.c (rb_reg_initialize_m): use StringValuePtr instead of
StringValueCStr because \0 exists when Regexp.new("\0").


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-04 14:53:36 +00:00
nobu c7697aba34 * parse.y (parser_regx_options, reg_compile_gen): relaxened encoding
matching rule.

* re.c (rb_reg_initialize): always set encoding of Regexp.

* re.c (rb_reg_initialize_str): fix enconding for non 7bit-clean
  strings.

* re.c (rb_reg_initialize_m): use ascii encoding for 'n' option.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-19 07:41:03 +00:00
matz 05737c3500 * re.c (rb_reg_s_union): the last check was not complete.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-17 05:21:10 +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 b06a606278 * re.c (rb_reg_desc): set encoding.
* re.c (rb_reg_s_union): check encodings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 18:37:09 +00:00
nobu 81ed881511 * re.c (rb_reg_initialize_m): allow binary encoding option.
[ruby-dev:32083]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 16:57:08 +00:00
nobu 5d8ba5a43f * re.c (rb_reg_s_union): check for encoding of original object.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 10:48:02 +00:00
nobu 676dc908b6 * parse.y (parser_regx_options): check if regexp encoding option
matches to current encoding.

* re.c (char_to_option, rb_char_to_option_kcode): 'n' is not kcode
  option now.

* re.c (rb_reg_to_s, rb_reg_error_desc): copy encoding rather than
  append as an option.

* re.c (make_regexp, rb_reg_prepare_re): use encoding of Regexp and
  String instead of kcode.

* re.c (rb_reg_initialize): set fixed option if none is set.

* re.c (rb_reg_regcomp): ditto.

* re.c (rb_reg_equal): check if encodings are equal.

* re.c (rb_reg_initialize_m): encoding option is obsolete.

* re.c (rb_kcode, rb_get_kcode, rb_set_kcode): removed.

* re.c (Init_Regexp): removed Regexp#kcode method.

* ruby.c (proc_options): allow long encoding name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 05:48:40 +00:00
matz 9f00119776 * re.c (rb_reg_s_union): encoding of all regexp objects should
match.  [ruby-dev:32076]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-16 05:06:30 +00:00
matz ba9eb2c929 * re.c (match_values_at): make #select to be alias to #values_at
to adapt RDoc description.  [ruby-core:12588]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-12 14:35:26 +00:00
matz 79a202433c * re.c (rb_reg_s_quote): no longer takes optional second argument
that has never been documented.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-10 14:34:42 +00:00
akr cf9bdd01d8 fix rdoc position of Regexp.union.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-08 16:03:53 +00:00