From: K.Kosako Date: Tue, 13 Feb 2018 04:41:04 +0000 (+0900) Subject: add OnigmatchParam access functions X-Git-Tag: v6.8.0~291 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a8372e69fdbb4a31aee4ade9f90cf8fcec277fd;p=onig add OnigmatchParam access functions --- diff --git a/src/oniguruma.h b/src/oniguruma.h index 8dacbe6..c5a246f 100644 --- a/src/oniguruma.h +++ b/src/oniguruma.h @@ -810,9 +810,6 @@ ONIG_EXTERN int onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option)); ONIG_EXTERN int onig_match_with_params P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option, OnigMatchParam* mp)); -ONIG_EXTERN -void onig_initialize_match_params P_((OnigMatchParam* mp)); - ONIG_EXTERN OnigRegion* onig_region_new P_((void)); ONIG_EXTERN @@ -904,6 +901,18 @@ const char* onig_version P_((void)); ONIG_EXTERN const char* onig_copyright P_((void)); +/* for OnigMatchParam */ +ONIG_EXTERN +void onig_initialize_match_params P_((OnigMatchParam* mp)); +ONIG_EXTERN +int onig_set_match_stack_limit_size_of_match_param P_((OnigMatchParam* param, unsigned int limit)); +ONIG_EXTERN +int onig_set_retry_limit_in_match_of_match_param P_((OnigMatchParam* param, unsigned long limit)); +ONIG_EXTERN +int onig_set_callout_of_code_of_match_param P_((OnigMatchParam* param, OnigCalloutFunc f)); +ONIG_EXTERN +int onig_set_retraction_callout_of_code_of_match_param P_((OnigMatchParam* param, OnigCalloutFunc f)); + /* for callout functions */ ONIG_EXTERN int onig_initialize_builtin_callouts P_((void)); diff --git a/src/regexec.c b/src/regexec.c index 6bb7a13..d83661a 100644 --- a/src/regexec.c +++ b/src/regexec.c @@ -40,6 +40,7 @@ #define CHECK_INTERRUPT_IN_MATCH + struct OnigMatchParamStruct { unsigned int match_stack_limit; unsigned long retry_limit_in_match; @@ -48,6 +49,39 @@ struct OnigMatchParamStruct { void* callout_user_data; }; +extern int +onig_set_match_stack_limit_size_of_match_param(OnigMatchParam* param, + unsigned int limit) +{ + param->match_stack_limit = limit; + return ONIG_NORMAL; +} + +extern int +onig_set_retry_limit_in_match_of_match_param(OnigMatchParam* param, + unsigned long limit) +{ + param->retry_limit_in_match = limit; + return ONIG_NORMAL; +} + +extern int +onig_set_callout_of_code_of_match_param(OnigMatchParam* param, OnigCalloutFunc f) +{ + param->callout_of_code = f; + return ONIG_NORMAL; +} + +extern int +onig_set_retraction_callout_of_code_of_match_param(OnigMatchParam* param, + OnigCalloutFunc f) +{ + param->retraction_callout_of_code = f; + return ONIG_NORMAL; +} + + + typedef struct { void* stack_p; int stack_n;