]> granicus.if.org Git - onig/commitdiff
add ONIG_REGSET_PRIORITY_TO_REGEX_ORDER into OnigRegSetLead
authorK.Kosako <kosako@sofnec.co.jp>
Mon, 30 Sep 2019 02:07:04 +0000 (11:07 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Mon, 30 Sep 2019 02:07:04 +0000 (11:07 +0900)
src/oniguruma.h
src/regexec.c

index 559cb2be312df459bcaeae64d1d4c343a4cd9a5c..6f39025868f99cbb46ca1cc24938fadbf05c9421 100644 (file)
@@ -692,7 +692,8 @@ typedef struct OnigRegSetStruct OnigRegSet;
 
 typedef enum {
   ONIG_REGSET_POSITION_LEAD = 0,
-  ONIG_REGSET_REGEX_LEAD    = 1
+  ONIG_REGSET_REGEX_LEAD    = 1,
+  ONIG_REGSET_PRIORITY_TO_REGEX_ORDER = 2
 } OnigRegSetLead;
 
 typedef struct {
index f71b81dfe1f4eabfaf7de282d60c732ecc8c168a..b4f12da09103ef08a9f78ac817d33e407d43a4a1 100644 (file)
@@ -4322,7 +4322,7 @@ regset_search_body_position_lead(OnigRegSet* set,
 static inline int
 regset_search_body_regex_lead(OnigRegSet* set,
               const UChar* str, const UChar* end,
-              const UChar* start, const UChar* orig_range,
+              const UChar* start, const UChar* orig_range, OnigRegSetLead lead,
               OnigOptionType option, OnigMatchParam* mps[], int* rmatch_pos)
 {
   int r;
@@ -4343,9 +4343,12 @@ regset_search_body_regex_lead(OnigRegSet* set,
     r = search_in_range(reg, str, end, start, ep, orig_range, region, option, mps[i]);
     if (r > 0) {
       if (str + r < ep) {
-        ep = str + r;
         match_index = i;
         *rmatch_pos = r;
+        if (lead == ONIG_REGSET_PRIORITY_TO_REGEX_ORDER)
+          break;
+
+        ep = str + r;
       }
     }
     else if (r == 0) {
@@ -4501,7 +4504,7 @@ onig_regset_search_with_param(OnigRegSet* set,
   }
   else {
     r = regset_search_body_regex_lead(set, str, end, start, orig_range,
-                                      option, mps, rmatch_pos);
+                                      lead, option, mps, rmatch_pos);
   }
   if (r < 0) goto finish;
   else       goto match2;