Subject: Re: bug in NetBSD and OpenBSD awk
To: None <mason@primenet.com.au>
From: Aleksey Cheusov <cheusov@tut.by>
List: tech-userlevel
Date: 04/30/2006 12:02:27
> Aleksey Cheusov <cheusov@tut.by> typed:
> : NetBSD 3-stable and OpenBSD-3.8 /usr/bin/awk work incorrectly.

> Seems to have problems near the end of the pattern.  The input was 145 chars.
> Taking off the EOL match $ :

> % echo 1_NNIFO 1_PSFR 1_JJFO 1_NNIFO 1_INR 1_NNIMR 1_CC 1_NNING 1_RQ 1_VPLIPF 1_NNIFG 1_JJPG 1_NNIMPG 1_PQINO 1_VPIPN 1_PP3FD 1_JJMA 1_PQMO 1_TC 1_VIIR3 | awk '{ match($0,"^[^_][^ ]*_NNIFO([ ]+[^_]+[^ ]*_(CC|INR|JJFO|JJMA|JJPG|NNIFG|NNIFO|NNIMPG|NNIMR|NNING|PP3FD|PQINO|PQMO|PSFR|RQ|TC|VIIR3|VPIPN|VPLIPF|NOTAG|RQR))*"); print RSTART,RLENGTH }'
> 1 137

> However, putting the last word (1_VIIR3) elsewhere and readding EOL match
> gives the correct answer.

> % echo 1_NNIFO 1_VIIR3 1_PSFR 1_JJFO 1_NNIFO 1_INR 1_NNIMR 1_CC 1_NNING 1_RQ 1_VPLIPF 1_NNIFG 1_JJPG 1_NNIMPG 1_PQINO 1_VPIPN 1_PP3FD 1_JJMA 1_PQMO 1_TC | awk '{ match($0,"^[^_][^ ]*_NNIFO([ ]+[^_]+[^ ]*_(CC|INR|JJFO|JJMA|JJPG|NNIFG|NNIFO|NNIMPG|NNIMR|NNING|PP3FD|PQINO|PQMO|PSFR|RQ|TC|VIIR3|VPIPN|VPLIPF|NOTAG|RQR))*$"); print RSTART,RLENGTH }'
> 1 145
I could not make regexp and input less,
because lots of other simple manipulations lead to to match too.

> This is worth a PR.
done

> Which version of nawk on Solaris?  Current awk on NetBSD is the latest nawk.
/usr/bin/awk at
SunOS solaris 5.9 Generic_112234-10 i86pc i386 i86pc Solaris

-- 
Best regards, Aleksey Cheusov.