summaryrefslogtreecommitdiff
path: root/re.c
AgeCommit message (Collapse)Author
2017-03-02refine a warning message.akr
The "n" option for regexp, /.../n, is historical. It doesn't mean the regexp works as binary match since Ruby 1.9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-22refine warning message for binary regexp /.../n.akr
Reported by Herwin W. [ruby-core:78592] [Bug #13024] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-20re.c: consider the case of RMatch::regexp is nilrhe
Follow r49675, r57098 and r57110. Don't assume RMatch::regexp always contains a valid Regexp instance; it will be Qnil if the MatchData is created by rb_backref_set_string(). [ruby-core:78741] [Bug #13054] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-19re.c: RB_TYPE_Pnobu
* re.c (match_backref_number, namev_to_backref_number): use RB_TYPE_P instead of switching by TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-19re.c: NAME_TO_NUMBERnobu
* re.c (namev_to_backref_number, rb_reg_regsub): extract name to backref number check as NAME_TO_NUMBER. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-18re.c: use name_to_backref_numbernobu
* re.c (match_backref_number): use name_to_backref_number for casts. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-17re.c: non-regexp name referencenobu
* re.c (rb_reg_regsub): other than regexp has no name references. [ruby-core:78686] [Bug #13042] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-12String#match? and Symbol#match?nobu
* string.c (rb_str_match_m_p): inverse of Regexp#match?. based on the patch by Herwin Weststrate <herwin@snt.utwente.nl>. [Fix GH-1483] [Feature #12898] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-12re.c: char boundarynobu
* re.c (rb_reg_match_m_p): consider char boundary. rb_str_subpos does not adjust to the boundary if len == 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-10Merge Onigmo 6.0.0naruse
* https://github.com/k-takata/Onigmo/blob/Onigmo-6.0.0/HISTORY * fix for ruby 2.4: https://github.com/k-takata/Onigmo/pull/78 * suppress warning: https://github.com/k-takata/Onigmo/pull/79 * include/ruby/oniguruma.h: include onigmo.h. * template/encdb.h.tmpl: ignore duplicated definition of EUC-CN in enc/euc_kr.c. It is defined in enc/gb2313.c with CRuby macro. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-06re.c: check that MatchData is initializedrhe
Follow r16757 ("* re.c: fix SEGV by Regexp.allocate.names, Match.allocate.names, etc.", 2008-06-02). Don't do null dereference if MatchData#hash or #== is called against an uninitialized instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-02re.c: count associated Regexp object in MatchData#hashrhe
Don't discard the hash value computed for the regexp object. It seems it was simply missed out in r24754, when MatchData#hash was initially implemented. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-26[DOC] replace Fixnum with Integer [ci skip]nobu
* numeric.c: [DOC] update document for Integer class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-04* internal.h (ST2FIX): new macro to convert st_index_t to Fixnum.usa
a hash value of Object might be Bignum, but it causes many troubles expecially the Object is used as a key of a hash. so I've gave up to do so. * array.c (rb_ary_hash): use above macro. * bignum.c (rb_big_hash): ditto. * hash.c (rb_obj_hash, rb_hash_hash): ditto. * numeric.c (rb_dbl_hash): ditto. * proc.c (proc_hash): ditto. * re.c (rb_reg_hash, match_hash): ditto. * string.c (rb_str_hash_m): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08replace fixnum by integer in documents.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25* re.c (unescape_nonascii): scan hex up to only 3 characters.naruse
[Bug #12420] [Bug #12423] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-19fix document of Regexp#match?kazu
* re.c (rb_reg_match_m_p): [DOC] fix return value in rdoc. * test/ruby/test_regexp.rb (TestRegexp#test_match_p): add some tests from document. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-19re.c: fix match?nobu
* re.c (rb_reg_match_m_p): fix match against empty string. rb_str_offset returns the end when the position exceeds the length. fix the range parameter of onig_search. [ruby-core:75604] [Bug #12394] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-19re.c: match? should return nil if no matchnobu
* re.c (rb_reg_match_m_p): should return nil if no match, as the document says. [Feature #8110] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18* re.c (reg_names_iter): specify capacifynaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18re.c: fix typenobu
* re.c (rb_reg_match_m_p): fix type of variable for onig_search result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18* re.c (rb_reg_match_m_p): Introduce Regexp#match?, which returnsnaruse
bool and doesn't save backref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18* re.c (match_ary_subseq): get subseq of match array without creatingnaruse
temporary array. * re.c (match_ary_aref): get element(s) of match array without creating temporary array. * re.c (match_aref): Use match_ary_subseq with handling irregulars. * re.c (match_values_at): Use match_ary_aref. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17re.c: fix up r55036nobu
* re.c (match_values_at): fix regression at r55036. MatchData#values_at accepts Range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17* re.c (match_aref): remove useless condition and call rb_fix2int.naruse
rb_reg_nth_match handles negative index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-17* re.c (match_values_at): MatchData#values_at supports named capturesnaruse
[Feature #9179] * re.c (namev_to_backref_number): separeted. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-02* re.c (str_coderange): to avoid function call when the string alreadynaruse
has coderange information. * re.c (rb_reg_prepare_enc): add shortcut path when the regexp has the same encoding of given string. * re.c (rb_reg_prepare_re): avoid duplicated allocation of onig_errmsg_buffer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-28* re.c (rb_reg_prepare_enc): use rb_enc_asciicompat(enc) instead ofnaruse
rb_enc_str_asciicompat_p(str) to avoid useless rb_enc_get(str) call. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-18* re.c: Add MatchData#named_capturessorah
[Feature #11999] [ruby-core:72897] * test/ruby/test_regexp.rb(test_match_data_named_captures): Test for above. * NEWS: News about MatchData#named_captures. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-12Update re.c [ci skip]nobu
* re.c (rb_reg_initialize_m): [DOC] fix missing right bracket. [Fix GH-1243] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-09* re.c: Remove deprecated kcode argument from Regexp.new and compilezzak
patch provided by Dylan Pulliam [Bug #11495] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-04fstring without copynobu
* re.c (reg_set_source): make source string frozen without copying. * re.c (rb_reg_initialize_m): refactor initialization with encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-04revert re.c in r53736nobu
* re.c (rb_reg_initialize): must copy the source string content, it is not a static literal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-04return shared stringnobu
* re.c (rb_reg_source): return shared string without copying. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-04fstring_enc_newnobu
* string.c (rb_fstring_enc_new, rb_fstring_enc_cstr): functions to make fstring with encoding. * re.c (rb_reg_initialize): make fstring without copying. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-02* re.c (rb_reg_prepare_enc): use already compiled US-ASCII regexpnaruse
if given string is ASCII only. 121.2s to 113.9s on my x86_64-freebsd10.2 Intel Core i5 661 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-02* re.c: Introduce RREGEXP_PTR.naruse
patch by dbussink. partially merge https://github.com/ruby/ruby/pull/497 * include/ruby/ruby.h: ditto. * gc.c: ditto. * ext/strscan/strscan.c: ditto. * parse.y: ditto. * string.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-14variable.c: matched backrefs onlynobu
* variable.c (rb_f_global_variables): add matched back references only, as well as defiend? operator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-17re.c: names encodingnobu
* re.c (reg_names_iter): should consider encoding of regexp. [ruby-core:72185] [Bug #11825] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-07re.c: indent [ci skip]nobu
* re.c (onig_new_with_source, rb_reg_search0): adjust indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15encindex.h: ENCINDEXnobu
* encindex.h: separate encoding index constants from internal.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-26re.c: fix wchar match at EOSnobu
* re.c (rb_memsearch_wchar, rb_memsearch_qchar): test matching till the end of string. [ruby-core:70592] [Bug #11488] * test/ruby/test_m17n.rb (test_include?, tet_index): add tests by Tom Stuart. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-03re.c: fix for wide character encodingsnobu
* re.c (rb_memsearch): should match only char boundaries in wide character encodings. [ruby-core:70220] [Bug #11413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17encoding.h: ENC_CODERANGE_CLEAN_Pnobu
* include/ruby/encoding.h (ENC_CODERANGE_CLEAN_P): predicate that tells if the coderange is clean, that is 7bit or valid, and no needs to scrub. * re.c (rb_reg_expr_str): use ENC_CODERANGE_CLEAN_P. * string.c (enc_strlen, rb_enc_cr_str_buf_cat, rb_str_scrub): ditto. * string.c (rb_str_enumerate_chars): ditto, and suppress a warning by gcc6. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24* re.c: Update documentation for Regexp class.hsbt
[fix GH-937][ci skip] Patch by @davydovanton git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-17* include/ruby/ruby.h: $SAFE=3 is now obsolete.hsbt
* ext/socket/init.c, ext/socket/socket.c, ext/socket/tcpsocket.c ext/socket/udpsocket.c, gc.c, object.c, re.c, safe.c: removed code for $SAFE=3 * bootstraptest/test_method.rb, test/erb/test_erb.rb, test/ruby/test_dir.rb test/ruby/test_file.rb, test/ruby/test_method.rb, test/ruby/test_regexp.rb test/ruby/test_thread.rb: remove tests for $SAFE=3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-14use frozen string of symbolsnobu
* range.c (range_step, range_each): String#upto should never modifies the receiver, use frozen strings to enumerate symbols. * re.c (reg_operand): matching target is not modified. * ext/socket/constants.c (constant_arg): str_to_int never modifies argument strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21re.c: RMatch::regexp can be nilnobu
* re.c (match_aref): RMatch::regexp is Qnil after matching by a string since r45451. [ruby-core:68209] [Bug #10877] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-29re.c: append excape sequence as-isnobu
* re.c (unescape_nonascii): append excape sequence as-is not unescaped character, to get rid of unexpected meta-character. [ruby-core:67193] [Bug #10670] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01re.c: rb_reg_region_copynobu
* re.c (rb_reg_region_copy): new function to try with GC if copy failed and return the error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e