summaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorTomas Heinrich2010-03-26 13:13:24 +0100
committerDenys Vlasenko2010-03-26 13:13:24 +0100
commitaa167556cd2954bb9a9fb0a005178462087a4600 (patch)
tree241a779a20d302397bd5e59eefceb49ce78834e4 /libbb/lineedit.c
parent385b4562e39e373761fd62b0990dce02ff96661f (diff)
downloadbusybox-aa167556cd2954bb9a9fb0a005178462087a4600.zip
busybox-aa167556cd2954bb9a9fb0a005178462087a4600.tar.gz
unicode: optional table for better handling of neutral bidi chars
Off: function old new delta unicode_bidi_isrtl - 55 +55 isrtl_str 51 65 +14 unicode_isrtl 55 - -55 read_line_input 5003 4937 -66 ------------------------------------------------------------------------------ (add/remove: 1/4 grow/shrink: 1/1 up/down: 69/-121) Total: -52 bytes On: function old new delta static.neutral_b - 320 +320 static.neutral_p - 142 +142 unicode_bidi_isrtl - 55 +55 unicode_bidi_is_neutral_wchar - 55 +55 isrtl_str 51 59 +8 unicode_isrtl 55 - -55 read_line_input 5003 4937 -66 ------------------------------------------------------------------------------ (add/remove: 4/4 grow/shrink: 1/1 up/down: 580/-121) Total: 459 bytes Signed-off-by: Tomas Heinrich <heinrich.tomas@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index be022e8..38a09cb 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1742,9 +1742,10 @@ static int lineedit_read_key(char *read_key_buffer)
static int isrtl_str(void)
{
int idx = cursor;
- while (command_ps[idx] >= ' ' && command_ps[idx] < 127 && !isalpha(command_ps[idx]))
+
+ while (idx < command_len && unicode_bidi_is_neutral_wchar(command_ps[idx]))
idx++;
- return unicode_isrtl(command_ps[idx]);
+ return unicode_bidi_isrtl(command_ps[idx]);
}
#else
# define isrtl_str() 0
@@ -2220,19 +2221,18 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
command_ps[cursor] = ic;
command_ps[cursor + 1] = BB_NUL;
cmdedit_set_out_char(' ');
- if (unicode_isrtl(ic))
+ if (unicode_bidi_isrtl(ic))
input_backward(1);
} else {
/* In the middle, insert */
- /* is char right-to-left, or "neutral" one (e.g. comma) added to rtl text? */
- int rtl = ENABLE_UNICODE_BIDI_SUPPORT ? (unicode_isrtl(ic) || (ic < 127 && !isalpha(ic) && isrtl_str())) : 0;
int sc = cursor;
memmove(command_ps + sc + 1, command_ps + sc,
(command_len - sc) * sizeof(command_ps[0]));
command_ps[sc] = ic;
- if (!rtl)
- sc++;
+ /* is right-to-left char, or neutral one (e.g. comma) was just added to rtl text? */
+ if (!isrtl_str())
+ sc++; /* no */
/* rewrite from cursor */
input_end();
/* to prev x pos + 1 */