Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit Get split el_getc and el_wgetc completely and ca...



details:   https://anonhg.NetBSD.org/src/rev/cc35a3ad60fe
branches:  trunk
changeset: 813878:cc35a3ad60fe
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Feb 24 14:25:38 2016 +0000

description:
Get split el_getc and el_wgetc completely and call el_wgetc internally.
Change some character constants to they wide versions. (Ingo Schwarze)

diffstat:

 lib/libedit/Makefile   |   5 ++---
 lib/libedit/chared.c   |  17 +++++++++--------
 lib/libedit/chartype.c |   7 ++++---
 lib/libedit/common.c   |   8 +++-----
 lib/libedit/eln.c      |   6 ++++--
 lib/libedit/keymacro.c |   8 +++++---
 lib/libedit/read.c     |  20 ++++++++++++--------
 lib/libedit/search.c   |  19 ++++++++++---------
 8 files changed, 49 insertions(+), 41 deletions(-)

diffs (truncated from 360 to 300 lines):

diff -r 34ed4e0d1ff6 -r cc35a3ad60fe lib/libedit/Makefile
--- a/lib/libedit/Makefile      Wed Feb 24 13:31:54 2016 +0000
+++ b/lib/libedit/Makefile      Wed Feb 24 14:25:38 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.54 2016/02/17 19:47:49 christos Exp $
+#      $NetBSD: Makefile,v 1.55 2016/02/24 14:25:38 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/4/93
 
 USE_SHLIBDIR=  yes
@@ -15,7 +15,7 @@
 CWARNFLAGS.gcc+=       -Wconversion
 CWARNFLAGS.clang+=     -Wno-cast-qual
 
-OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
+OSRCS= chared.c common.c el.c eln.c emacs.c fcns.c filecomplete.c help.c \
        hist.c keymacro.c map.c chartype.c \
        parse.c prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c
 
@@ -37,7 +37,6 @@
 SRCS=  editline.c readline.c tokenizer.c history.c
 
 .if ${WIDECHAR} == "yes"
-OSRCS += eln.c
 SRCS += tokenizern.c historyn.c
 CLEANFILES+=tokenizern.c.tmp tokenizern.c historyn.c.tmp historyn.c
 CPPFLAGS+=-DWIDECHAR
