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.

Example:
=============================================
[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]
/ț<enter>
Pattern not found
/ă<enter>
Pattern not found
s/ă/A/g
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 */
        default:
          /* ordinary(p, c &~ BACKSL); -- Fix potential overflow */
-               ordinary(p, c & 0xff);
+               ordinary(p, c & BACKSL - 1);
                break;
        }
 

Reply via email to