ThomasDickey / original-mawk

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

Regular expression doesn't match string when using MAWK #65

Closed augustkst closed 1 year ago

augustkst commented 2 years ago

I have defined a regular expression which matches a list of words separated by one or more spaces where one of the words is followed by an asterisk. For a list with only one word the expression doesn't match when I use mawk but it matches when I use gawk or nawk:

$ echo 'a*' | mawk '/([a-z]+ *)*[a-z]+ *[*]( *[a-z]+)*/'
$ echo 'a*' | gawk '/([a-z]+ *)*[a-z]+ *[*]( *[a-z]+)*/'
a*
$ echo 'a*' | nawk '/([a-z]+ *)*[a-z]+ *[*]( *[a-z]+)*/'
a*

If the word with the asterisk is followed by one or more words then the regular expression matches also when using mawk:

$ echo 'a* b' | mawk '/([a-z]+ *)*[a-z]+ *[*]( *[a-z]+)*/'
a* b

I use Debian 11 (stable) where mawk is the default implementation of AWK.

$ mawk -W version
mawk 1.3.4 20200120
Copyright 2008-2019,2020, Thomas E. Dickey
Copyright 1991-1996,2014, Michael D. Brennan

random-funcs:       srandom/random
regex-funcs:        internal
compiled limits:
sprintf buffer      8192
maximum-integer     2147483647
ThomasDickey commented 2 years ago

Offhand, perhaps a bug introduced while fixing one of the unbounded results cases.

ThomasDickey commented 1 year ago

Fixed in 20230716:

+ amend/limit special case optimization for redundant wildwards
          (Original-Mawk #36).