aboutsummaryrefslogtreecommitdiff
path: root/libbb/unicode.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/unicode.c')
-rw-r--r--libbb/unicode.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/libbb/unicode.c b/libbb/unicode.c
index 79481f159..e98cbbf35 100644
--- a/libbb/unicode.c
+++ b/libbb/unicode.c
@@ -25,7 +25,7 @@ uint8_t unicode_status;
25 25
26void FAST_FUNC reinit_unicode(const char *LANG) 26void FAST_FUNC reinit_unicode(const char *LANG)
27{ 27{
28 static const char unicode_0x394[] = { 0xce, 0x94, 0 }; 28 static const char unicode_0x394[] ALIGN1 = { 0xce, 0x94, 0 };
29 size_t width; 29 size_t width;
30 30
31 /* We pass "" instead of "C" because some libc's have 31 /* We pass "" instead of "C" because some libc's have
@@ -306,8 +306,10 @@ static int in_uint16_table(unsigned ucs, const uint16_t *table, unsigned max)
306 unsigned first, last; 306 unsigned first, last;
307 307
308 first = table[0] >> 2; 308 first = table[0] >> 2;
309 last = first + (table[0] & 3); 309 if (ucs < first)
310 if (ucs < first || ucs > last) 310 return 0;
311 last = (table[max] >> 2) + (table[max] & 3);
312 if (ucs > last)
311 return 0; 313 return 0;
312 314
313 min = 0; 315 min = 0;
@@ -587,12 +589,12 @@ int FAST_FUNC wcwidth(unsigned ucs)
587 BIG_(0xFE20, 0xFE23) \ 589 BIG_(0xFE20, 0xFE23) \
588 BIG_(0xFEFF, 0xFEFF) \ 590 BIG_(0xFEFF, 0xFEFF) \
589 BIG_(0xFFF9, 0xFFFB) 591 BIG_(0xFFF9, 0xFFFB)
590 static const struct interval combining[] = { ARRAY }; 592 static const struct interval combining[] ALIGN4 = { ARRAY };
591# undef BIG_ 593# undef BIG_
592# undef PAIR 594# undef PAIR
593# define BIG_(a,b) 595# define BIG_(a,b)
594# define PAIR(a,b) (a << 2) | (b-a), 596# define PAIR(a,b) (a << 2) | (b-a),
595 static const uint16_t combining1[] = { ARRAY }; 597 static const uint16_t combining1[] ALIGN2 = { ARRAY };
596# undef BIG_ 598# undef BIG_
597# undef PAIR 599# undef PAIR
598# define BIG_(a,b) char big_##a[b < 0x4000 && b-a <= 3 ? -1 : 1]; 600# define BIG_(a,b) char big_##a[b < 0x4000 && b-a <= 3 ? -1 : 1];
@@ -646,7 +648,7 @@ int FAST_FUNC wcwidth(unsigned ucs)
646# if CONFIG_LAST_SUPPORTED_WCHAR >= 0x10000 648# if CONFIG_LAST_SUPPORTED_WCHAR >= 0x10000
647 if (ucs >= 0x10000) { 649 if (ucs >= 0x10000) {
648 /* Combining chars in Supplementary Multilingual Plane 0x1xxxx */ 650 /* Combining chars in Supplementary Multilingual Plane 0x1xxxx */
649 static const struct interval combining0x10000[] = { 651 static const struct interval combining0x10000[] ALIGN4 = {
650 { 0x0A01, 0x0A03 }, { 0x0A05, 0x0A06 }, { 0x0A0C, 0x0A0F }, 652 { 0x0A01, 0x0A03 }, { 0x0A05, 0x0A06 }, { 0x0A0C, 0x0A0F },
651 { 0x0A38, 0x0A3A }, { 0x0A3F, 0x0A3F }, { 0xD167, 0xD169 }, 653 { 0x0A38, 0x0A3A }, { 0x0A3F, 0x0A3F }, { 0xD167, 0xD169 },
652 { 0xD173, 0xD182 }, { 0xD185, 0xD18B }, { 0xD1AA, 0xD1AD }, 654 { 0xD173, 0xD182 }, { 0xD185, 0xD18B }, { 0xD1AA, 0xD1AD },
@@ -757,12 +759,12 @@ int FAST_FUNC unicode_bidi_isrtl(wint_t wc)
757 {0x10E7F, 0x10FFF}, 759 {0x10E7F, 0x10FFF},
758 {0x1E800, 0x1EFFF} 760 {0x1E800, 0x1EFFF}
759 */ 761 */
760 static const struct interval rtl_b[] = { ARRAY }; 762 static const struct interval rtl_b[] ALIGN4 = { ARRAY };
761# undef BIG_ 763# undef BIG_
762# undef PAIR 764# undef PAIR
763# define BIG_(a,b) 765# define BIG_(a,b)
764# define PAIR(a,b) (a << 2) | (b-a), 766# define PAIR(a,b) (a << 2) | (b-a),
765 static const uint16_t rtl_p[] = { ARRAY }; 767 static const uint16_t rtl_p[] ALIGN2 = { ARRAY };
766# undef BIG_ 768# undef BIG_
767# undef PAIR 769# undef PAIR
768# define BIG_(a,b) char big_##a[b < 0x4000 && b-a <= 3 ? -1 : 1]; 770# define BIG_(a,b) char big_##a[b < 0x4000 && b-a <= 3 ? -1 : 1];
@@ -961,12 +963,12 @@ int FAST_FUNC unicode_bidi_is_neutral_wchar(wint_t wc)
961 {0x1F030, 0x1F093}, 963 {0x1F030, 0x1F093},
962 {0x1F100, 0x1F10A} 964 {0x1F100, 0x1F10A}
963 */ 965 */
964 static const struct interval neutral_b[] = { ARRAY }; 966 static const struct interval neutral_b[] ALIGN4 = { ARRAY };
965# undef BIG_ 967# undef BIG_
966# undef PAIR 968# undef PAIR
967# define BIG_(a,b) 969# define BIG_(a,b)
968# define PAIR(a,b) (a << 2) | (b-a), 970# define PAIR(a,b) (a << 2) | (b-a),
969 static const uint16_t neutral_p[] = { ARRAY }; 971 static const uint16_t neutral_p[] ALIGN2 = { ARRAY };
970# undef BIG_ 972# undef BIG_
971# undef PAIR 973# undef PAIR
972# define BIG_(a,b) char big_##a[b < 0x4000 && b-a <= 3 ? -1 : 1]; 974# define BIG_(a,b) char big_##a[b < 0x4000 && b-a <= 3 ? -1 : 1];