Module Name: src Committed By: christos Date: Sun Feb 14 14:47:48 UTC 2016
Modified Files: src/lib/libedit: chartype.c chartype.h read.c Log Message: >From Ingo Schwartze: Next step: Remove #ifdef'ing in read_char(), in the same style as we did for setlocale(3) in el.c. A few remarks are required to explain the choices made. * On first sight, handling mbrtowc(3) seems a bit less trivial than handling setlocale(3) because its prototype uses the data type mbstate_t from <wchar.h>. However, it turns out that "histedit.h" already includes <wchar.h> unconditionally (i don't like headers including other headers, but that ship has sailed, people are by now certainly used to the fact that including "histedit.h" doesn't require including <wchar.h> before), and "histedit.h" is of course included all over the place. So from that perspective, there is no problem with using mbrtowc(3) unconditionally ever for !WIDECHAR. * However, <wchar.h> also defines the mbrtowc(3) prototype, so we cannot just #define mbrtowc away, or including the header will break. It would also be a bad idea to porovide a local implementation of mbrtowc() and hope that it overrides the one in libc. Besides, the required prototype is subtly different: While mbrtowc(3) takes "wchar_t *" as its first argument, we need a function that takes "Char *". So unfortunately, we have to keep a ct_mbrtowc #define, at least until we can maybe get rid of "Char *" in the more remote future. * After getting rid of the #else clause in read_char(), we can pull "return 1;" into the default: clause. After that, we can get rid of the ugly "goto again_lastbyte;" and just "break;". As a bonus, that also gets rid of the ugly CONSTCOND. * While here, delete the unused ct_mbtowc() from chartype.h. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libedit/chartype.c cvs rdiff -u -r1.17 -r1.18 src/lib/libedit/chartype.h cvs rdiff -u -r1.76 -r1.77 src/lib/libedit/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.