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

488 Коммитов

Автор SHA1 Сообщение Дата
kazu e712ad9cd7 [DOC] Fix exception class [ci skip]
ref https://github.com/rurema/doctree/pull/816

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13 14:08:20 +00:00
kazu 210f2cc7e8 Regexp#===: Use `\A` and `\z` instead of `^` and `$`
[ci skip]
ref https://github.com/rurema/doctree/pull/812

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16 03:32:23 +00:00
naruse 6187b0001b [Feature #13712] String#start_with? supports regexp
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 06:51:01 +00:00
nobu 4fb1438b9d use rb_hash_new_with_size()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-02 12:23:17 +00:00
rhe 2bd222abfb re.c: remove unused rb_memcmp() function
It is no longer used or exported as of r13641.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-18 05:37:29 +00:00
nobu d96eba12c2 re.c: options for sub-regexp
* re.c (rb_reg_to_s): needs embedded options to check syntax of
  sub-regexp.  [ruby-core:82328] [Bug #13798]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-11 02:05:24 +00:00
akr d8cee4ff0a refine a warning message.
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-03-02 23:33:06 +00:00
akr dbd4c4a7b3 refine warning message for binary regexp /.../n.
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
2017-02-22 07:31:25 +00:00
rhe dc2d359b70 re.c: consider the case of RMatch::regexp is nil
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-20 07:32:23 +00:00
nobu 528f870e14 re.c: RB_TYPE_P
* 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-19 04:07:40 +00:00
nobu db29a279fc re.c: NAME_TO_NUMBER
* 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-19 03:11:57 +00:00
nobu 9fc44b8790 re.c: use name_to_backref_number
* 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-18 11:43:51 +00:00
nobu 7f4dc81717 re.c: non-regexp name reference
* 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-17 00:52:47 +00:00
nobu 6dd5ee752a String#match? and Symbol#match?
* 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-12 02:56:12 +00:00
nobu 2800e6a0a4 re.c: char boundary
* 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-12 02:38:53 +00:00
naruse 2873edeafb Merge Onigmo 6.0.0
* 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-10 17:47:04 +00:00
rhe d802149be3 re.c: check that MatchData is initialized
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-06 06:14:17 +00:00
rhe 76bb017ad2 re.c: count associated Regexp object in MatchData#hash
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-12-02 02:24:45 +00:00
nobu 4e44f6ef86 [DOC] replace Fixnum with Integer [ci skip]
* 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-26 06:11:23 +00:00
usa c2dd2d268e * internal.h (ST2FIX): new macro to convert st_index_t to Fixnum.
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-10-04 16:25:01 +00:00
akr 577de1e93d replace fixnum by integer in documents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-08 04:57:49 +00:00
naruse e45cf75f9a * re.c (unescape_nonascii): scan hex up to only 3 characters.
[Bug #12420] [Bug #12423]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25 11:51:37 +00:00
kazu 02942a6b90 fix document of Regexp#match?
* 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-19 12:23:57 +00:00
nobu a28c12af14 re.c: fix match?
* 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-19 03:10:12 +00:00
nobu 780c056dad re.c: match? should return nil if no match
* 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-19 02:37:38 +00:00
naruse a6c38cb4d3 * re.c (reg_names_iter): specify capacify
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-18 15:17:31 +00:00
nobu d23bd5803e re.c: fix type
* 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 11:32:26 +00:00
naruse f09574c879 * re.c (rb_reg_match_m_p): Introduce Regexp#match?, which returns
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 10:37:13 +00:00
naruse b8fde96861 * re.c (match_ary_subseq): get subseq of match array without creating
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-18 04:56:02 +00:00
nobu 7f860741b9 re.c: fix up r55036
* 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 18:16:08 +00:00
naruse e6a10e89b1 * re.c (match_aref): remove useless condition and call rb_fix2int.
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 17:10:01 +00:00
naruse 92f8d74a3e * re.c (match_values_at): MatchData#values_at supports named captures
[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-17 17:10:01 +00:00
naruse d0fbdb005c * re.c (str_coderange): to avoid function call when the string already
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-05-02 12:04:04 +00:00
naruse 0c4466abba * re.c (rb_reg_prepare_enc): use rb_enc_asciicompat(enc) instead of
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-04-28 07:52:59 +00:00
sorah e8074a382e * re.c: Add MatchData#named_captures
[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-18 05:29:18 +00:00
nobu 301cbf4d69 Update re.c [ci skip]
* 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-12 02:17:58 +00:00
zzak d901058900 * re.c: Remove deprecated kcode argument from Regexp.new and compile
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-09 04:54:39 +00:00
nobu 445b015c3a fstring without copy
* 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-04 08:38:06 +00:00
nobu 09c9110896 revert re.c in r53736
* 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-04 06:46:28 +00:00
nobu 25fd278459 return shared string
* 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-04 06:44:55 +00:00
nobu 94c70c7d72 fstring_enc_new
* 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-04 06:35:34 +00:00
naruse 7aefa7b89f * re.c (rb_reg_prepare_enc): use already compiled US-ASCII regexp
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 17:38:00 +00:00
naruse 21daa56b2a * re.c: Introduce RREGEXP_PTR.
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-02-02 04:39:44 +00:00
nobu 92e803c9c8 variable.c: matched backrefs only
* 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
2016-01-14 08:36:49 +00:00
nobu e64d814101 re.c: names encoding
* 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-12-17 00:46:07 +00:00
nobu 907b6d32be re.c: indent [ci skip]
* 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-10-07 08:26:56 +00:00
nobu 078b6c9838 encindex.h: ENCINDEX
* 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-09-15 05:49:20 +00:00
nobu 5ce4bfc9d2 re.c: fix wchar match at EOS
* 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-26 01:52:04 +00:00
nobu 2c8986d23b re.c: fix for wide character encodings
* 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-08-03 01:08:36 +00:00
nobu 137d08de4b encoding.h: ENC_CODERANGE_CLEAN_P
* 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-07-17 06:39:29 +00:00