Source-Changes-HG archive

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

[src/trunk]: src/dist/nvi Use wide char versions of tolower/toupper/islower/i...



details:   https://anonhg.NetBSD.org/src/rev/debf46de2d48
branches:  trunk
changeset: 750299:debf46de2d48
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Wed Dec 23 12:44:21 2009 +0000

description:
Use wide char versions of tolower/toupper/islower/isupper where
appropriate. Fixes ~ command on big-endian architectures.

diffstat:

 dist/nvi/common/cut.c       |   6 +++---
 dist/nvi/common/cut.h       |   6 +++---
 dist/nvi/common/multibyte.h |   8 +++++++-
 dist/nvi/ex/ex.c            |   6 +++---
 dist/nvi/ex/ex_subst.c      |  12 ++++++------
 dist/nvi/ex/ex_usage.c      |   8 ++++----
 dist/nvi/vi/v_ulcase.c      |  12 ++++++------
 7 files changed, 32 insertions(+), 26 deletions(-)

diffs (193 lines):

diff -r 80d502bd5660 -r debf46de2d48 dist/nvi/common/cut.c
--- a/dist/nvi/common/cut.c     Wed Dec 23 09:54:22 2009 +0000
+++ b/dist/nvi/common/cut.c     Wed Dec 23 12:44:21 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cut.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+/*     $NetBSD: cut.c,v 1.3 2009/12/23 12:44:21 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -103,10 +103,10 @@
                        copy_one = 1;
                        cb_rotate(sp);
                }
-               if ((append = isupper(name)) == 1) {
+               if ((append = ISUPPER(name)) == 1) {
                        if (!copy_one)
                                copy_def = 1;
-                       name = tolower(name);
+                       name = TOLOWER(name);
                }
 namecb:                CBNAME(sp, cbp, name);
        } else if (LF_ISSET(CUT_NUMREQ) || (LF_ISSET(CUT_NUMOPT) &&
diff -r 80d502bd5660 -r debf46de2d48 dist/nvi/common/cut.h
--- a/dist/nvi/common/cut.h     Wed Dec 23 09:54:22 2009 +0000
+++ b/dist/nvi/common/cut.h     Wed Dec 23 12:44:21 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cut.h,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+/*     $NetBSD: cut.h,v 1.3 2009/12/23 12:44:21 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -67,8 +67,8 @@
  */
 #define        CBNAME(sp, cbp, nch) {                                          \
        CHAR_T L__name;                                                 \
-       L__name = isupper((unsigned char)nch) ?                         \
-           tolower((unsigned char)nch) : (nch);                        \
+       L__name = ISUPPER((unsigned char)nch) ?                         \
+           TOLOWER((unsigned char)nch) : (nch);                        \
        for (cbp = sp->wp->cutq.lh_first;                               \
            cbp != NULL; cbp = cbp->q.le_next)                          \
                if (cbp->name == L__name)                               \
diff -r 80d502bd5660 -r debf46de2d48 dist/nvi/common/multibyte.h
--- a/dist/nvi/common/multibyte.h       Wed Dec 23 09:54:22 2009 +0000
+++ b/dist/nvi/common/multibyte.h       Wed Dec 23 12:44:21 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: multibyte.h,v 1.4 2009/08/11 21:28:02 aymeric Exp $ */
+/*     $NetBSD: multibyte.h,v 1.5 2009/12/23 12:44:21 mlelstv Exp $ */
 
 #ifndef MULTIBYTE_H
 #define MULTIBYTE_H
@@ -23,6 +23,9 @@
 #define STRCMP         wcscmp
 #define STRPBRK                wcspbrk
 #define TOUPPER                towupper
+#define TOLOWER                towlower
+#define ISUPPER                iswupper
+#define ISLOWER                iswlower
 #define STRSET         wmemset
 #define STRCHR         wcschr
 
@@ -41,6 +44,9 @@
 #define STRCMP         strcmp
 #define STRPBRK                strpbrk
 #define TOUPPER                toupper
+#define TOLOWER                tolower
+#define ISUPPER                isupper
+#define ISLOWER                islower
 #define STRSET         memset
 #define STRCHR         strchr
 
diff -r 80d502bd5660 -r debf46de2d48 dist/nvi/ex/ex.c
--- a/dist/nvi/ex/ex.c  Wed Dec 23 09:54:22 2009 +0000
+++ b/dist/nvi/ex/ex.c  Wed Dec 23 12:44:21 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ex.c,v 1.5 2009/11/14 23:31:37 christos Exp $ */
+/*     $NetBSD: ex.c,v 1.6 2009/12/23 12:44:22 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -438,7 +438,7 @@
                        break;
                case 'E': case 'F': case 'N': case 'P': case 'T': case 'V':
                        newscreen = 1;
-                       p[0] = tolower(p[0]);
+                       p[0] = TOLOWER(p[0]);
                        break;
                }
 
@@ -486,7 +486,7 @@
                                /* FALLTHROUGH */
                        default:
 unknown:                       if (newscreen)
