added simplified Unicode support for non-locale-enabled builds

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2009-07-11 21:36:13 +02:00
parent 883cea4751
commit 42a8fd0db0
6 changed files with 331 additions and 24 deletions

View File

@ -34,10 +34,7 @@
* PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
*/
#include "libbb.h"
#if ENABLE_FEATURE_ASSUME_UNICODE
# include <wchar.h>
# include <wctype.h>
#endif
#include "unicode.h"
/* FIXME: obsolete CONFIG item? */
#define ENABLE_FEATURE_NONPRINTABLE_INVERSE_PUT 0
@ -1581,7 +1578,7 @@ static int lineedit_read_key(char *read_key_buffer)
return ic;
unicode_buf[unicode_idx++] = ic;
unicode_buf[unicode_idx] = '\0';
if (mbstowcs(&wc, unicode_buf, 1) < 1 && unicode_idx < MB_CUR_MAX) {
if (mbstowcs(&wc, unicode_buf, 1) != 1 && unicode_idx < MB_CUR_MAX) {
delay = 50;
goto poll_again;
}
@ -1636,6 +1633,8 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
return len;
}
check_unicode_in_env();
// FIXME: audit & improve this
if (maxsize > MAX_LINELEN)
maxsize = MAX_LINELEN;