From: millert Date: Fri, 23 Jun 2023 15:06:45 +0000 (+0000) Subject: Fix a bug in ex's 's' command with the 'c' flag when 'number' is off. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=80ddc267446596956ab5c3c464f5369de59a72c6;p=openbsd Fix a bug in ex's 's' command with the 'c' flag when 'number' is off. The underlining was positioned in the wrong place. This fixes the problem and matches historic ex behavior. OK op@ --- diff --git a/usr.bin/vi/ex/ex.c b/usr.bin/vi/ex/ex.c index 357aa860728..9aa31ad29fb 100644 --- a/usr.bin/vi/ex/ex.c +++ b/usr.bin/vi/ex/ex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex.c,v 1.22 2022/02/20 19:45:51 tb Exp $ */ +/* $OpenBSD: ex.c,v 1.23 2023/06/23 15:06:45 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -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; diff --git a/usr.bin/vi/ex/ex_subst.c b/usr.bin/vi/ex/ex_subst.c index 64afb91e6a7..e58bf1eb711 100644 --- a/usr.bin/vi/ex/ex_subst.c +++ b/usr.bin/vi/ex/ex_subst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ex_subst.c,v 1.30 2017/04/18 01:45:35 deraadt Exp $ */ +/* $OpenBSD: ex_subst.c,v 1.31 2023/06/23 15:06:45 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -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))