-                                       p[0] = toupper(p[0]);
+                                       p[0] = TOUPPER(p[0]);
                                ex_unknown(sp, p, namelen);
                                goto err;
                        }
diff -r 80d502bd5660 -r debf46de2d48 dist/nvi/ex/ex_subst.c
--- a/dist/nvi/ex/ex_subst.c    Wed Dec 23 09:54:22 2009 +0000
+++ b/dist/nvi/ex/ex_subst.c    Wed Dec 23 12:44:21 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ex_subst.c,v 1.2 2008/12/05 22:51:42 christos Exp $ */
+/*     $NetBSD: ex_subst.c,v 1.3 2009/12/23 12:44:22 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -912,7 +912,7 @@
        }
        if (LF_ISSET(SEARCH_ICL)) {
 iclower:       for (p = ptrn, len = plen; len > 0; ++p, --len)
-                       if (isupper(*p))
+                       if (ISUPPER(*p))
                                break;
                if (len == 0)
                        reflags |= REG_ICASE;
@@ -1366,15 +1366,15 @@
                        conv = C_NOT_SET;                               \
                        /* FALLTHROUGH */                               \
                case C_LOWER:                                           \
-                       if (isupper(__ch))                              \
-                               __ch = tolower(__ch);                   \
+                       if (ISUPPER(__ch))                              \
+                               __ch = TOLOWER(__ch);                   \
                        break;                                          \
                case C_ONE_UPPER:                                       \
                        conv = C_NOT_SET;                               \
                        /* FALLTHROUGH */                               \
                case C_UPPER:                                           \
-                       if (islower(__ch))                              \
-                               __ch = toupper(__ch);                   \
+                       if (ISLOWER(__ch))                              \
+                               __ch = TOUPPER(__ch);                   \
                        break;                                          \
                default:                                                \
                        abort();                                        \
diff -r 80d502bd5660 -r debf46de2d48 dist/nvi/ex/ex_usage.c
--- a/dist/nvi/ex/ex_usage.c    Wed Dec 23 09:54:22 2009 +0000
+++ b/dist/nvi/ex/ex_usage.c    Wed Dec 23 12:44:21 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ex_usage.c,v 1.3 2009/11/14 23:40:11 christos Exp $ */
+/*     $NetBSD: ex_usage.c,v 1.4 2009/12/23 12:44:22 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -68,9 +68,9 @@
        switch (cmdp->argc) {
        case 1:
                ap = cmdp->argv[0];
-               if (isupper(ap->bp[0])) {
+               if (ISUPPER(ap->bp[0])) {
                        newscreen = 1;
-                       ap->bp[0] = tolower(ap->bp[0]);
+                       ap->bp[0] = TOLOWER(ap->bp[0]);
                } else
                        newscreen = 0;
                for (cp = cmds; cp->name != NULL &&
@@ -81,7 +81,7 @@
                        size_t nlen;
 
                        if (newscreen)
-                               ap->bp[0] = toupper(ap->bp[0]);
+                               ap->bp[0] = TOUPPER(ap->bp[0]);
 
                        INT2CHAR(sp, ap->bp, ap->len + 1, nstr, nlen);
                        (void)ex_printf(sp, "The %.*s command is unknown\n",
diff -r 80d502bd5660 -r debf46de2d48 dist/nvi/vi/v_ulcase.c
--- a/dist/nvi/vi/v_ulcase.c    Wed Dec 23 09:54:22 2009 +0000
+++ b/dist/nvi/vi/v_ulcase.c    Wed Dec 23 12:44:21 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: v_ulcase.c,v 1.1.1.2 2008/05/18 14:31:47 aymeric Exp $ */
+/*     $NetBSD: v_ulcase.c,v 1.2 2009/12/23 12:44:22 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993, 1994
@@ -155,12 +155,12 @@
 
        change = rval = 0;
        for (p = bp + scno, t = bp + ecno + 1; p < t; ++p) {
-               ch = *(u_char *)p;
-               if (islower(ch)) {
-                       *p = toupper(ch);
+               ch = *p;
+               if (ISLOWER(ch)) {
+                       *p = TOUPPER(ch);
                        change = 1;
-               } else if (isupper(ch)) {
-                       *p = tolower(ch);
+               } else if (ISUPPER(ch)) {
+                       *p = TOLOWER(ch);
                        change = 1;
                }
        }



Home | Main Index | Thread Index | Old Index