Files
coreutils/tests/ptx
Sylvestre Ledru f6539191f1 ptx: fix infinite loop with a nullable --word-regexp
'ptx -W "a*"' would never terminate.  SKIP_SOMETHING advanced the cursor
by the length of the match, which is zero when the word regexp matches
the empty string, and no other value in the surrounding loop conditions
changes.  find_occurs_in_text already skips zero length matches, and a
zero length --context-regexp match is rejected outright; only this macro
lacked the forward progress guarantee.

* src/ptx.c (SKIP_SOMETHING): Advance by at least one byte on a zero
length match, as the other branches of the macro already do.
* tests/ptx/word-regex-loop.sh: New test.
* tests/local.mk (all_tests): Reference it.
* NEWS: Mention the fix.

Link: https://github.com/coreutils/coreutils/pull/328
2026-08-10 22:24:21 +01:00
..