diff options
author | 2016-03-20 20:16:09 +0000 | |
---|---|---|
committer | 2016-03-20 20:16:09 +0000 | |
commit | 3a40234dc67f056961931b881e187b6a4d62687c (patch) | |
tree | c077cf16d0c23b3d2d33e4dcce1e97d03b3bded2 /lib/libedit/read.c | |
parent | Delete the weird IGNORE_EXTCHARS flag, simplifying the code (diff) | |
download | wireguard-openbsd-3a40234dc67f056961931b881e187b6a4d62687c.tar.xz wireguard-openbsd-3a40234dc67f056961931b881e187b6a4d62687c.zip |
Get rid of "#ifdef WIDECHAR" and one goto in read_char(),
making the code more readable. Instead, provide an mbrtowc(3)
replacement function in chartype.[hc], files that encapsulate
such system dependencies anyway. No functional change.
OK czarkoff@
Diffstat (limited to 'lib/libedit/read.c')
-rw-r--r-- | lib/libedit/read.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/libedit/read.c b/lib/libedit/read.c index 5093ea33b4e..2feace6ddb4 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.23 2016/03/20 19:33:16 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.24 2016/03/20 20:16:09 schwarze Exp $ */ /* $NetBSD: read.c,v 1.57 2010/07/21 18:18:52 christos Exp $ */ /*- @@ -330,10 +330,9 @@ read_char(EditLine *el, Char *cp) return 0; } -#ifdef WIDECHAR - do { + for (;;) { mbstate_t mbs; -again_lastbyte: + ++cbp; /* This only works because UTF8 is stateless */ memset(&mbs, 0, sizeof(mbs)); @@ -346,7 +345,7 @@ again_lastbyte: */ cbuf[0] = cbuf[cbp - 1]; cbp = 0; - goto again_lastbyte; + break; } else { /* Invalid byte, discard it. */ cbp = 0; @@ -368,14 +367,9 @@ again_lastbyte: goto again; default: /* Valid character, process it. */ - break; + return 1; } - } while (/*CONSTCOND*/0); -#else - *cp = (unsigned char)cbuf[0]; -#endif - - return 1; + } } /* read_pop(): |