NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/59766: awk does not handle RS="\0"



The following reply was made to PR bin/59766; it has been noted by GNATS.

From: Christos Zoulas <christos%zoulas.com@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: gnats-admin%netbsd.org@localhost,
 netbsd-bugs%netbsd.org@localhost
Subject: Re: bin/59766: awk does not handle RS="\0"
Date: Sun, 16 Nov 2025 14:34:44 -0500

 --Apple-Mail=_E44D379A-6585-41F5-A115-6471C1A327FB
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii
 
 It is trivial to fix:
 
 Index: lib.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/src/external/historical/nawk/dist/lib.c,v
 retrieving revision 1.16
 diff -u -p -u -r1.16 lib.c
 --- lib.c       18 Aug 2024 16:51:05 -0000      1.16
 +++ lib.c       16 Nov 2025 19:33:24 -0000
 @@ -252,13 +252,7 @@ int readrec(char **pbuf, int *pbufsize,=20
                 isrec =3D found !=3D 0 || *buf !=3D '\0';
 =20
         } else {
 -               if ((sep =3D *rs) =3D=3D 0) {
 -                       sep =3D '\n';
 -                       while ((c=3Dgetc(inf)) =3D=3D '\n' && c !=3D =
 EOF)       /* skip leading \n's */
 -                               ;
 -                       if (c !=3D EOF)
 -                               ungetc(c, inf);
 -               }
 +              sep =3D *rs;
                 for (rr =3D buf; ; ) {
                         for (; (c=3Dgetc(inf)) !=3D sep && c !=3D EOF; ) =
 {
                                 if (rr-buf+1 > bufsize)
 @@ -267,7 +261,7 @@ int readrec(char **pbuf, int *pbufsize,=20
                                                 FATAL("input record =
 `%.30s...' too long", buf);
                                 *rr++ =3D c;
                         }
 -                       if (*rs =3D=3D sep || c =3D=3D EOF)
 +                       if (c =3D=3D EOF)
                                 break;
                         if ((c =3D getc(inf)) =3D=3D '\n' || c =3D=3D =
 EOF)        /* 2 in a row */
                                 break;
 
 
 The question is why special-case it this way? gawk does not do this.
 
 christos
 
 
 --Apple-Mail=_E44D379A-6585-41F5-A115-6471C1A327FB
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
 	filename=signature.asc
 Content-Type: application/pgp-signature;
 	name=signature.asc
 Content-Description: Message signed with OpenPGP
 
 -----BEGIN PGP SIGNATURE-----
 Comment: GPGTools - http://gpgtools.org
 
 iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCaRonVAAKCRBxESqxbLM7
 OiYcAJ9AXgX3zERCjBRvwK/yrlnauTZsFgCfei6pvUIs7wAG0icV8i+k+CwLvUA=
 =3Rsn
 -----END PGP SIGNATURE-----
 
 --Apple-Mail=_E44D379A-6585-41F5-A115-6471C1A327FB--
 


Home | Main Index | Thread Index | Old Index