Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about the \G anchor and onig_search_gpos #53

Closed
dahakawang opened this issue Aug 11, 2015 · 1 comment
Closed

question about the \G anchor and onig_search_gpos #53

dahakawang opened this issue Aug 11, 2015 · 1 comment
Labels

Comments

@dahakawang
Copy link

hi,

let's say we have a regex /\Gabc/ and target string is "123abcdef", if we set gpos at offset 3 in the target string, then the regex is supposed to match "abc" in the target string, right?

can someone please advise why below code not work as my expected?

    UChar* pattern = (UChar*) "\\Gabc";
    UChar* pattern_end = (UChar*) (pattern + strlen(pattern));
    OnigErrorInfo oni_error;
    regex_t* regex;
    int code = onig_new(&regex, pattern, pattern_end, ONIG_OPTION_CAPTURE_GROUP, ONIG_ENCODING_UTF8, ONIG_SYNTAX_DEFAULT,&oni_error);
    if (code != ONIG_NORMAL) printf("error create regex\n");

    UChar* str = (UChar*)"123abcdef";
    UChar* end = str + strlen(str);
    UChar* gpos = str + 3;
    UChar* start = str;
    OnigRegion* region = onig_region_new();
    code = onig_search_gpos(regex, str, end, gpos, start, end, region, ONIG_OPTION_NONE);
    if (code == ONIG_MISMATCH) {
        printf("can't match\n");   // output this, why???
    }else {
        printf("matched\n");
    }
@k-takata k-takata added the bug label Nov 17, 2016
k-takata added a commit that referenced this issue Nov 17, 2016
Also add missing debug log for Sunday's quick search.
@k-takata
Copy link
Owner

Sorry for the very late response.
This was a bug, and I committed the fix to devel-6.0 branch.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants