From a64626f4d97a9338d0f4af8649e97dc3870beb0a Mon Sep 17 00:00:00 2001 From: millert Date: Sat, 10 Dec 2022 16:06:18 +0000 Subject: [PATCH] ex_range: fix handling of escaped backslashes. If there are two consecutive backslashes, skip past both so the second is not mistakenly treated as an escape character. This is consistent with how escaped backslashes are treated in ex_substitute() and global(). From Bosco G. G. --- usr.bin/vi/common/search.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/usr.bin/vi/common/search.c b/usr.bin/vi/common/search.c index 03328b740c9..4224e02cfc9 100644 --- a/usr.bin/vi/common/search.c +++ b/usr.bin/vi/common/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.14 2016/08/14 21:47:16 guenther Exp $ */ +/* $OpenBSD: search.c,v 1.15 2022/12/10 16:06:18 millert Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -104,9 +104,14 @@ prev: if (sp->re == NULL) { ++p; break; } - if (plen > 1 && p[0] == '\\' && p[1] == delim) { - ++p; - --plen; + if (plen > 1 && p[0] == '\\') { + if (p[1] == delim) { + ++p; + --plen; + } else if (p[1] == '\\') { + *t++ = *p++; + --plen; + } } } if (epp != NULL) -- 2.20.1