diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-03-20 19:33:17 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-03-20 19:33:17 +0000 |
commit | 05ebab8294bd1f55bbb1df7ae2c3482d26bea7e0 (patch) | |
tree | 945a9c8a147136fa0780be497a68e3039200a3d6 /lib/libedit/eln.c | |
parent | ba1a981ecd6c87247aa8c1861dc29bc1c15d5ef6 (diff) |
Delete the weird IGNORE_EXTCHARS flag, simplifying the code
in the generic low-level function read_char().
Until we fully enable UTF-8 support, instead filter out non-ASCII
characters in the more logical place in the high-level function
el_gets(3).
OK czarkoff@.
Diffstat (limited to 'lib/libedit/eln.c')
-rw-r--r-- | lib/libedit/eln.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c index 39bfa6dd48c..3395b239720 100644 --- a/lib/libedit/eln.c +++ b/lib/libedit/eln.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eln.c,v 1.7 2016/03/20 19:14:29 schwarze Exp $ */ +/* $OpenBSD: eln.c,v 1.8 2016/03/20 19:33:16 schwarze Exp $ */ /* $NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $ */ /*- @@ -77,10 +77,24 @@ public const char * el_gets(EditLine *el, int *nread) { const wchar_t *tmp; + wchar_t *rd, *wr; - el->el_flags |= IGNORE_EXTCHARS; tmp = el_wgets(el, nread); - el->el_flags &= ~IGNORE_EXTCHARS; + + /* + * Temporary until the libedit audit is complete: + * Filter out all non-ASCII characters. + */ + wr = (wchar_t *)tmp; + for (rd = wr; *rd != L'\0'; rd++) { + if (wr < rd) + *wr = *rd; + if (*rd < 128) + wr++; + } + *wr = L'\0'; + *nread = wr - tmp; + return ct_encode_string(tmp, &el->el_lgcyconv); } |