aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
Commit message (Collapse)AuthorAgeFilesLines
* * regparse.c (PINC): use optimized enclen() instead ofmatz2008-05-191-15/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * array.c (rb_ary_sort_bang): stop memory leak. [ruby-dev:34726]matz2008-05-161-0/+2
| | | | | | | | | | | | | | * re.c (rb_reg_search): need to free allocated buffer in re_register. * regexec.c (onig_region_new): more pedantic malloc check. * regexec.c (onig_region_resize): ditto. * regexec.c (STATE_CHECK_BUFF_INIT): ditto. * regexec.c (onig_region_copy): use onig_region_resize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_prepare_enc): error condition was updated for nonmatz2008-05-151-19/+28
| | | | | | ASCII compatible strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_prepare_re): made non static with small refactoring.matz2008-05-121-3/+4
| | | | | | | * ext/strscan/strscan.c (strscan_do_scan): should adjust encoding before regex searching. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (Init_Regexp): remove MatchData#select. [ruby-dev:34563]matz2008-05-021-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_search): use local variable. a patch from wanabenobu2008-04-301-1/+2
| | | | | | | <s.wanabe AT gmail.com> in [ruby-dev:34537]. [ruby-dev:34492] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enumerator.c (enumerator_each, enumerator_with_index): suppressnobu2008-04-221-5/+3
| | | | | | | | | | | | | | | | | | warnings. * pack.c (pack_unpack): ditto. * process.c (rb_syswait): ditto. * re.c (rb_reg_prepare_enc, rb_reg_prepare_re, rb_reg_adjust_startpos): ditto. * regparse.c (onig_name_to_group_numbers): ditto. * missing/vsnprintf.c (BSD_vfprintf): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_search): make search reentrant. [ruby-dev:34223]matz2008-04-141-48/+63
| | | | | | | * test/ruby/test_parse.rb (TestParse::test_global_variable): should preserve $& variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_quote): should always copy the quoting string.matz2008-04-081-3/+3
| | | | | | [ruby-core:16235] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_memsearch_qs): wrong boundary condition.naruse2008-04-041-4/+4
| | | | | | * re.c (rb_memsearch_qs_utf8): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_memsearch_qs): wrong boundary condition. a patch frommatz2008-04-041-1/+1
| | | | | | wanabe <s.wanabe AT gmail.com> in [ruby-dev:34248]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_memsearch_ss): simple shift search.naruse2008-03-171-26/+130
| | | | | | | | | | | | | | | | | | | | * 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
* fix doc.akr2008-03-091-9/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * numeric.c (fix_to_s): avoid rb_scan_args() when no argumentmatz2008-03-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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
* * re.c (rb_reg_regsub): remove too strict encoding check.matz2008-03-031-1/+0
| | | | | | [ruby-dev:33966] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * time.c (time_strftime): format should be ascii compatible.matz2008-02-291-0/+1
| | | | | | | | | | | | * 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
* add tests for sub/gsub with hash.akr2008-02-181-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* typo fix.akr2008-02-181-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (re_warn): defined to restore warnings for /[a-c-e]/, etc.akr2008-02-181-0/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_regsub): don't repeat repl twice withakr2008-02-171-0/+1
| | | | | | | "X".sub!(/./, sprintf("\\%c", 255)). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_prepare_re): add enable_warning parameter.akr2008-02-171-4/+5
| | | | | | | | (rb_reg_adjust_startpos): disable warning by rb_reg_prepare_re. (rb_reg_search): follow rb_reg_prepare_re parameter change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_quote): return US-ASCII string consistently.akr2008-02-171-2/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/re.h (struct rmatch_offset): new struct for characterakr2008-02-161-45/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * re.c (match_inspect): avoid SEGV with MatchData.allocate.inspect.akr2008-02-161-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_quote): set US-ACII for ASCII-only string.nobu2008-02-151-1/+1
| | | | | | | [ruby-dev:33785] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_preprocess_dregexp): use non-preprocessed regexp sourceakr2008-02-141-11/+14
| | | | | | | for result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * insns.def (toregexp): generate a regexp from strings instead of oneakr2008-01-291-28/+47
| | | | | | | | | | | | | | | | | string. * re.c (rb_reg_new_ary): defined for toregexp. it concatenates strings after each string is preprocessed. * compile.c (compile_dstr_fragments): split from compile_dstr. (compile_dstr): call compile_dstr_fragments. (compile_dregx): defined for dynamic regexp. (iseq_compile_each): use compile_dregx for dynamic regexp. [ruby-dev:33400] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * string.c, parse.y, re.c: use rb_ascii8bit_encoding.naruse2008-01-281-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/oniguruma.h: precise mbclen API redesigned to avoidakr2008-01-271-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | inline functions. (onigenc_mbclen_charfound): removed. (onigenc_mbclen_needmore): removed. (onigenc_mbclen_recover): removed. (ONIGENC_MBCLEN_CHARFOUND): removed. (ONIGENC_MBCLEN_CHARFOUND_P): defined. (ONIGENC_MBCLEN_CHARFOUND_LEN): defined. (ONIGENC_MBCLEN_INVALID): removed. (ONIGENC_MBCLEN_INVALID_P): defined. (ONIGENC_MBCLEN_NEEDMORE): removed. (ONIGENC_MBCLEN_NEEDMORE_P): defined. (ONIGENC_MBCLEN_NEEDMORE_LEN): defined. (ONIGENC_MBC_ENC_LEN): use onigenc_mbclen_approximate. * regenc.c (onigenc_mbclen_approximate): defined. * include/ruby/encoding.h (MBCLEN_CHARFOUND): removed. (MBCLEN_INVALID): removed. (MBCLEN_NEEDMORE): removed. (MBCLEN_CHARFOUND_P): defined. (MBCLEN_INVALID_P): defined. (MBCLEN_NEEDMORE_P): defined. (MBCLEN_CHARFOUND_LEN): defined. (MBCLEN_NEEDMORE_LEN): defined. * encoding.c: use new API. * re.c: ditto. * string.c: ditto. * parse.y: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_source): set encoding as regexp encoding.naruse2008-01-271-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_preprocess): force fixed encoding when ASCIIakr2008-01-261-1/+7
| | | | | | | incompatible source string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_str_buf_cat_ascii): declared.akr2008-01-251-1/+4
| | | | | | | | | | * string.c (rb_str_buf_cat_ascii): defined. * re.c (rb_reg_s_union): use rb_str_buf_cat_ascii to support ASCII incompatible encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_fixed_encoding_p): no need to treat ASCII-8BIT specially.usa2008-01-241-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_initialize): 7bit clean regexp should be US-ASCII.usa2008-01-241-1/+1
| | | | | | | | [ruby-dev:33346] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_prepare_re): fix SEGV byakr2008-01-231-1/+5
| | | | | | | /a/ =~ "aa".force_encoding("utf-16be"). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_char_to_option_kcode): Regexp switch `s' should meanusa2008-01-181-1/+1
| | | | | | | | Windows-31J, as wells as `-Ks'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_char_to_option_kcode): fixed typo.nobu2008-01-171-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_char_to_option_kcode): use rb_enc_find_index() insteadmatz2008-01-141-9/+3
| | | | | | | | of using fixed index value. * enc/Makefile.in (encsrcdir): make US-ASCII built-in. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_prepare_re): initialize error message buffer.akr2008-01-141-9/+9
| | | | | | | | | | | | | (rb_reg_search): ditto. (rb_reg_check_preprocess): ditto. (rb_reg_new_str): ditto. (rb_enc_reg_new): ditto. (rb_reg_compile): ditto. (rb_reg_initialize_m): ditto. (rb_reg_s_union_m): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_preprocess): fix fixed_enc condition.akr2008-01-071-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * encoding.c (rb_enc_internal_get_index): extracted fromakr2008-01-071-1/+1
| | | | | | | | | | | | | | | | | | | | | rb_enc_get_index. (rb_enc_internal_set_index): extracted from rb_enc_associate_index * include/ruby/encoding.h (ENCODING_SET): work over ENCODING_INLINE_MAX. (ENCODING_GET): ditto. (ENCODING_IS_ASCII8BIT): defined. (ENCODING_CODERANGE_SET): defined. * re.c (rb_reg_fixed_encoding_p): use ENCODING_IS_ASCII8BIT. * string.c (rb_enc_str_buf_cat): use ENCODING_IS_ASCII8BIT. * parse.y (reg_fragment_setenc_gen): use ENCODING_IS_ASCII8BIT. * marshal.c (has_ivars): use ENCODING_IS_ASCII8BIT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_initialize_str): forbid raw non ASCII characterakr2008-01-061-2/+10
| | | | | | | for ASCII-8BIT regexp in non ASCII-8BIT script. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_enc_str_buf_cat): declared.akr2008-01-061-18/+18
| | | | | | | | | | | | | | | | * string.c (coderange_scan): extracted from rb_enc_str_coderange. (rb_enc_str_coderange): use coderange_scan. (rb_str_shared_replace): copy encoding and coderange. (rb_enc_str_buf_cat): new function for linear complexity string accumulation with encoding. (rb_str_sub_bang): don't conflict substituted part and replacement. (str_gsub): use rb_enc_str_buf_cat. (rb_str_clear): clear coderange. * re.c (rb_reg_regsub): use rb_enc_str_buf_cat. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_initialize_str): /\x80/n is not an error even if scriptakr2008-01-051-2/+8
| | | | | | | encoding is EUC-JP. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h, re.c (rb_reg_new): keep interface same asnobu2008-01-041-6/+38
| | | | | | | | | | | | | | | | 1.8. [ruby-core:14583] * include/ruby/intern.h, re.c (rb_reg_new_str): renamed, and defines HAVE_RB_REG_NEW_STR macro to tell if it is available. * include/ruby/encoding.h (rb_enc_reg_new): added. * insns.def (toregexp), marshal.c (r_object0): use rb_reg_new_str(). * re.c (rb_reg_regcomp, rb_reg_s_union): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_prepare_re): check string encoding. Oniguruma doesn'takr2008-01-041-0/+6
| | | | | | | support invalid encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* unused variable removed.akr2008-01-041-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_search): avoid inner loop for reverse search.matz2008-01-041-27/+9
| | | | | | | * regexec.c: unset USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE which is turned on since oniguruma 5.9.1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * re.c (rb_reg_search): iterate onig_match for reverse mode.akr2008-01-031-8/+23
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix typos.akr2007-12-311-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e