Skip to content

grep: warn on leading ERE repeat operators#48

Open
wondr-wclabs wants to merge 1 commit into
uutils:mainfrom
wondr-wclabs:codex/ere-leading-repeat-warnings
Open

grep: warn on leading ERE repeat operators#48
wondr-wclabs wants to merge 1 commit into
uutils:mainfrom
wondr-wclabs:codex/ere-leading-repeat-warnings

Conversation

@wondr-wclabs
Copy link
Copy Markdown
Contributor

Closes #23.

GNU grep accepts leading ERE repeat operators as a warning case rather than a hard regex compile error. The operator is effectively ignored, so a pattern like ? or {2} becomes an empty match and still selects the input line.

This keeps the compatibility change deliberately narrow: instead of disabling Oniguruma’s invalid-repeat handling globally, it detects only the leading ERE repeat forms described in the issue, emits the GNU-style warning, and compiles the remaining pattern normally. That preserves existing BRE behavior such as treating *foo as a literal basic-regexp pattern, and it avoids changing unrelated independent-repeat cases in the regex engine.

The regression test covers ?, *, +, {2}, and {,2} in ERE mode, plus a BRE *foo control case.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 5, 2026

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 17 skipped benchmarks1


Comparing wondr-wclabs:codex/ere-leading-repeat-warnings (0f16075) with main (e925ff4)

Open in CodSpeed

Footnotes

  1. 17 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@wondr-wclabs wondr-wclabs force-pushed the codex/ere-leading-repeat-warnings branch from 21cf159 to 261a0bc Compare June 5, 2026 08:37
@wondr-wclabs wondr-wclabs force-pushed the codex/ere-leading-repeat-warnings branch from 261a0bc to 0f16075 Compare June 5, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rejects a leading quantifier (?/*/+) that GNU accepts with a warning

1 participant