tech-userlevel archive

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

Patch from FreeBSD for el_gets() in libedit



			Hi tech-userlevel@,

FreeBSD patched their own copy of libedit about a month ago, see:
https://svnweb.freebsd.org/ports/head/devel/libedit/files/patch-src_eln.c?revision=382458&view=markup
(patch attached)

If I get this right (I have never used libedit myself) the value
returned in the "nread" argument (called "count" in the corresponding
manual page) may be wrong if any wide-character was encountered.

I did not find where el_wgets() is implemented. Would anyone know?

In pkgsrc I saw a folder called "libedit" in net/tnftp/files/libedit,
and it has a completely different implementation of el_gets().

Ok to commit?

Cheers,
-- 
khorben
--- src/eln.c.orig	2015-03-25 21:02:28.000000000 +0100
+++ src/eln.c	2015-03-28 11:42:29.913925000 +0100
@@ -75,12 +75,17 @@ 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, nread);
+	tmp = el_wgets(el, &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);
 }
 


Home | Main Index | Thread Index | Old Index