diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-05-18 22:03:05 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2015-05-18 22:03:05 +0000 |
| commit | d44bc1335e8a3bdb54198005e191aaebb3903d1b (patch) | |
| tree | 6bf0961fc5ea51f4406b759c41ab6c89442a04bd /lib/libedit/eln.c | |
| parent | abdc8d91e7365bad2428412fb8e2da9536195154 (diff) | |
Notes
Diffstat (limited to 'lib/libedit/eln.c')
| -rw-r--r-- | lib/libedit/eln.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c index 41697f490be7e..013aa3e04093f 100644 --- a/lib/libedit/eln.c +++ b/lib/libedit/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 <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -77,18 +77,18 @@ public const char * el_gets(EditLine *el, int *nread) { const wchar_t *tmp; - int nwread; - - *nread = 0; if (!(el->el_flags & CHARSET_IS_UTF8)) el->el_flags |= IGNORE_EXTCHARS; - tmp = el_wgets(el, &nwread); + 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; - for (int i = 0; i < nwread; i++) - *nread += ct_enc_width(tmp[i]); - return ct_encode_string(tmp, &el->el_lgcyconv); } |
