Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit GC IGNORE_EXTCHARS and simplify code (Ingo Schwa...



details:   https://anonhg.NetBSD.org/src/rev/12134946d972
branches:  trunk
changeset: 343533:12134946d972
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Feb 12 15:36:08 2016 +0000

description:
GC IGNORE_EXTCHARS and simplify code (Ingo Schwarze)

diffstat:

 lib/libedit/el.h   |   3 +--
 lib/libedit/eln.c  |  13 ++-----------
 lib/libedit/read.c |  18 +++++-------------
 3 files changed, 8 insertions(+), 26 deletions(-)

diffs (129 lines):

diff -r 70e2b15831ed -r 12134946d972 lib/libedit/el.h
--- a/lib/libedit/el.h  Fri Feb 12 15:11:09 2016 +0000
+++ b/lib/libedit/el.h  Fri Feb 12 15:36:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: el.h,v 1.25 2011/07/29 23:44:44 christos Exp $ */
+/*     $NetBSD: el.h,v 1.26 2016/02/12 15:36:08 christos Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -58,7 +58,6 @@
 #define        EDIT_DISABLED   0x04
 #define        UNBUFFERED      0x08
 #define        CHARSET_IS_UTF8 0x10
-#define        IGNORE_EXTCHARS 0x20            /* Ignore characters read > 0xff */
 #define        NARROW_HISTORY  0x40
 #define        NARROW_READ     0x80
 
diff -r 70e2b15831ed -r 12134946d972 lib/libedit/eln.c
--- a/lib/libedit/eln.c Fri Feb 12 15:11:09 2016 +0000
+++ b/lib/libedit/eln.c Fri Feb 12 15:36:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $        */
+/*     $NetBSD: eln.c,v 1.20 2016/02/12 15:36:08 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.19 2015/05/18 15:07:04 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.20 2016/02/12 15:36:08 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include "histedit.h"
@@ -50,12 +50,7 @@
        int num_read;
        wchar_t wc = 0;
 
-       if (!(el->el_flags & CHARSET_IS_UTF8))
-               el->el_flags |= IGNORE_EXTCHARS;
        num_read = el_wgetc (el, &wc);
-       if (!(el->el_flags & CHARSET_IS_UTF8))
-               el->el_flags &= ~IGNORE_EXTCHARS;
-
        if (num_read > 0)
                *cp = (char)wc;
        return num_read;
@@ -76,8 +71,6 @@
 {
        const wchar_t *tmp;
 
-       if (!(el->el_flags & CHARSET_IS_UTF8))
-               el->el_flags |= IGNORE_EXTCHARS;
        tmp = el_wgets(el, nread);
        if (tmp != NULL) {
            size_t nwread = 0;
@@ -85,8 +78,6 @@
                nwread += ct_enc_width(tmp[i]);
            *nread = (int)nwread;
        }
-       if (!(el->el_flags & CHARSET_IS_UTF8))
-               el->el_flags &= ~IGNORE_EXTCHARS;
        return ct_encode_string(tmp, &el->el_lgcyconv);
 }
 
diff -r 70e2b15831ed -r 12134946d972 lib/libedit/read.c
--- a/lib/libedit/read.c        Fri Feb 12 15:11:09 2016 +0000
+++ b/lib/libedit/read.c        Fri Feb 12 15:36:08 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: read.c,v 1.75 2016/02/12 15:11:09 christos Exp $       */
+/*     $NetBSD: read.c,v 1.76 2016/02/12 15:36:08 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.75 2016/02/12 15:11:09 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.76 2016/02/12 15:36:08 christos Exp $");
 #endif
 #endif /* not lint && not SCCSID */
 
@@ -305,7 +305,6 @@
        int tried = 0;
        char cbuf[MB_LEN_MAX];
        size_t cbp = 0;
-       int bytes = 0;
        int save_errno = errno;
 
  again:
@@ -341,12 +340,11 @@
 #ifdef WIDECHAR
        do {
                mbstate_t mbs;
-               size_t rbytes;
 again_lastbyte:
                ++cbp;
                /* This only works because UTF8 is stateless */
                memset(&mbs, 0, sizeof(mbs));
-               switch (rbytes = ct_mbrtowc(cp, cbuf, cbp, &mbs)) {
+               switch (ct_mbrtowc(cp, cbuf, cbp, &mbs)) {
                case (size_t)-1:
                        if (cbp > 1) {
                                /*
@@ -377,20 +375,14 @@
                        goto again;
                default:
                        /* Valid character, process it. */
-                       bytes = (int)rbytes;
                        break;
                }
        } while (/*CONSTCOND*/0);
 #else
-               *cp = (Char)(unsigned char)cbuf[0];
+       *cp = (Char)(unsigned char)cbuf[0];
 #endif
 
-       if ((el->el_flags & IGNORE_EXTCHARS) && bytes > 1) {
-               cbp = 0; /* skip this character */
-               goto again;
-       }
-
-       return (int)num_read;
+       return 1;
 }
 
 /* read_pop():



Home | Main Index | Thread Index | Old Index