Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit More WIDECHAR elimination (Ingo Schwarze)



details:   https://anonhg.NetBSD.org/src/rev/1772156b433e
branches:  trunk
changeset: 814790:1772156b433e
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 09 18:43:17 2016 +0000

description:
More WIDECHAR elimination (Ingo Schwarze)

diffstat:

 lib/libedit/chared.c   |  18 +++++++++---------
 lib/libedit/chartype.c |  25 ++++++++-----------------
 lib/libedit/chartype.h |  44 +-------------------------------------------
 lib/libedit/common.c   |  13 ++++++-------
 lib/libedit/el.c       |   8 ++++----
 lib/libedit/eln.c      |  12 ++++++------
 lib/libedit/emacs.c    |  22 +++++++++++-----------
 lib/libedit/hist.c     |   6 +++---
 lib/libedit/keymacro.c |  10 +++++-----
 lib/libedit/map.c      |  22 +++++++++++-----------
 lib/libedit/read.c     |  13 ++++++++-----
 lib/libedit/refresh.c  |  18 ++++++++++--------
 lib/libedit/search.c   |   6 +++---
 lib/libedit/terminal.c |  30 +++++++++++++++---------------
 lib/libedit/tty.c      |  16 +++++++++-------
 lib/libedit/vi.c       |  24 ++++++++++++------------
 16 files changed, 121 insertions(+), 166 deletions(-)

diffs (truncated from 1015 to 300 lines):

diff -r af7ead8a4c1f -r 1772156b433e lib/libedit/chared.c
--- a/lib/libedit/chared.c      Sat Apr 09 18:25:26 2016 +0000
+++ b/lib/libedit/chared.c      Sat Apr 09 18:43:17 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chared.c,v 1.49 2016/02/24 14:29:21 christos Exp $     */
+/*     $NetBSD: chared.c,v 1.50 2016/04/09 18:43:17 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)chared.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: chared.c,v 1.49 2016/02/24 14:29:21 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.50 2016/04/09 18:43:17 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -205,7 +205,7 @@
 protected int
 ce__isword(wint_t p)
 {
-       return Isalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL;
+       return iswalnum(p) || Strchr(STR("*?_-.[]~="), p) != NULL;
 }
 
 
@@ -215,9 +215,9 @@
 protected int
 cv__isword(wint_t p)
 {
-       if (Isalnum(p) || p == '_')
+       if (iswalnum(p) || p == L'_')
                return 1;
-       if (Isgraph(p))
+       if (iswgraph(p))
                return 2;
        return 0;
 }
@@ -229,7 +229,7 @@
 protected int
 cv__isWord(wint_t p)
 {
-       return !Isspace(p);
+       return !iswspace(p);
 }
 
 
@@ -292,7 +292,7 @@
                 * trailing whitespace! This is not what 'w' does..
                 */
                if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT))
-                       while ((p < high) && Isspace(*p))
+                       while ((p < high) && iswspace(*p))
                                p++;
        }
 
@@ -314,7 +314,7 @@
 
        p--;
        while (n--) {
-               while ((p > low) && Isspace(*p))
+               while ((p > low) && iswspace(*p))
                        p--;
                test = (*wtest)(*p);
                while ((p >= low) && (*wtest)(*p) == test)
@@ -379,7 +379,7 @@
        p++;
 
        while (n--) {
-               while ((p < high) && Isspace(*p))
+               while ((p < high) && iswspace(*p))
                        p++;
 
                test = (*wtest)(*p);
diff -r af7ead8a4c1f -r 1772156b433e lib/libedit/chartype.c
--- a/lib/libedit/chartype.c    Sat Apr 09 18:25:26 2016 +0000
+++ b/lib/libedit/chartype.c    Sat Apr 09 18:43:17 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.c,v 1.24 2016/03/23 22:27:48 christos Exp $   */
+/*     $NetBSD: chartype.c,v 1.25 2016/04/09 18:43:17 christos Exp $   */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.24 2016/03/23 22:27:48 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.25 2016/04/09 18:43:17 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <ctype.h>
@@ -123,7 +123,7 @@
        if (!s)
                return NULL;
 
-       len = ct_mbstowcs(NULL, s, (size_t)0);
+       len = mbstowcs(NULL, s, (size_t)0);
        if (len == (size_t)-1)
                return NULL;
 
@@ -131,7 +131,7 @@
                if (ct_conv_wbuff_resize(conv, len + CT_BUFSIZ) == -1)
                        return NULL;
 
-       ct_mbstowcs(conv->wbuff, s, conv->wsize);
+       mbstowcs(conv->wbuff, s, conv->wsize);
        return conv->wbuff;
 }
 
@@ -198,24 +198,15 @@
        ssize_t l = 0;
        if (len < ct_enc_width(c))
                return -1;
-       l = ct_wctomb(dst, c);
+       l = wctomb(dst, c);
 
        if (l < 0) {
-               ct_wctomb_reset;
+               wctomb(NULL, L'\0');
                l = 0;
        }
        return l;
 }
 
