Hi, Sevan Janiyan wrote on Mon, Jun 27, 2016 at 02:02:26AM +0100:
> The attached patch amends bin/cat/cat.c so the output is the same aside > from blank lines being numbered or unnumbered, depending on whether cat > was invoked with -ne or -be. > > At present, when cat is invoked with -be, there is an aditional > difference that the '$' on blank lines is placed on the far left of the > script. > > The patch originates from r1.17 of bin/cat/cat.c from NetBSD. > > Following from that there is the addition of a regress test to check for > this issue. > > The regress changes also includes a test previously mentioned here[1] > for the fix applied in r1.13 of OpenBSD bin/cat/cat.c. > > [1] http://marc.info/?l=openbsd-tech&m=146665028627169&w=2 This all makes sense to me. The -ben options are all POSIX extensions. Consequently, POSIX doesn't forbid this. If anybody provides an OK, i'll commit. Alternatively, feel free to commit with OK schwarze@. Yours, Ingo > Index: cat.c > =================================================================== > RCS file: /cvs/src/bin/cat/cat.c,v > retrieving revision 1.24 > diff -u -p -u -r1.24 cat.c > --- bin/cat/cat.c 4 Nov 2015 21:28:01 -0000 1.24 > +++ bin/cat/cat.c 27 Jun 2016 00:27:47 -0000 > @@ -153,10 +153,16 @@ cook_buf(FILE *fp) > } else > gobble = 0; > } > - if (nflag && (!bflag || ch != '\n')) { > - (void)fprintf(stdout, "%6d\t", ++line); > - if (ferror(stdout)) > - break; > + if (nflag) { > + if (!bflag || ch != '\n') { > + (void)fprintf(stdout, "%6d\t", ++line); > + if (ferror(stdout)) > + break; > + } else if (eflag) { > + (void)fprintf(stdout, "%6s\t", ""); > + if (ferror(stdout)) > + break; > + } > } > } > if (ch == '\n') { > Index: regress/bin/Makefile > =================================================================== > RCS file: /cvs/src/regress/bin/Makefile,v > retrieving revision 1.9 > diff -u -p -u -r1.9 Makefile > --- regress/bin/Makefile 15 Jun 2015 09:25:22 -0000 1.9 > +++ regress/bin/Makefile 27 Jun 2016 00:37:19 -0000 > @@ -1,6 +1,6 @@ > # $OpenBSD: Makefile,v 1.9 2015/06/15 09:25:22 florian Exp $ > > -SUBDIR+= chmod ksh ln md5 pax ps systrace test > +SUBDIR+= cat chmod ksh ln md5 pax ps systrace test > > install: > > Index: regress/bin/cat/Makefile > =================================================================== > RCS file: regress/bin/cat/Makefile > diff -N regress/bin/cat/Makefile > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ regress/bin/cat/Makefile 27 Jun 2016 00:37:19 -0000 > @@ -0,0 +1,11 @@ > +# $OpenBSD$ > + > +REGRESS_TARGETS=cat_be cat_se > + > +cat_be: > + cat -be ${.CURDIR}/cat_be.in | cmp -s ${.CURDIR}/cat_be.out /dev/stdin > + > +cat_se: > + cat -se ${.CURDIR}/cat_se.in | cmp -s ${.CURDIR}/cat_se.out /dev/stdin > + > +.include <bsd.regress.mk> > Index: regress/bin/cat/cat_be.in > =================================================================== > RCS file: regress/bin/cat/cat_be.in > diff -N regress/bin/cat/cat_be.in > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ regress/bin/cat/cat_be.in 27 Jun 2016 00:37:19 -0000 > @@ -0,0 +1,5 @@ > +free, > + > +functional > + > +and secure > Index: regress/bin/cat/cat_be.out > =================================================================== > RCS file: regress/bin/cat/cat_be.out > diff -N regress/bin/cat/cat_be.out > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ regress/bin/cat/cat_be.out 27 Jun 2016 00:37:19 -0000 > @@ -0,0 +1,5 @@ > + 1 free,$ > + $ > + 2 functional$ > + $ > + 3 and secure$ > Index: regress/bin/cat/cat_se.in > =================================================================== > RCS file: regress/bin/cat/cat_se.in > diff -N regress/bin/cat/cat_se.in > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ regress/bin/cat/cat_se.in 27 Jun 2016 00:37:19 -0000 > @@ -0,0 +1,3 @@ > + > +Free, functional and secure > + > Index: regress/bin/cat/cat_se.out > =================================================================== > RCS file: regress/bin/cat/cat_se.out > diff -N regress/bin/cat/cat_se.out > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ regress/bin/cat/cat_se.out 27 Jun 2016 00:37:19 -0000 > @@ -0,0 +1,3 @@ > +$ > +Free, functional and secure$ > +$
