Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit make el_gets() return the number of characters r...



details:   https://anonhg.NetBSD.org/src/rev/0a1fe93597f1
branches:  trunk
changeset: 338326:0a1fe93597f1
user:      christos <christos%NetBSD.org@localhost>
date:      Mon May 18 15:07:04 2015 +0000

description:
make el_gets() return the number of characters read in wide mode (not the
number of wide characters) From khorben@ by FreeBSD:
https://svnweb.freebsd.org/ports/head/devel/libedit/files/patch-src_eln.c?\
revision=382458&view=markup
XXX: Pullup-7

diffstat:

 lib/libedit/eln.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (31 lines):

diff -r 37740075f586 -r 0a1fe93597f1 lib/libedit/eln.c
--- a/lib/libedit/eln.c Mon May 18 15:03:16 2015 +0000
+++ b/lib/libedit/eln.c Mon May 18 15:07:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: eln.c,v 1.18 2015/03/24 21:26:50 christos Exp $        */
+/*     $NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 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.18 2015/03/24 21:26:50 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include "histedit.h"
@@ -79,6 +79,12 @@
        if (!(el->el_flags & CHARSET_IS_UTF8))
                el->el_flags |= IGNORE_EXTCHARS;
        tmp = el_wgets(el, nread);
+       if (tmp != NULL) {
+           size_t nwread = 0;
+           for (int i = 0; i < *nread; i++)
+               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);



Home | Main Index | Thread Index | Old Index