From: millert Date: Sat, 10 Dec 2022 16:06:18 +0000 (+0000) Subject: ex_range: fix handling of escaped backslashes. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a64626f4d97a9338d0f4af8649e97dc3870beb0a;p=openbsd 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. --- 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)