Add Regexp.linear_time? (#6901)

This commit is contained in:
TSUYUSATO Kitsune 2022-12-14 12:57:14 +09:00 committed by GitHub
parent fe3cbc61c8
commit fbedadb61f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-12-14 03:57:33 +00:00
Merged-By: makenowjust <make.just.on@gmail.com>
4 changed files with 59 additions and 1 deletions

View file

@ -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)