NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/52671: The ignorecase option is not handeled correctly in vi for unicode characters



>Number:         52671
>Category:       bin
>Synopsis:       The ignorecase option is not handeled correctly in vi for unicode characters
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 29 15:20:00 +0000 2017
>Originator:     Ralph Geier
>Release:        7.1
>Organization:
>Environment:
NetBSD madeira NetBSD 7.1 (GENERIC.201703111743Z) i386
>Description:
For unicode characters ignorecase seems not to work.                        
>How-To-Repeat:
Open a new file with vi, set the 'ignorecase' option and try to search           
for german 'umlauts', e.g. in:          
        
während Ähren 

>Fix:
The following patch seems to fix it. I did not investigate really
deeply. I replaced some character classification/conversion functions           
by macros which use the multibyte aware versions where necessary, as it         
has been done similarly in the course of the NetBSD 'local changes' for         
the same source file.                   
                    
Note that I had to introduce an ISALPHA2 macro, because the NetBSD              
local changes implement an ISALPHA which is restricted to the ASCII             
character set, and not suitable here.

Index: multibyte.h
===================================================================             
RCS file: /cvsroot/src/external/bsd/nvi/dist/common/multibyte.h,v               
retrieving revision 1.2
diff -u -r1.2 multibyte.h
--- multibyte.h 22 Nov 2013 15:52:05 -0000      1.2
+++ multibyte.h 29 Oct 2017 13:09:49 -0000                                      
@@ -53,6 +53,7 @@   
 #define ISCNTRL                iswcntrl                                        
 #define ISGRAPH                iswgraph
 #define ISLOWER                iswlower                                        
+#define ISALPHA2       iswalpha        
 #define ISPUNCT                iswpunct
 #define ISSPACE                iswspace
 #define ISUPPER                iswupper
@@ -86,6 +87,7 @@
 #define ISCNTRL                iscntrl
 #define ISGRAPH                isgraph
 #define ISLOWER                islower
+#define ISALPHA2       isalpha
 #define ISPUNCT                ispunct
 #define ISSPACE                isspace
 #define ISUPPER                isupper

Index: regcomp.c
===================================================================
RCS file: /cvsroot/src/external/bsd/nvi/dist/regex/regcomp.c,v
retrieving revision 1.5
diff -u -r1.5 regcomp.c
--- regcomp.c   26 Jan 2014 21:47:00 -0000      1.5
+++ regcomp.c   29 Oct 2017 13:10:01 -0000
@@ -752,7 +752,7 @@
                int ci;

                for (i = p->g->csetsize - 1; i >= 0; i--)
-                       if (CHIN(cs, i) && isalpha(i)) {
+                       if (CHIN(cs, i) && ISALPHA2(i)) {
                                ci = othercase(i);
                                if (ci != i)
                                        CHadd(cs, ci);
@@ -860,7 +860,7 @@
        const char *u;
        char c;

-       while (MORE() && isalpha(PEEK()))
+       while (MORE() && ISALPHA2(PEEK()))
                NEXT();
        len = p->next - sp;
        for (cp = cclasses; cp->name != NULL; cp++)
@@ -949,11 +949,11 @@
 static char                    /* if no counterpart, return ch */
 othercase(int ch)
 {
-       assert(isalpha(ch));
-       if (isupper(ch))
-               return(tolower(ch));
-       else if (islower(ch))
-               return(toupper(ch));
+       assert(ISALPHA2(ch));
+       if (ISUPPER(ch))
+               return(TOLOWER(ch));
+       else if (ISLOWER(ch))
+               return(TOUPPER(ch));
        else                    /* peculiar, but could happen */
                return(ch);
 }
@@ -994,7 +994,7 @@
        cat_t *cap = p->g->categories;
 */

-       if ((p->g->cflags&REG_ICASE) && isalpha(ch) && othercase(ch) != ch)
+       if ((p->g->cflags&REG_ICASE) && ISALPHA2(ch) && othercase(ch) != ch)
                bothcases(p, ch);
        else {
                EMIT(OCHAR, (UCHAR_T)ch);



Home | Main Index | Thread Index | Old Index