aboutsummaryrefslogtreecommitdiffstats
path: root/regexec.c
diff options
context:
space:
mode:
authorTSUYUSATO Kitsune <make.just.on@gmail.com>2022-12-14 12:57:14 +0900
committerGitHub <noreply@github.com>2022-12-14 12:57:14 +0900
commitfbedadb61f49ba3aaf4f07939b4fc7d0b8f8ac03 (patch)
tree05f5147da45c55947f220e9e2119b905d97cdab3 /regexec.c
parentfe3cbc61c805a860da3d41253879708ec86b6aa2 (diff)
downloadruby-fbedadb61f49ba3aaf4f07939b4fc7d0b8f8ac03.tar.gz
Add `Regexp.linear_time?` (#6901)
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/regexec.c b/regexec.c
index a9822ee064..a52ed800c5 100644
--- a/regexec.c
+++ b/regexec.c
@@ -694,7 +694,21 @@ unexpected_bytecode_error:
bytecode_error:
return ONIGERR_UNDEFINED_BYTECODE;
}
-#endif /* USE_MATCH_CACHE */
+#else /* USE_MATCH_CACHE */
+static OnigPosition count_num_cache_opcode(regex_t* reg, long* num, long* table_size)
+{
+ *num = NUM_CACHE_OPCODE_FAIL;
+ return 0;
+}
+#endif
+
+extern int
+onig_check_linear_time(OnigRegexType* reg)
+{
+ long num = 0, table_size = 0;
+ count_num_cache_opcode(reg, &num, &table_size);
+ return num != NUM_CACHE_OPCODE_FAIL;
+}
extern void
onig_region_clear(OnigRegion* region)