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

ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS not working for ^* pattern #292

Closed
sargas opened this issue Apr 1, 2024 · 1 comment
Closed

ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS not working for ^* pattern #292

sargas opened this issue Apr 1, 2024 · 1 comment
Labels

Comments

@sargas
Copy link

sargas commented Apr 1, 2024

docs/SYNTAX.md has this to say about ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS:

ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS (independent ?, *, +, {n,m})

Set in: Oniguruma, PosixExtended, GnuRegex, Java, Perl, Perl_NG, Ruby

This flag specifies how to handle operators like ? and * when they aren't
directly attached to an operand, as in ^* or (*): Are they an error, are
they discarded, or are they taken as literals? If this flag is clear, they
are taken as literals; otherwise, the ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS flag
determines if they are errors or if they are discarded.

Since this flag isn't set for "grep", I used the sample.c example changing the syntax to ONIG_SYNTAX_GREP and the str to (UChar* )"*zzzzaffffffffb" (note the initial asterisk).

For a pattern of * or \\(*\\), the first character matches (as expected).
For a pattern of ^*, I get "ERROR: target of repeat operator is invalid", despite this being exactly the example regular expression in the documentation saying the asterisk should be treated as a literal.

@kkos kkos closed this as completed in 23dfc82 Apr 1, 2024
kkos added a commit that referenced this issue Apr 1, 2024
@kkos kkos added the bug label Apr 1, 2024
@sargas
Copy link
Author

sargas commented Apr 1, 2024

Thanks for the fast response!

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