]> granicus.if.org Git - onig/commitdiff
add onig_initialize_match_params()
authorK.Kosako <kosako@sofnec.co.jp>
Tue, 30 Jan 2018 04:57:23 +0000 (13:57 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Tue, 30 Jan 2018 04:57:23 +0000 (13:57 +0900)
src/oniguruma.h
src/regexec.c

index e80fb75bd5e3b85753605706cd80d7c93f579673..af9ab9236ca2fc8026bef34e89786ba12f1fce19 100644 (file)
@@ -737,9 +737,27 @@ typedef struct {
   OnigCaseFoldType   case_fold_flag;
 } OnigCompileInfo;
 
+
+typedef struct {
+  OnigUChar*   content;
+  OnigUChar*   name;
+  regex_t*     reg;
+  const UChar* str;
+  const UChar* end;
+  UChar* right_range;
+  const UChar* sstart;
+  UChar* s;  // current matching position
+  unsigned long try_in_match_counter;
+} OnigCalloutArgs;
+
+typedef int (*OnigCalloutFunc)(OnigCalloutArgs* args, void* user_data);
+
 typedef struct {
-  unsigned int  match_stack_limit;
-  unsigned long try_in_match_limit;
+  unsigned int    match_stack_limit;
+  unsigned long   try_in_match_limit;
+  OnigCalloutFunc callout;
+  OnigCalloutFunc retraction_callout;
+  void* callout_user_data;
 } OnigMatchParams;
 
 /* Oniguruma Native API */
@@ -776,6 +794,9 @@ 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, OnigMatchParams* mp));
+ONIG_EXTERN
+void onig_initialize_match_params P_((OnigMatchParams* mp));
+
 ONIG_EXTERN
 OnigRegion* onig_region_new P_((void));
 ONIG_EXTERN
index bcb7235b413a9ada9c85282dcd0aa1cb76ef4022..3a50025bd12e36bcb7f1e12306bd64866ac50789 100644 (file)
@@ -990,6 +990,18 @@ onig_set_try_in_match_limit(unsigned long size)
 #endif
 }
 
+extern void
+onig_initialize_match_params(OnigMatchParams* mp)
+{
+  mp->match_stack_limit  = MatchStackLimit;
+#ifdef USE_TRY_IN_MATCH_LIMIT
+  mp->try_in_match_limit = TryInMatchLimit;
+#endif
+  mp->callout            = 0;
+  mp->retraction_callout = 0;
+  mp->callout_user_data  = 0;
+}
+
 
 static int
 stack_double(int is_alloca, char** arg_alloc_base,
@@ -3792,11 +3804,7 @@ onig_match(regex_t* reg, const UChar* str, const UChar* end, const UChar* at,
 {
   OnigMatchParams mp;
 
-  mp.match_stack_limit = MatchStackLimit;
-#ifdef USE_TRY_IN_MATCH_LIMIT
-  mp.try_in_match_limit = TryInMatchLimit;
-#endif
-
+  onig_initialize_match_params(&mp);
   return onig_match_with_params(reg, str, end, at, region, option, &mp);
 }
 
@@ -4096,11 +4104,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
 {
   OnigMatchParams mp;
 
-  mp.match_stack_limit = MatchStackLimit;
-#ifdef USE_TRY_IN_MATCH_LIMIT
-  mp.try_in_match_limit = TryInMatchLimit;
-#endif
-
+  onig_initialize_match_params(&mp);
   return onig_search_with_params(reg, str, end, start, range, region, option, &mp);
 }