aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorTomas Heinrich <heinrich.tomas@gmail.com>2010-03-26 13:13:24 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-26 13:13:24 +0100
commitaa167556cd2954bb9a9fb0a005178462087a4600 (patch)
tree241a779a20d302397bd5e59eefceb49ce78834e4 /libbb/lineedit.c
parent385b4562e39e373761fd62b0990dce02ff96661f (diff)
downloadbusybox-w32-aa167556cd2954bb9a9fb0a005178462087a4600.tar.gz
busybox-w32-aa167556cd2954bb9a9fb0a005178462087a4600.tar.bz2
busybox-w32-aa167556cd2954bb9a9fb0a005178462087a4600.zip
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 be022e8ae..38a09cb26 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1742,9 +1742,10 @@ static int lineedit_read_key(char *read_key_buffer)
1742static int isrtl_str(void) 1742static int isrtl_str(void)
1743{ 1743{
1744 int idx = cursor; 1744 int idx = cursor;
1745 while (command_ps[idx] >= ' ' && command_ps[idx] < 127 && !isalpha(command_ps[idx])) 1745
1746 while (idx < command_len && unicode_bidi_is_neutral_wchar(command_ps[idx]))
1746 idx++; 1747 idx++;
1747 return unicode_isrtl(command_ps[idx]); 1748 return unicode_bidi_isrtl(command_ps[idx]);
1748} 1749}
1749#else 1750#else
1750# define isrtl_str() 0 1751# define isrtl_str() 0
@@ -2220,19 +2221,18 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
2220 command_ps[cursor] = ic; 2221 command_ps[cursor] = ic;
2221 command_ps[cursor + 1] = BB_NUL; 2222 command_ps[cursor + 1] = BB_NUL;
2222 cmdedit_set_out_char(' '); 2223 cmdedit_set_out_char(' ');
2223 if (unicode_isrtl(ic)) 2224 if (unicode_bidi_isrtl(ic))
2224 input_backward(1); 2225 input_backward(1);
2225 } else { 2226 } else {
2226 /* In the middle, insert */ 2227 /* In the middle, insert */
2227 /* is char right-to-left, or "neutral" one (e.g. comma) added to rtl text? */
2228 int rtl = ENABLE_UNICODE_BIDI_SUPPORT ? (unicode_isrtl(ic) || (ic < 127 && !isalpha(ic) && isrtl_str())) : 0;
2229 int sc = cursor; 2228 int sc = cursor;
2230 2229
2231 memmove(command_ps + sc + 1, command_ps + sc, 2230 memmove(command_ps + sc + 1, command_ps + sc,
2232 (command_len - sc) * sizeof(command_ps[0])); 2231 (command_len - sc) * sizeof(command_ps[0]));
2233 command_ps[sc] = ic; 2232 command_ps[sc] = ic;
2234 if (!rtl) 2233 /* is right-to-left char, or neutral one (e.g. comma) was just added to rtl text? */
2235 sc++; 2234 if (!isrtl_str())
2235 sc++; /* no */
2236 /* rewrite from cursor */ 2236 /* rewrite from cursor */
2237 input_end(); 2237 input_end();
2238 /* to prev x pos + 1 */ 2238 /* to prev x pos + 1 */