summaryrefslogtreecommitdiff
path: root/regcomp.c
AgeCommit message (Collapse)Author
2 daysFix regexp performance regression for patterns starting with s/kChris Hasiński
Commit 981ee02c7c ("Fix performance problem with /k/i and /s/i") was merged for Ruby 4.0 to enable partial Boyer-Moore optimization for patterns containing 's' or 'k' by using the prefix before those characters. However, when 's' or 'k' appears at the start of a pattern (no usable prefix), set_bm_skip() returns 0 and the code returned early without setting any optimization mode, leaving reg->optimize at ONIG_OPTIMIZE_NONE. This caused up to 30x slowdown for patterns like /slackware/i when matched against strings with non-ASCII characters. This patch keeps the improvement from 981ee02c7c for patterns with 3+ char prefix, while fixing the regression by falling back to ONIG_OPTIMIZE_EXACT_IC with the full pattern when the usable prefix is less than 3 characters. Before: /\bslackware\b/i with non-ASCII string: 2.24 us/op After: /\bslackware\b/i with non-ASCII string: 0.70 us/op (3.2x faster) [Bug #21824]
3 days[k-takata/Onigmo] Suppress warning on 64-bit buildsK.Takata
https://github.com/k-takata/Onigmo/commit/ced209d5e9
3 days[k-takata/Onigmo] Fix that onig_new() may crashK.Takata
When onig_reg_init() returns an error, onig_free_body() which is called via onig_new() may crash because some members are not properly initialized. Fix it. https://github.com/k-takata/Onigmo/commit/d2a090a57e
3 days[k-takata/Onigmo] Update copyright informationK.Takata
* Update our copyright information. * Import the latest information from oniguruma. Related: #95 https://github.com/k-takata/Onigmo/commit/0d8662b500
3 days[k-takata/Onigmo] Revise set_bm_skip()K.Takata
https://github.com/k-takata/Onigmo/commit/6875da50f7
3 days[k-takata/Onigmo] Remove code for backward BM searchK.Takata
The code has not been used for long. (Oniguruma also removed this code.) https://github.com/k-takata/Onigmo/commit/8796781fdd
3 days[k-takata/Onigmo] Remove code for reg->int_mapK.Takata
https://github.com/k-takata/Onigmo/commit/6c58de82d2
2025-10-31Remove old code for BMH searchK.Takata
Remove the code for Boyer-Moore-Horspool search. Now we are using Sunday's quick search. https://github.com/k-takata/Onigmo/commit/3d9072419a1578b742a422412d004fd8a54209fd
2025-10-31Fix initialization of the table for quick searchK.Takata
This fixes k-takata/Onigmo#120. The commit k-takata/Onigmo@9c13de8d0684ebde97e3709d7693997c81ca374b was insufficient. https://github.com/k-takata/Onigmo/commit/1de602ddff140d91419e3f86dd35c81d7bd2d8e7
2025-10-31Fix lgtm.com warningsK.Takata
* Multiplication result may overflow 'int' before it is converted to 'OnigDistance'. * Comparison is always true because code <= 122. * This statement makes ExprStmt unreachable. * Empty block without comment https://github.com/k-takata/Onigmo/commit/387ad616c3cb9370f99d2b11198c2135fa07030f
2025-10-31[Bug #13671] Fix that "ss" in look-behind causes syntax errorK.Takata
Fixes k-takata/Onigmo#92. This fix was ported from oniguruma: https://github.com/kkos/oniguruma/commit/257082dac8c6019198b56324012f0bd1830ff4ba https://github.com/k-takata/Onigmo/commit/b1a5445fbeba97b3e94a733c2ce11c033453af73
2025-10-31Revert "[tune] implicit-anchor optimization"K.Takata
This reverts commit 282338f88a8bf0807a7a1d21b06f78abe9de8fac. It seems that the commit didn't improve the performance. Revert it to fix k-takata/Onigmo#100. https://github.com/k-takata/Onigmo/commit/cef834cb3a6e278fa252f52b704c65175a970ac0
2025-10-31Fix performance problem with /k/i and /s/i (Close k-takata/Onigmo#97)K.Takata
E.g. For the pattern `/----k/i`, optimization was totally turned off. Make it possible to use the characters before `k` (i.e. `----`) for optimization. https://github.com/k-takata/Onigmo/commit/9c13de8d0684ebde97e3709d7693997c81ca374b
2025-07-31Fix indents in Onigmo files to use spaces instead of tabs (#14047) [no ci]Hiroya Fujinami
2024-02-13Fix [Bug #20246]: Don't set next_head_exact if a capture is called (#9897)Hiroya Fujinami
2024-01-19Remove null checks for xfreePeter Zhu
xfree can handle null values, so we don't need to check it.
2023-11-03Fix onigmo name table without stNobuyoshi Nakada
Co-authored-by: Adam Hess <HParker@github.com>
2023-10-30Optimize regexp matching for look-around and atomic groups (#7931)Hiroya Fujinami
2023-07-27Use onig_new_without_alloc for onig_newPeter Zhu
2023-06-30Don't check for null pointer in calls to freePeter Zhu
According to the C99 specification section 7.20.3.2 paragraph 2: > If ptr is a null pointer, no action occurs. So we do not need to check that the pointer is a null pointer. Notes: Merged: https://github.com/ruby/ruby/pull/8004
2023-06-09Optimize `Regexp#dup` and `Regexp.new(/RE/)`Nobuyoshi Nakada
When copying from another regexp, copy already built `regex_t` instead of re-compiling its source. Notes: Merged: https://github.com/ruby/ruby/pull/7922
2022-10-14Use `roomof` macro for rounding up divisionsNobuyoshi Nakada
2022-04-12Just free compiled pattern if no space is usedNobuyoshi Nakada
https://hackerone.com/reports/1220911 Notes: Merged: https://github.com/ruby/ruby/pull/5793
2022-03-30re.c: Add Regexp.timeout= and Regexp.timeoutYusuke Endoh
[Feature #17837] Notes: Merged: https://github.com/ruby/ruby/pull/5703
2021-10-14Cast up to get rid of the potential overflow posibilityNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4968
2021-05-07Fixed shorten-64-to-32 errors when USE_COMBINATION_EXPLOSION_CHECKNobuyoshi Nakada
2021-03-15Check backref number buffer overrun [Bug #16376]xtkoba (Tee KOBAYASHI)
2020-12-10Right size literal regular expression buffers on compileLourens Naudé
Notes: Merged: https://github.com/ruby/ruby/pull/2696
2018-09-15Fix issues detected by code analysis tool (mainly Coverity).nobu
* Fix leaked storage in addr2line.c. * Fix for "top_root" leaking the resource. [Fix GH-1956] From: Jun Aruga <jaruga@redhat.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18Fix typos.hsbt
* rememberd -> remembered * refered -> referred git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-11Merge Onigmo 6.1.1naruse
* Support absent operator https://github.com/k-takata/Onigmo/issues/82 * https://github.com/k-takata/Onigmo/blob/Onigmo-6.1.1/HISTORY git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-25regcomp.c: debug function [ci skip]nobu
* regcomp.c (print_indent_tree): make a function for debug static. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-21regcomp.c: Fix compile error with old version of fcc on Solarisngoto
* regcomp.c (get_min_match_length): Fix compile error with old version of fcc (Fujitsu C Compiler) on Solaris 10. [Bug #13059][ruby-dev:49909] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57143 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-11-30Regexp supports Unicoe 9.0.0's \Xnaruse
* meta character \X matches Unicode 9.0.0 characters with some workarounds for UTR #51 Unicode Emoji, Version 4.0 emoji zwj sequences. [Feature #12831] [ruby-core:77586] The term "character" can have many meanings bytes, codepoints, combined characters, and so on. "grapheme cluster" is highest one of such words, which means user-perceived characters. Unicode Standard Annex #29 UNICODE TEXT SEGMENTATION specifies how to handle grapheme clusters (extended grapheme cluster). But some specs aren't updated to current situation because Unicode Emoji is rapidly extended without well definition. It breaks the precondition of UTR#29 "Grapheme cluster boundaries can be easily tested by looking at immediately adjacent characters". (the sentence will be removed in the next version) Though some of its detail are described in Unicode Technical Report #51 UNICODE EMOJI but it is not merged into UTR#29 yet. http://unicode.org/reports/tr29/ http://unicode.org/reports/tr51/ http://unicode.org/Public/emoji/4.0/ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-03* regcomp.c (onig_print_compiled_byte_code): make the shown addressnaruse
look relative. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-01* regcomp.c (noname_disable_map): don't optimize out group 0naruse
Ruby's Regexp doesn't allow normal numbered groups if the regexp has named groups. On such case it optimizes out related NT_ENCLOSE. But even on the case it can use \g<0>. This fix not to remove NT_ENCLOSE whose regnum is 0. [ruby-core:75828] [Bug #12454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25regcomp.c: fix debug conditionalsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25* regcomp.c: remove condition for debug output because preludenaruse
doesn't use regexp now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25* regcomp.c (compile_length_tree): return error code immediatelynaruse
if compile_length_tree raised error [Bug #12418] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09Revert r52995nobu
revert slow atomic operations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09use atomic operationsnobu
* regcomp.c (onig_chain_link_add): use atomic operation instead of mutex. * regint.h (ONIG_STATE_{INC,DEC}_THREAD): ditto. * regparse.c (PopFreeNode, node_recycle): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-26* regcomp.c, regenc.c, regexec.c, regint.h, enc/unicode.c:naruse
Merge Onigmo 58fa099ed1a34367de67fb3d06dd48d076839692 + https://github.com/k-takata/Onigmo/pull/52 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-15* reg*.c: Merge Onigmo 5.15.0 38a870960aa7370051a3544naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-16* regcomp.c: Merge Onigmo 5.14.1 25a8a69fc05ae3b56a09.naruse
this includes Support for Unicode 7.0 [Bug #9092]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04* regcomp.c (): Merge Onigmo 5.13.5 23b523076d6f1161.naruse
https://bugs.ruby-lang.org/issues/8583 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-13* Merge Onigmo 5.13.4 f22cf2e566712cace60d17f84d63119d7c5764ee.naruse
[bug] fix problem with optimization of \z (Issue #16) [Bug #8210] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-01* Merge Onigmo 0fe387da2fee089254f6b04990541c731a26757fnaruse
v5.13.3 [Bug#7972] [Bug#7974] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-05Remove unused variables.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-18* regcomp.c, regexec.c: fix-up warnings.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e