[comp.unix.shell] nawk Bug?

khoa@hpindwa.cup.hp.com (Khoa Ton) (05/14/91)

I found what seems to be a bug in nawk.  The built-in function match (a, b)
is supposed to find regular expression b in string a and return 1 if found
else 0, according to the man page.  Match () does not work.

Any help or information would be greatly appreciated.

Khoa Ton

$ what $(which nawk)
/usr/bin/nawk:
         $Revision: 64.13.1.1 $

Following are the bug.* files for the command:
$ nawk -f bug.awk bug.in > bug.out

::::::::::::::
bug.awk
::::::::::::::
{
        hit= match ($0, "junk");
        print $0;
        printf ("Hit:%d\tRSTART:%d\tRLENGTH:%d\n", hit, RSTART, RLENGTH);
}
::::::::::::::
bug.in
::::::::::::::
line 1
line 2
line 3
line junk
line 5
line 6
::::::::::::::
bug.out
::::::::::::::
line 1
Hit:-166200     RSTART:-166200  RLENGTH:0
line 2
Hit:-166200     RSTART:-166200  RLENGTH:0
line 3
Hit:-166200     RSTART:-166200  RLENGTH:0
line junk
Hit:1   RSTART:1        RLENGTH:4
line 5
Hit:1   RSTART:1        RLENGTH:4
line 6
Hit:1   RSTART:1        RLENGTH:4

-------------------------------------------------------------------------------
Khoa Ton                                                khoa@hpindno.hp.cup.com
Hewlett-Packard Co.
Cupertino, CA
(408)447-3362
-------------------------------------------------------------------------------

khoa@hpindwa.cup.hp.com (Khoa Ton) (05/16/91)

I just updated to a new version of nawk and all is well.

$ what `which nawk`
/usr/local/bin/nawk:
	AT&T Unix System Toolchest (December 1 1987), HP-UX $Revision: 1.1 $


Thanks for your help!

Khoa

-------------------------------------------------------------------------------
Khoa Ton                                                khoa@hpindno.hp.cup.com
Hewlett-Packard Co.
Cupertino, CA
(408)447-3362
-------------------------------------------------------------------------------