aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/lineedit.c24
-rw-r--r--libbb/unicode.c14
2 files changed, 37 insertions, 1 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index a6884c7e0..54f0edef0 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -726,8 +726,15 @@ static void input_forward(void)
726#if !ENABLE_PLATFORM_MINGW32 726#if !ENABLE_PLATFORM_MINGW32
727 put_cur_glyph_and_inc_cursor(); 727 put_cur_glyph_and_inc_cursor();
728#else 728#else
729 /*
730 * inc_cursor improves forward cursor movement appearance on
731 * win 7/8 console, but it's broken with unicode wide-glyphs,
732 * e.g. paste and move forward over: echo 开开心心过每一天
733 * so disable inc_cursor when unicode is active (which is only
734 * windows 10+, where inc_cursor is not needed anyway).
735 */
729 { 736 {
730 if (terminal_mode(FALSE) & VT_INPUT) 737 if (unicode_status == UNICODE_ON)
731 put_cur_glyph_and_inc_cursor(); 738 put_cur_glyph_and_inc_cursor();
732 else 739 else
733 inc_cursor(); 740 inc_cursor();
@@ -770,6 +777,11 @@ static void add_match(char *matched, int sensitive)
770 || (!ENABLE_UNICODE_SUPPORT && *p >= 0x7f) 777 || (!ENABLE_UNICODE_SUPPORT && *p >= 0x7f)
771 || (ENABLE_UNICODE_SUPPORT && *p == 0x7f) 778 || (ENABLE_UNICODE_SUPPORT && *p == 0x7f)
772# else 779# else
780 /*
781 * on Windows, *p > 0x7f is never control:
782 * without unicode active: these are normal codepage chars.
783 * with unicode active: these are UTF8 continuation bytes.
784 */
773 || *p == 0x7f 785 || *p == 0x7f
774# endif 786# endif
775 ) { 787 ) {
@@ -1318,6 +1330,12 @@ static NOINLINE void input_tab(smallint *lastWasTab)
1318# if ENABLE_PLATFORM_MINGW32 1330# if ENABLE_PLATFORM_MINGW32
1319 int chosen_index = 0; 1331 int chosen_index = 0;
1320 int chosen_sens = FALSE; 1332 int chosen_sens = FALSE;
1333 /*
1334 * FIXME: the next three vars are unused with ENABLE_UNICODE_SUPPORT
1335 * because the mingw code which uses them to update a tab-completion
1336 * prefix to the correct case (e.g. ~/desk<tab> to ~/Desktop/) is
1337 * not compiled, and so e.g. ~/desk<tab> completes to ~/desktop/ .
1338 */
1321 unsigned orig_pfx_len; 1339 unsigned orig_pfx_len;
1322 char *target; 1340 char *target;
1323 const char *source; 1341 const char *source;
@@ -2803,7 +2821,11 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2803#if ENABLE_PLATFORM_MINGW32 2821#if ENABLE_PLATFORM_MINGW32
2804 case CTRL('Z'): 2822 case CTRL('Z'):
2805 command_ps[command_len] = '\0'; 2823 command_ps[command_len] = '\0';
2824 #if ENABLE_UNICODE_SUPPORT
2825 bs_to_slash_u(command_ps);
2826 #else
2806 bs_to_slash(command_ps); 2827 bs_to_slash(command_ps);
2828 #endif
2807 redraw(cmdedit_y, 0); 2829 redraw(cmdedit_y, 0);
2808 break; 2830 break;
2809#endif 2831#endif
diff --git a/libbb/unicode.c b/libbb/unicode.c
index e98cbbf35..206ec0dcb 100644
--- a/libbb/unicode.c
+++ b/libbb/unicode.c
@@ -69,8 +69,14 @@ void FAST_FUNC init_unicode(void)
69void FAST_FUNC reinit_unicode(const char *LANG) 69void FAST_FUNC reinit_unicode(const char *LANG)
70{ 70{
71 unicode_status = UNICODE_OFF; 71 unicode_status = UNICODE_OFF;
72#if ENABLE_PLATFORM_MINGW32
73 /* enable unicode only when ACP is UTF8 and the env var is not 'C' */
74 if (GetACP() != CP_UTF8 || (LANG && LANG[0] == 'C' && LANG[1] == 0))
75 return;
76#else
72 if (!LANG || !(strstr(LANG, ".utf") || strstr(LANG, ".UTF"))) 77 if (!LANG || !(strstr(LANG, ".utf") || strstr(LANG, ".UTF")))
73 return; 78 return;
79#endif
74 unicode_status = UNICODE_ON; 80 unicode_status = UNICODE_ON;
75} 81}
76 82
@@ -653,6 +659,9 @@ int FAST_FUNC wcwidth(unsigned ucs)
653 { 0x0A38, 0x0A3A }, { 0x0A3F, 0x0A3F }, { 0xD167, 0xD169 }, 659 { 0x0A38, 0x0A3A }, { 0x0A3F, 0x0A3F }, { 0xD167, 0xD169 },
654 { 0xD173, 0xD182 }, { 0xD185, 0xD18B }, { 0xD1AA, 0xD1AD }, 660 { 0xD173, 0xD182 }, { 0xD185, 0xD18B }, { 0xD1AA, 0xD1AD },
655 { 0xD242, 0xD244 } 661 { 0xD242, 0xD244 }
662#if ENABLE_PLATFORM_MINGW32
663 , { 0xF3FB, 0xF3FF }
664#endif
656 }; 665 };
657 /* Binary search in table of non-spacing characters in Supplementary Multilingual Plane */ 666 /* Binary search in table of non-spacing characters in Supplementary Multilingual Plane */
658 if (in_interval_table(ucs ^ 0x10000, combining0x10000, ARRAY_SIZE(combining0x10000) - 1)) 667 if (in_interval_table(ucs ^ 0x10000, combining0x10000, ARRAY_SIZE(combining0x10000) - 1))
@@ -689,6 +698,11 @@ int FAST_FUNC wcwidth(unsigned ucs)
689 || (ucs >= 0xff00 && ucs <= 0xff60) /* Fullwidth Forms */ 698 || (ucs >= 0xff00 && ucs <= 0xff60) /* Fullwidth Forms */
690 || (ucs >= 0xffe0 && ucs <= 0xffe6) 699 || (ucs >= 0xffe0 && ucs <= 0xffe6)
691# endif 700# endif
701#if ENABLE_PLATFORM_MINGW32
702# if CONFIG_LAST_SUPPORTED_WCHAR >= 0x10000
703 || (ucs >= 0x1f600 && ucs <= 0x1f64f) /* Emoticons */
704# endif
705#endif
692# if CONFIG_LAST_SUPPORTED_WCHAR >= 0x20000 706# if CONFIG_LAST_SUPPORTED_WCHAR >= 0x20000
693 || ((ucs >> 17) == (2 >> 1)) /* 20000..3ffff: Supplementary and Tertiary Ideographic Planes */ 707 || ((ucs >> 17) == (2 >> 1)) /* 20000..3ffff: Supplementary and Tertiary Ideographic Planes */
694# endif 708# endif