-size_t
-ct_mbrtowc(wchar_t *wc, const char *s, size_t n)
-{
-       mbstate_t mbs;
-       /* This only works because UTF-8 is stateless */
-       memset(&mbs, 0, sizeof(mbs));
-       return mbrtowc(wc, s, n, &mbs);
-}
-
 protected const Char *
 ct_visual_string(const Char *s)
 {
@@ -344,9 +335,9 @@
                return CHTYPE_TAB;
        else if (c == '\n')
                return CHTYPE_NL;
-       else if (IsASCII(c) && Iscntrl(c))
+       else if (c < 0x100 && iswcntrl(c))
                return CHTYPE_ASCIICTL;
-       else if (Isprint(c))
+       else if (iswprint(c))
                return CHTYPE_PRINT;
        else
                return CHTYPE_NONPRINT;
diff -r af7ead8a4c1f -r 1772156b433e lib/libedit/chartype.h
--- a/lib/libedit/chartype.h    Sat Apr 09 18:25:26 2016 +0000
+++ b/lib/libedit/chartype.h    Sat Apr 09 18:43:17 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.h,v 1.26 2016/03/23 22:27:48 christos Exp $   */
+/*     $NetBSD: chartype.h,v 1.27 2016/04/09 18:43:17 christos Exp $   */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -51,56 +51,19 @@
 #warning Build environment does not support non-BMP characters
 #endif
 
-#define ct_wctob             wctob
-#define ct_wctomb            wctomb
-#define ct_wctomb_reset      wctomb(0,0)
-#define ct_wcstombs          wcstombs
-#define ct_mbstowcs          mbstowcs
-
 #define Char                   wchar_t
 #define FUN(prefix,rest)       prefix ## _w ## rest
 #define FUNW(type)             type ## _w
 #define TYPE(type)             type ## W
-#define FSTR                   "%ls"
-#define FSTARSTR               "%.*ls"
 #define STR(x)                 L ## x
-#define UC(c)                  c
-#define Isalpha(x)  iswalpha(x)
-#define Isalnum(x)  iswalnum(x)
-#define Isgraph(x)  iswgraph(x)
-#define Isspace(x)  iswspace(x)
-#define Isdigit(x)  iswdigit(x)
-#define Iscntrl(x)  iswcntrl(x)
-#define Isprint(x)  iswprint(x)
-
-#define Isupper(x)  iswupper(x)
-#define Islower(x)  iswlower(x)
-#define Toupper(x)  towupper(x)
-#define Tolower(x)  towlower(x)
-
-#define IsASCII(x)  (x < 0x100)
 
 #define Strlen(x)       wcslen(x)
 #define Strchr(s,c)     wcschr(s,c)
-#define Strrchr(s,c)    wcsrchr(s,c)
-#define Strstr(s,v)     wcsstr(s,v)
 #define Strdup(x)       wcsdup(x)
-#define Strcpy(d,s)     wcscpy(d,s)
 #define Strncpy(d,s,n)  wcsncpy(d,s,n)
 #define Strncat(d,s,n)  wcsncat(d,s,n)
-
 #define Strcmp(s,v)     wcscmp(s,v)
 #define Strncmp(s,v,n)  wcsncmp(s,v,n)
-#define Strcspn(s,r)    wcscspn(s,r)
-
-#define Strtol(p,e,b)   wcstol(p,e,b)
-
-static inline int
-Width(wchar_t c)
-{
-       int w = wcwidth(c);
-       return w < 0 ? 0 : w;
-}
 
 #else /* NARROW */
 
@@ -150,8 +113,6 @@
 protected ssize_t ct_encode_char(char *, size_t, Char);
 protected size_t ct_enc_width(Char);
 
-#define ct_free_argv(s)        el_free(s)
-
 #else
 #define        ct_encode_string(s, b)  (s)
 #define ct_decode_string(s, b) (s)
@@ -199,7 +160,4 @@
 protected int ct_chr_class(Char c);
 #endif
 
-size_t ct_mbrtowc(wchar_t *, const char *, size_t);
-
-
 #endif /* _chartype_f */
diff -r af7ead8a4c1f -r 1772156b433e lib/libedit/common.c
--- a/lib/libedit/common.c      Sat Apr 09 18:25:26 2016 +0000
+++ b/lib/libedit/common.c      Sat Apr 09 18:43:17 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.c,v 1.40 2016/03/02 19:24:20 christos Exp $     */
+/*     $NetBSD: common.c,v 1.41 2016/04/09 18:43:17 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)common.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: common.c,v 1.40 2016/03/02 19:24:20 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.41 2016/04/09 18:43:17 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -148,8 +148,7 @@
 #ifdef DEBUG_EDIT
 #define        EL      el->el_line
        (void) fprintf(el->el_errfile,
-           "\nD(b: %p(" FSTR ")  c: %p(" FSTR ") last: %p(" FSTR
-           ") limit: %p(" FSTR ")\n",
+           "\nD(b: %p(%ls)  c: %p(%ls) last: %p(%ls) limit: %p(%ls)\n",
            EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
            EL.lastchar, EL.limit, EL.limit);
 #endif
@@ -242,7 +241,7 @@
 
        if (el->el_map.type == MAP_VI) {
                        /* We want FIRST non space character */
-               while (Isspace(*el->el_line.cursor))
+               while (iswspace(*el->el_line.cursor))
                        el->el_line.cursor++;
                if (el->el_chared.c_vcmd.action != NOP) {
                        cv_delfini(el);
@@ -384,7 +383,7 @@
 ed_digit(EditLine *el, wint_t c)
 {
 
-       if (!Isdigit(c))
+       if (!iswdigit(c))
                return CC_ERROR;
 
        if (el->el_state.doingarg) {
@@ -412,7 +411,7 @@
 ed_argument_digit(EditLine *el, wint_t c)
 {
 
-       if (!Isdigit(c))
+       if (!iswdigit(c))
                return CC_ERROR;
 
        if (el->el_state.doingarg) {
diff -r af7ead8a4c1f -r 1772156b433e lib/libedit/el.c
--- a/lib/libedit/el.c  Sat Apr 09 18:25:26 2016 +0000
+++ b/lib/libedit/el.c  Sat Apr 09 18:43:17 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.c,v 1.84 2016/03/23 22:27:48 christos Exp $ */
+/*     $NetBSD: el.c,v 1.85 2016/04/09 18:43:17 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c       8.2 (Berkeley) 1/3/94";



Home | Main Index | Thread Index | Old Index