From a4d2a19e01d9e8c5fca9dbb177c9f928895974d6 Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Thu, 8 Feb 2018 14:56:41 +0900 Subject: [PATCH] add onig_initialize_callout() --- src/regcomp.c | 3 ++- src/regexec.c | 22 ++++++++++++++++++++++ src/regint.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/regcomp.c b/src/regcomp.c index cb4d0f5..d12ac54 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -6274,7 +6274,8 @@ onig_initialize(OnigEncoding encodings[], int n) return r; } - return 0; + r = onig_initialize_callout(); + return r; } typedef struct EndCallListItem { diff --git a/src/regexec.c b/src/regexec.c index ade4fda..b382699 100644 --- a/src/regexec.c +++ b/src/regexec.c @@ -4857,3 +4857,25 @@ onig_get_used_stack_size_in_callout(OnigCalloutArgs* args, int* used_num, int* u return ONIG_NORMAL; } + +extern int +onig_builtin_fail(OnigCalloutArgs* args, void* user_data) +{ + return ONIG_CALLOUT_FAIL; +} + +extern int +onig_initialize_callout(void) +{ +#define B1(name, func) do {\ + r = onig_set_callout_of_name(0, (UChar* )#name, (UChar* )(#name + strlen(#name)),\ + onig_builtin_ ## func, 0);\ + if (r != ONIG_NORMAL) return r;\ +} while(0) + + int r; + + B1(FAIL, fail); + + return ONIG_NORMAL; +} diff --git a/src/regint.h b/src/regint.h index 4dd4ee5..d0a285d 100644 --- a/src/regint.h +++ b/src/regint.h @@ -780,6 +780,7 @@ extern int onig_ext_set_pattern(regex_t* reg, const UChar* pattern, const UCh extern OnigCalloutFunc onig_get_callout_func_from_id(int id); extern OnigCalloutFunc onig_get_retraction_callout_func_from_id(int id); +extern int onig_initialize_callout(void); /* strend hash */ typedef void hash_table_type; -- 2.40.0