Package: nvi
Version: 1.81.6-13
Severity: important
Tags: patch upstream

In nvi, it's impossible to search for a string containing any unicode char
whose code point is > 0xff.

[working under an utf-8 locale]
$ cat /tmp/a.txt
tată    tata
țață    țața
țâță    țâța
$ nvi /tmp/a.txt
        ... displays the file correctly
[inside nvi]
Pattern not found
Pattern not found
No match found

And ':set extended' won't fix it, either.

[without the proper keyboard support, you can enter those characters
by copy-pasting them from this message]

This seems to have been always broken, but the "fix" for #523934
(14private_regex_fixes.patch) only made it worse.

The following patch fixes the search issue, and does not bring back
the "potential overflow" mentioned in the comment. Notice that the
'-' operator has precedence over '&'.

diff --git a/regex/regcomp.c b/regex/regcomp.c
index 12ee513..095ab7a 100644
--- a/regex/regcomp.c
+++ b/regex/regcomp.c
@@ -300,7 +300,7 @@ p_ere(register struct parse *p, int stop)
                                /* character this ERE should end at */
-       register char c;
+       register int c;
        register sopno prevback;
        register sopno prevfwd;
        register sopno conc;
@@ -344,7 +344,7 @@ p_ere(register struct parse *p, int stop)
 static void
 p_ere_exp(register struct parse *p)
-       register char c;
+       register int c;
        register sopno pos;
        register int count;
        register int count2;
@@ -624,7 +624,7 @@ p_simp_re(register struct parse *p, int starordinary)
                /* FALLTHROUGH */
          /* ordinary(p, c &~ BACKSL); -- Fix potential overflow */
-               ordinary(p, c & 0xff);
+               ordinary(p, c & BACKSL - 1);

Reply via email to