From c729c39672cd6bc2e7f57dccc8aab4eb761f0ba6 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Sun, 7 Feb 2016 01:38:50 +0000 Subject: Import libedit 2016-01-16 Obtained from: NetBSD --- eln.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'eln.c') diff --git a/eln.c b/eln.c index 5bcfb4f2b3b3..e1de71adf992 100644 --- a/eln.c +++ b/eln.c @@ -1,4 +1,4 @@ -/* $NetBSD: eln.c,v 1.17 2014/06/18 18:12:28 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.17 2014/06/18 18:12:28 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" @@ -76,9 +76,17 @@ el_gets(EditLine *el, int *nread) { const wchar_t *tmp; - el->el_flags |= IGNORE_EXTCHARS; + if (!(el->el_flags & CHARSET_IS_UTF8)) + el->el_flags |= IGNORE_EXTCHARS; tmp = el_wgets(el, nread); - el->el_flags &= ~IGNORE_EXTCHARS; + 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); } -- cgit v1.3