I have found a bug in nvi source code, you can see my report to nvi2 in
https://github.com/lichray/nvi2/pull/113
I append a patch of OpenBSD source code.
Index: usr.bin/vi/common/search.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/search.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 search.c
--- usr.bin/vi/common/search.c 14 Aug 2016 21:47:16 -0000 1.14
+++ usr.bin/vi/common/search.c 10 Dec 2022 10:02:07 -0000
@@ -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)