ThomasDickey / original-mawk

bug-reports for mawk (originally on GoogleCode)
http://invisible-island.net/mawk/mawk.html
17 stars 2 forks source link

mawk mishandles {2,} in regular expressions #72

Open eggert opened 7 months ago

eggert commented 7 months ago

I found this problem while trying to use mawk to implement tzselect, an awk-using program that's part of tzcode. To reproduce the bug, run this shell command:

mawk 'BEGIN { if ("aaa" ~ /^a{2,}$/) print "ok" }'

This should output "ok" but does not, because the regular expression ^a{2,}$ incorrectly matches only aa.

I found the problem on mawk 1.3.4 20230730 as distributed by Ubuntu 23.10. The problem is still present in mawk 1.3.4 20231126 which I compiled myself.

ThomasDickey commented 7 months ago

thanks - will fix. I understand the problem, but won't get to this for a few weeks (currently improvements to mawk are behind several other programs).

jlp765 commented 6 months ago

mawk 'BEGIN { if ("aaa" ~ /^a{2,5}$/) print "ok" }' fails as well

oguz-ismail commented 4 months ago

This doesn't look right either.

$ echo 'x xx ' | mawk '{sub(/(x+ +){2}/, "y")} 1'
yxx