From 1e27f6bf475dafebec371e7036f57da2f307b35b Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Sun, 18 Aug 2013 16:22:18 +0200 Subject: [PATCH] Add ONIG_OPTION_NOTGPOS --- Frameworks/regexp/src/regexp.cc | 5 ++++- Frameworks/regexp/src/regexp.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Frameworks/regexp/src/regexp.cc b/Frameworks/regexp/src/regexp.cc index 1228dac6..c1a2698d 100644 --- a/Frameworks/regexp/src/regexp.cc +++ b/Frameworks/regexp/src/regexp.cc @@ -111,9 +111,12 @@ namespace regexp { if(ptrn) { + char const* gpos = (options & ONIG_OPTION_NOTGPOS) ? nullptr : (from ?: first); + options &= ~ONIG_OPTION_NOTGPOS; + struct helper_t { static void region_free (OnigRegion* r) { onig_region_free(r, 1); } }; regexp::region_ptr region(onig_region_new(), &helper_t::region_free); - if(ONIG_MISMATCH != onig_search(ptrn.get().get(), (OnigUChar const*)first, (OnigUChar const*)last, (OnigUChar const*)(from ?: first), (OnigUChar const*)(to ?: last), region.get(), options)) + if(ONIG_MISMATCH != onig_search_gpos(ptrn.get().get(), (OnigUChar const*)first, (OnigUChar const*)last, (OnigUChar*)gpos, (OnigUChar const*)(from ?: first), (OnigUChar const*)(to ?: last), region.get(), options)) return match_t(region, ptrn.get(), first); } return match_t(); diff --git a/Frameworks/regexp/src/regexp.h b/Frameworks/regexp/src/regexp.h index 109554e8..b8f097d0 100644 --- a/Frameworks/regexp/src/regexp.h +++ b/Frameworks/regexp/src/regexp.h @@ -4,6 +4,8 @@ #include #include +#define ONIG_OPTION_NOTGPOS (ONIG_OPTION_MAXBIT << 1) + namespace regexp { typedef std::shared_ptr regex_ptr;