mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-09 19:50:32 +02:00
internal fixes for declare; additional tests for broken wcwidth()
This commit is contained in:
@@ -2063,7 +2063,11 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
|
||||
assume it's a combining character and back one up so the two base
|
||||
characters no longer compare equivalently. */
|
||||
t = MBRTOWC (&wc, ofd, mb_cur_max, &ps);
|
||||
#if 0
|
||||
if (t > 0 && UNICODE_COMBINING_CHAR (wc) && WCWIDTH (wc) == 0)
|
||||
#else
|
||||
if (t > 0 && IS_COMBINING_CHAR (wc))
|
||||
#endif
|
||||
{
|
||||
old_offset = _rl_find_prev_mbchar (old, ofd - old, MB_FIND_ANY);
|
||||
new_offset = _rl_find_prev_mbchar (new, nfd - new, MB_FIND_ANY);
|
||||
|
||||
@@ -216,11 +216,13 @@ _rl_find_next_mbchar_internal (const char *string, int seed, int count, int find
|
||||
|
||||
if (find_non_zero)
|
||||
{
|
||||
tmp = MBRTOWC (&wc, string + point, strlen (string + point), &ps);
|
||||
len = strlen (string + point);
|
||||
tmp = MBRTOWC (&wc, string + point, len, &ps);
|
||||
while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && WCWIDTH (wc) == 0)
|
||||
{
|
||||
point += tmp;
|
||||
tmp = MBRTOWC (&wc, string + point, strlen (string + point), &ps);
|
||||
len -= tmp;
|
||||
tmp = MBRTOWC (&wc, string + point, len, &ps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,11 +263,16 @@ _rl_find_prev_utf8char (const char *string, int seed, int find_non_zero)
|
||||
save = prev;
|
||||
|
||||
/* Move back until we're not in the middle of a multibyte char */
|
||||
#if 0
|
||||
if (UTF8_MBCHAR (b))
|
||||
{
|
||||
while (prev > 0 && (b = (unsigned char)string[--prev]) && UTF8_MBCHAR (b))
|
||||
;
|
||||
}
|
||||
#else
|
||||
while (prev > 0 && (b = (unsigned char)string[--prev]) && UTF8_MBFIRSTCHAR (b) == 0)
|
||||
;
|
||||
#endif
|
||||
|
||||
if (UTF8_MBFIRSTCHAR (b))
|
||||
{
|
||||
|
||||
+10
-3
@@ -172,11 +172,16 @@ _rl_wcwidth (WCHAR_T wc)
|
||||
}
|
||||
}
|
||||
|
||||
/* Unicode combining characters range from U+0300 to U+036F */
|
||||
#define UNICODE_COMBINING_CHAR(x) ((x) >= 768 && (x) <= 879)
|
||||
/* Unicode combining characters as of version 15.1 */
|
||||
#define UNICODE_COMBINING_CHAR(x) \
|
||||
(((x) >= 0x0300 && (x) <= 0x036F) || \
|
||||
((x) >= 0x1AB0 && (x) <= 0x1AFF) || \
|
||||
((x) >= 0x1DC0 && (x) <= 0x1DFF) || \
|
||||
((x) >= 0x20D0 && (x) <= 0x20FF) || \
|
||||
((x) >= 0xFE20 && (x) <= 0xFE2F))
|
||||
|
||||
#if defined (WCWIDTH_BROKEN)
|
||||
# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR(wc)) ? 0 : _rl_wcwidth(wc))
|
||||
# define WCWIDTH(wc) ((_rl_utf8locale && UNICODE_COMBINING_CHAR((int)wc)) ? 0 : _rl_wcwidth(wc))
|
||||
#else
|
||||
# define WCWIDTH(wc) _rl_wcwidth(wc)
|
||||
#endif
|
||||
@@ -187,6 +192,8 @@ _rl_wcwidth (WCHAR_T wc)
|
||||
# define IS_COMBINING_CHAR(x) (WCWIDTH(x) == 0)
|
||||
#endif
|
||||
|
||||
#define IS_BASE_CHAR(x) (iswgraph(x) && WCWIDTH(x) > 0)
|
||||
|
||||
#define UTF8_SINGLEBYTE(c) (((c) & 0x80) == 0)
|
||||
#define UTF8_MBFIRSTCHAR(c) (((c) & 0xc0) == 0xc0)
|
||||
#define UTF8_MBCHAR(c) (((c) & 0xc0) == 0x80)
|
||||
|
||||
Reference in New Issue
Block a user