From: K.Kosako Date: Thu, 8 Feb 2018 05:56:41 +0000 (+0900) Subject: add onig_initialize_callout() X-Git-Tag: v6.8.0~338 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4d2a19e01d9e8c5fca9dbb177c9f928895974d6;p=onig add onig_initialize_callout() --- 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;