Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit Make the read_char function always take a wchar_...



details:   https://anonhg.NetBSD.org/src/rev/72da5975ef37
branches:  trunk
changeset: 813888:72da5975ef37
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Feb 24 17:13:22 2016 +0000

description:
Make the read_char function always take a wchar_t * argument (Ingo Schwarze)

diffstat:

 lib/libedit/chartype.c |   6 +++---
 lib/libedit/chartype.h |   4 ++--
 lib/libedit/el.c       |   5 ++---
 lib/libedit/el.h       |   3 +--
 lib/libedit/eln.c      |   7 ++-----
 lib/libedit/read.c     |  29 +++++++++++++----------------
 lib/libedit/read.h     |   4 ++--
 lib/libedit/readline.c |  25 ++++++++++++++-----------
 8 files changed, 39 insertions(+), 44 deletions(-)

diffs (truncated from 357 to 300 lines):

diff -r e797c89f77f0 -r 72da5975ef37 lib/libedit/chartype.c
--- a/lib/libedit/chartype.c    Wed Feb 24 16:06:20 2016 +0000
+++ b/lib/libedit/chartype.c    Wed Feb 24 17:13:22 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.c,v 1.20 2016/02/24 14:25:38 christos Exp $   */
+/*     $NetBSD: chartype.c,v 1.21 2016/02/24 17:13:22 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.20 2016/02/24 14:25:38 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.21 2016/02/24 17:13:22 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <ctype.h>
@@ -219,7 +219,7 @@
 
 size_t
 /*ARGSUSED*/
-ct_mbrtowc(char *wc, const char *s, size_t n,
+ct_mbrtowc(wchar_t *wc, const char *s, size_t n,
     void *mbs __attribute__((__unused__))) {
        if (s == NULL)
                return 0;
diff -r e797c89f77f0 -r 72da5975ef37 lib/libedit/chartype.h
--- a/lib/libedit/chartype.h    Wed Feb 24 16:06:20 2016 +0000
+++ b/lib/libedit/chartype.h    Wed Feb 24 17:13:22 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chartype.h,v 1.21 2016/02/17 19:47:49 christos Exp $   */
+/*     $NetBSD: chartype.h,v 1.22 2016/02/24 17:13:22 christos Exp $   */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -113,7 +113,7 @@
 
 #else /* NARROW */
 
-size_t ct_mbrtowc(char *, const char *, size_t, void *);
+size_t ct_mbrtowc(wchar_t *, const char *, size_t, void *);
 #define ct_wctob(w)          ((int)(w))
 #define ct_wctomb            error
 #define ct_wctomb_reset
diff -r e797c89f77f0 -r 72da5975ef37 lib/libedit/el.c
--- a/lib/libedit/el.c  Wed Feb 24 16:06:20 2016 +0000
+++ b/lib/libedit/el.c  Wed Feb 24 17:13:22 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.c,v 1.82 2016/02/17 19:47:49 christos Exp $ */
+/*     $NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)el.c       8.2 (Berkeley) 1/3/94";
 #else
-__RCSID("$NetBSD: el.c,v 1.82 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.83 2016/02/24 17:13:22 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -308,7 +308,6 @@
        {
                el_rfunc_t rc = va_arg(ap, el_rfunc_t);
                rv = el_read_setfn(el, rc);
-               el->el_flags &= ~NARROW_READ;
                break;
        }
 
diff -r e797c89f77f0 -r 72da5975ef37 lib/libedit/el.h
--- a/lib/libedit/el.h  Wed Feb 24 16:06:20 2016 +0000
+++ b/lib/libedit/el.h  Wed Feb 24 17:13:22 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.h,v 1.33 2016/02/17 19:47:49 christos Exp $ */
+/*     $NetBSD: el.h,v 1.34 2016/02/24 17:13:22 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -57,7 +57,6 @@
 #define        UNBUFFERED      0x08
 #define        CHARSET_IS_UTF8 0x10
 #define        NARROW_HISTORY  0x40
-#define        NARROW_READ     0x80
 
 typedef unsigned char el_action_t;     /* Index to command array       */
 
diff -r e797c89f77f0 -r 72da5975ef37 lib/libedit/eln.c
--- a/lib/libedit/eln.c Wed Feb 24 16:06:20 2016 +0000
+++ b/lib/libedit/eln.c Wed Feb 24 17:13:22 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eln.c,v 1.26 2016/02/24 14:25:38 christos Exp $        */
+/*     $NetBSD: eln.c,v 1.27 2016/02/24 17:13:22 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.26 2016/02/24 14:25:38 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.27 2016/02/24 17:13:22 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <errno.h>
@@ -247,10 +247,8 @@
                break;
        }
 
-       /* XXX: do we need to change el_rfunc_t? */
        case EL_GETCFN:         /* el_rfunc_t */
                ret = el_wset(el, op, va_arg(ap, el_rfunc_t));
-               el->el_flags |= NARROW_READ;
                break;
 
        case EL_CLIENTDATA:     /* void * */
@@ -344,7 +342,6 @@
                break;
        }
 
-       /* XXX: do we need to change el_rfunc_t? */
        case EL_GETCFN:         /* el_rfunc_t */
                ret = el_wget(el, op, va_arg(ap, el_rfunc_t *));
                break;
diff -r e797c89f77f0 -r 72da5975ef37 lib/libedit/read.c
--- a/lib/libedit/read.c        Wed Feb 24 16:06:20 2016 +0000
+++ b/lib/libedit/read.c        Wed Feb 24 17:13:22 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: read.c,v 1.83 2016/02/24 14:25:38 christos Exp $       */
+/*     $NetBSD: read.c,v 1.84 2016/02/24 17:13:22 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.83 2016/02/24 14:25:38 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.84 2016/02/24 17:13:22 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -59,7 +59,7 @@
 
 private int    read__fixio(int, int);
 private int    read_preread(EditLine *);
-private int    read_char(EditLine *, Char *);
+private int    read_char(EditLine *, wchar_t *);
 private int    read_getcmd(EditLine *, el_action_t *, Char *);
 private void   read_pop(c_macro_t *);
 
@@ -304,7 +304,7 @@
  *     Read a character from the tty.
  */
 private int
-read_char(EditLine *el, Char *cp)
+read_char(EditLine *el, wchar_t *cp)
 {
        ssize_t num_read;
        int tried = 0;
@@ -331,14 +331,14 @@
                        tried = 1;
                } else {
                        errno = e;
-                       *cp = '\0';
+                       *cp = L'\0';
                        return -1;
                }
        }
 
        /* Test for EOF */
        if (num_read == 0) {
-               *cp = '\0';
+               *cp = L'\0';
                return 0;
        }
 
