% sed -n 20,32p /sys/src/cmd/grep/grep.y prog: /* empty */ { yyerror("empty pattern"); } | expr newlines { $$.beg = ral(Tend); $$.end = $$.beg; $$ = re2cat(re2star(re2or(re2char(0x00, '\n'-1), re2char('\n'+1, 0xff))), $$); $$ = re2cat($1, $$); $$ = re2cat(re2star(re2char(0x00, 0xff)), $$); topre = $$; } %
The above code sets up the initial state machine including the pattern passed on the command line, $1. This combined with the fact that multiple "stars" are coalesced causes the weirdness you're seeing. Anthony