diff -r 34ed4e0d1ff6 -r cc35a3ad60fe lib/libedit/chared.c
--- a/lib/libedit/chared.c      Wed Feb 24 13:31:54 2016 +0000
+++ b/lib/libedit/chared.c      Wed Feb 24 14:25:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chared.c,v 1.47 2016/02/17 19:47:49 christos Exp $     */
+/*     $NetBSD: chared.c,v 1.48 2016/02/24 14:25:38 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.47 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.48 2016/02/24 14:25:38 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -675,9 +675,9 @@
 protected int
 c_gets(EditLine *el, Char *buf, const Char *prompt)
 {
-       Char ch;
+       wchar_t wch;
        ssize_t len;
-       Char *cp = el->el_line.buffer;
+       Char *cp = el->el_line.buffer, ch;
 
        if (prompt) {
                len = (ssize_t)Strlen(prompt);
@@ -692,15 +692,16 @@
                el->el_line.lastchar = cp + 1;
                re_refresh(el);
 
-               if (FUN(el,getc)(el, &ch) != 1) {
+               if (el_wgetc(el, &wch) != 1) {
                        ed_end_of_file(el, 0);
                        len = -1;
                        break;
                }
+               ch = (Char)wch;
 
                switch (ch) {
 
-               case 0010:      /* Delete and backspace */
+               case L'\b':     /* Delete and backspace */
                case 0177:
                        if (len == 0) {
                                len = -1;
@@ -710,8 +711,8 @@
                        continue;
 
                case 0033:      /* ESC */
-               case '\r':      /* Newline */
-               case '\n':
+               case L'\r':     /* Newline */
+               case L'\n':
                        buf[len] = ch;
                        break;
 
diff -r 34ed4e0d1ff6 -r cc35a3ad60fe lib/libedit/chartype.c
--- a/lib/libedit/chartype.c    Wed Feb 24 13:31:54 2016 +0000
+++ b/lib/libedit/chartype.c    Wed Feb 24 14:25:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.c,v 1.19 2016/02/17 19:47:49 christos Exp $   */
+/*     $NetBSD: chartype.c,v 1.20 2016/02/24 14:25:38 christos Exp $   */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.19 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.20 2016/02/24 14:25:38 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <ctype.h>
@@ -218,8 +218,9 @@
 #else
 
 size_t
+/*ARGSUSED*/
 ct_mbrtowc(char *wc, const char *s, size_t n,
-    void *mbs __attribute((__unused__))) {
+    void *mbs __attribute__((__unused__))) {
        if (s == NULL)
                return 0;
        if (n == 0)
diff -r 34ed4e0d1ff6 -r cc35a3ad60fe lib/libedit/common.c
--- a/lib/libedit/common.c      Wed Feb 24 13:31:54 2016 +0000
+++ b/lib/libedit/common.c      Wed Feb 24 14:25:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.c,v 1.38 2016/02/17 19:47:49 christos Exp $     */
+/*     $NetBSD: common.c,v 1.39 2016/02/24 14:25:38 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.38 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.39 2016/02/24 14:25:38 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -365,11 +365,9 @@
 ed_quoted_insert(EditLine *el, wint_t c)
 {
        int num;
-       Char tc;
 
        tty_quotemode(el);
-       num = FUN(el,getc)(el, &tc);
-       c = tc;
+       num = el_wgetc(el, &c);
        tty_noquotemode(el);
        if (num == 1)
                return ed_insert(el, c);
diff -r 34ed4e0d1ff6 -r cc35a3ad60fe lib/libedit/eln.c
--- a/lib/libedit/eln.c Wed Feb 24 13:31:54 2016 +0000
+++ b/lib/libedit/eln.c Wed Feb 24 14:25:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eln.c,v 1.25 2016/02/16 15:53:48 christos Exp $        */
+/*     $NetBSD: eln.c,v 1.26 2016/02/24 14:25:38 christos Exp $        */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.25 2016/02/16 15:53:48 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.26 2016/02/24 14:25:38 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <errno.h>
@@ -65,6 +65,7 @@
 }
 
 
+#ifdef WIDECHAR
 public void
 el_push(EditLine *el, const char *str)
 {
@@ -398,3 +399,4 @@
 {
        return el_winsertstr(el, ct_decode_string(str, &el->el_lgcyconv));
 }
+#endif /* WIDECHAR */
diff -r 34ed4e0d1ff6 -r cc35a3ad60fe lib/libedit/keymacro.c
--- a/lib/libedit/keymacro.c    Wed Feb 24 13:31:54 2016 +0000
+++ b/lib/libedit/keymacro.c    Wed Feb 24 14:25:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: keymacro.c,v 1.13 2016/02/17 19:47:49 christos Exp $   */
+/*     $NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $   */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)key.c      8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: keymacro.c,v 1.13 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: keymacro.c,v 1.14 2016/02/24 14:25:38 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -280,16 +280,18 @@
 private int
 node_trav(EditLine *el, keymacro_node_t *ptr, Char *ch, keymacro_value_t *val)
 {
+       wchar_t wc;
 
        if (ptr->ch == *ch) {
                /* match found */
                if (ptr->next) {
                        /* key not complete so get next char */
-                       if (FUN(el,getc)(el, ch) != 1) {/* if EOF or error */
+                       if (el_wgetc(el, &wc) != 1) {/* if EOF or error */
                                val->cmd = ED_END_OF_FILE;
                                return XK_CMD;
                                /* PWP: Pretend we just read an end-of-file */
                        }
+                       *ch = (Char)wc;
                        return node_trav(el, ptr->next, ch, val);
                } else {
                        *val = ptr->val;
diff -r 34ed4e0d1ff6 -r cc35a3ad60fe lib/libedit/read.c
--- a/lib/libedit/read.c        Wed Feb 24 13:31:54 2016 +0000
+++ b/lib/libedit/read.c        Wed Feb 24 14:25:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: read.c,v 1.82 2016/02/17 19:47:49 christos Exp $       */
+/*     $NetBSD: read.c,v 1.83 2016/02/24 14:25:38 christos Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)read.c     8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: read.c,v 1.82 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.83 2016/02/24 14:25:38 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -244,14 +244,16 @@
 {
        static const Char meta = (Char)0x80;
        el_action_t cmd;
+       wchar_t wc;
        int num;
 
        el->el_errno = 0;
        do {
-               if ((num = FUN(el,getc)(el, ch)) != 1) {/* if EOF or error */
+               if ((num = el_wgetc(el, &wc)) != 1) {/* if EOF or error */
                        el->el_errno = num == 0 ? 0 : errno;
                        return 0;       /* not OKCMD */
                }
+               *ch = (Char)wc;
 
 #ifdef KANJI
                if ((*ch & meta)) {
@@ -397,14 +399,15 @@
        ma->offset = 0;
 }
 
-/* el_getc():
- *     Read a character
+/* el_wgetc():
+ *     Read a wide character
  */
 public int
-FUN(el,getc)(EditLine *el, Char *cp)
+el_wgetc(EditLine *el, wchar_t *cp)
 {
        int num_read;
        c_macro_t *ma = &el->el_chared.c_macro;
+       Char cp_temp;
 
        terminal__flush(el);
        for (;;) {
@@ -440,15 +443,16 @@
 #ifdef DEBUG_READ
        (void) fprintf(el->el_errfile, "Reading a character\n");
 #endif /* DEBUG_READ */
-       num_read = (*el->el_read.read_char)(el, cp);
+       num_read = (*el->el_read.read_char)(el, &cp_temp);
        if (num_read < 0)
                el->el_errno = errno;
+       *cp = cp_temp;
 #ifdef WIDECHAR
        if (el->el_flags & NARROW_READ)
                *cp = *(char *)(void *)cp;
 #endif
 #ifdef DEBUG_READ
-       (void) fprintf(el->el_errfile, "Got it %c\n", *cp);
+       (void) fprintf(el->el_errfile, "Got it %lc\n", *cp);
 #endif /* DEBUG_READ */
        return num_read;
 }
diff -r 34ed4e0d1ff6 -r cc35a3ad60fe lib/libedit/search.c
--- a/lib/libedit/search.c      Wed Feb 24 13:31:54 2016 +0000
+++ b/lib/libedit/search.c      Wed Feb 24 14:25:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: search.c,v 1.38 2016/02/16 22:53:14 christos Exp $     */
+/*     $NetBSD: search.c,v 1.39 2016/02/24 14:25:38 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0



Home | Main Index | Thread Index | Old Index