@@ -372,7 +372,7 @@
                        if ((el->el_flags & CHARSET_IS_UTF8) == 0 ||
                            cbp >= MB_LEN_MAX) {
                                errno = EILSEQ;
-                               *cp = '\0';
+                               *cp = L'\0';
                                return -1;
                        }
                        /* Incomplete sequence, read another byte. */
@@ -407,7 +407,6 @@
 {
        int num_read;
        c_macro_t *ma = &el->el_chared.c_macro;
-       Char cp_temp;
 
        terminal__flush(el);
        for (;;) {
@@ -443,14 +442,9 @@
 #ifdef DEBUG_READ
        (void) fprintf(el->el_errfile, "Reading a character\n");
 #endif /* DEBUG_READ */
-       num_read = (*el->el_read.read_char)(el, &cp_temp);
+       num_read = (*el->el_read.read_char)(el, cp);
        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 %lc\n", *cp);
 #endif /* DEBUG_READ */
@@ -493,6 +487,7 @@
        int retval;
        el_action_t cmdnum = 0;
        int num;                /* how many chars we have read at NL */
+       wchar_t wc;
        Char ch, *cp;
        int crlf = 0;
        int nrb;
@@ -508,7 +503,8 @@
                size_t idx;
 
                cp = el->el_line.buffer;
-               while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
+               while ((num = (*el->el_read.read_char)(el, &wc)) == 1) {
+                       *cp = (Char)wc;
                        /* make sure there is space for next character */
                        if (cp + 1 >= el->el_line.limit) {
                                idx = (size_t)(cp - el->el_line.buffer);
@@ -560,7 +556,8 @@
 
                terminal__flush(el);
 
-               while ((num = (*el->el_read.read_char)(el, cp)) == 1) {
+               while ((num = (*el->el_read.read_char)(el, &wc)) == 1) {
+                       *cp = (Char)wc;
                        /* make sure there is space next character */
                        if (cp + 1 >= el->el_line.limit) {
                                idx = (size_t)(cp - el->el_line.buffer);
diff -r e797c89f77f0 -r 72da5975ef37 lib/libedit/read.h
--- a/lib/libedit/read.h        Wed Feb 24 16:06:20 2016 +0000
+++ b/lib/libedit/read.h        Wed Feb 24 17:13:22 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: read.h,v 1.8 2016/02/17 19:47:49 christos Exp $        */
+/*     $NetBSD: read.h,v 1.9 2016/02/24 17:13:22 christos Exp $        */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #ifndef        _h_el_read
 #define        _h_el_read
 
-typedef int (*el_rfunc_t)(EditLine *, Char *);
+typedef int (*el_rfunc_t)(EditLine *, wchar_t *);
 
 typedef struct el_read_t {
        el_rfunc_t      read_char;      /* Function to read a character */
diff -r e797c89f77f0 -r 72da5975ef37 lib/libedit/readline.c
--- a/lib/libedit/readline.c    Wed Feb 24 16:06:20 2016 +0000
+++ b/lib/libedit/readline.c    Wed Feb 24 17:13:22 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.c,v 1.125 2016/02/17 19:47:49 christos Exp $  */
+/*     $NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $  */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.125 2016/02/17 19:47:49 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.126 2016/02/24 17:13:22 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -166,13 +166,13 @@
 static unsigned char    _el_rl_complete(EditLine *, int);
 static unsigned char    _el_rl_tstp(EditLine *, int);
 static char            *_get_prompt(EditLine *);
-static int              _getc_function(EditLine *, char *);
+static int              _getc_function(EditLine *, wchar_t *);
 static HIST_ENTRY      *_move_history(int);
 static int              _history_expand_command(const char *, size_t, size_t,
     char **);
 static char            *_rl_compat_sub(const char *, const char *,
     const char *, int);
-static int              _rl_event_read_char(EditLine *, char *);
+static int              _rl_event_read_char(EditLine *, wchar_t *);
 static void             _rl_update_pos(void);
 
 
@@ -209,14 +209,14 @@
  */
 static int
 /*ARGSUSED*/
-_getc_function(EditLine *el __attribute__((__unused__)), char *c)
+_getc_function(EditLine *el __attribute__((__unused__)), wchar_t *c)
 {
        int i;
 



Home | Main Index | Thread Index | Old Index