On 2023/06/22 13:18:43 -0600, Todd C. Miller <mill...@openbsd.org> wrote: > On Tue, 07 Feb 2023 20:35:10 -0700, Todd C. Miller wrote: > > > On Tue, 07 Feb 2023 17:17:02 -0700, Todd C. Miller wrote: > > > > > Yes, the bug is that the number is not displayed. The following > > > diff fixes that but there is still a bug because the resulting line > > > also lacks a line number. In other words, instead of: > > > > > > :s/men/MEN/c > > > 1 Five women came to the party. > > > ^^^[ynq]y > > > Five woMEN came to the party. > > > > > > it should look like this: > > > > > > :s/men/MEN/c > > > 1 Five women came to the party. > > > ^^^[ynq]y > > > 1 Five woMEN came to the party. > > > > Here's an updated diff that prints line numbers when autoprint is > > set too. This seems to match historic ex behavior and POSIX, but > > I'd appreciate other eyes on it. > > Moving this from busg@ to tech@. I noticed today I still have this > diff from Feb rotting in my tree. The original thread is: > https://marc.info/?l=openbsd-bugs&m=167580085421828&w=2 > > OK?
not really using ex, but the diff reads fine and fixes the issue. ok op@ (midly surprised by LF_INIT, wich is just a long way to set a local variable :/) > Index: usr.bin/vi/ex/ex.c > =================================================================== > RCS file: /cvs/src/usr.bin/vi/ex/ex.c,v > retrieving revision 1.22 > diff -u -p -u -r1.22 ex.c > --- usr.bin/vi/ex/ex.c 20 Feb 2022 19:45:51 -0000 1.22 > +++ usr.bin/vi/ex/ex.c 8 Feb 2023 03:28:32 -0000 > @@ -1454,8 +1454,14 @@ addr_verify: > LF_INIT(FL_ISSET(ecp->iflags, E_C_HASH | E_C_LIST | E_C_PRINT)); > if (!LF_ISSET(E_C_HASH | E_C_LIST | E_C_PRINT | E_NOAUTO) && > !F_ISSET(sp, SC_EX_GLOBAL) && > - O_ISSET(sp, O_AUTOPRINT) && F_ISSET(ecp, E_AUTOPRINT)) > - LF_INIT(E_C_PRINT); > + O_ISSET(sp, O_AUTOPRINT) && F_ISSET(ecp, E_AUTOPRINT)) { > + > + /* Honor the number option if autoprint is set. */ > + if (F_ISSET(ecp, E_OPTNUM)) > + LF_INIT(E_C_HASH); > + else > + LF_INIT(E_C_PRINT); > + } > > if (LF_ISSET(E_C_HASH | E_C_LIST | E_C_PRINT)) { > cur.lno = sp->lno; > Index: usr.bin/vi/ex/ex_subst.c > =================================================================== > RCS file: /cvs/src/usr.bin/vi/ex/ex_subst.c,v > retrieving revision 1.30 > diff -u -p -u -r1.30 ex_subst.c > --- usr.bin/vi/ex/ex_subst.c 18 Apr 2017 01:45:35 -0000 1.30 > +++ usr.bin/vi/ex/ex_subst.c 8 Feb 2023 03:23:27 -0000 > @@ -633,7 +633,9 @@ nextmatch: match[0].rm_so = offset; > goto lquit; > } > } else { > - if (ex_print(sp, cmdp, &from, &to, 0) || > + const int flags = > + O_ISSET(sp, O_NUMBER) ? E_C_HASH : 0; > + if (ex_print(sp, cmdp, &from, &to, flags) || > ex_scprint(sp, &from, &to)) > goto lquit; > if (ex_txt(sp, &tiq, 0, TXT_CR))