Add ONIG_OPTION_NOTGPOS

This commit is contained in:
Allan Odgaard
2013-08-18 16:22:18 +02:00
parent c5a7d32056
commit 1e27f6bf47
2 changed files with 6 additions and 1 deletions

View File

@@ -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();

View File

@@ -4,6 +4,8 @@
#include <Onigmo/oniguruma.h>
#include <oak/debug.h>
#define ONIG_OPTION_NOTGPOS (ONIG_OPTION_MAXBIT << 1)
namespace regexp
{
typedef std::shared_ptr<regex_t> regex_ptr;