diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2021-12-02 13:42:06 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2021-12-02 13:42:06 +0100 |
commit | 7e35c27e98eaf77398bb33705e62087572e24029 (patch) | |
tree | 655fc6723ff6f4096888b78dd0b91c7902083375 | |
parent | fde0a98b8e8a8b11c6afaae4ac4eb373e6b7d23c (diff) | |
download | mariadb-git-wlad-uca-1400.tar.gz |
Fix compiler errors, MSVCwlad-uca-1400
1. static const my_wc_t some_name = whatever;
As far as compiler is concerned, some_name is not a constant,
and can't be used where constant expression is expected, bringing
error C2099: initializer is not a constant
So, either this needs to be replaced with #defines, in C (
in C++, constexpr would be possible)
2. Fix some truncation bugs.
-rw-r--r-- | strings/ctype-uca.c | 2 | ||||
-rw-r--r-- | strings/ctype-uca1400.h | 22 | ||||
-rw-r--r-- | strings/uca-dump.c | 15 |
3 files changed, 21 insertions, 18 deletions
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 5c844589403..651ab8457fa 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -34408,7 +34408,7 @@ init_weight_level(MY_CHARSET_LOADER *loader, CHARSET_INFO *cs, for (i= 0; i != src->contractions.nitems; i++) { MY_CONTRACTION *item= &src->contractions.item[i]; - uint length= my_wstrnlen(item->ch, array_elements(item->ch)); + uint length= (uint)my_wstrnlen(item->ch, array_elements(item->ch)); uint16 *weights= my_uca_init_one_contraction(&dst->contractions, item->ch, length, item->with_context); diff --git a/strings/ctype-uca1400.h b/strings/ctype-uca1400.h index 721716b5f64..df1d3e83c6d 100644 --- a/strings/ctype-uca1400.h +++ b/strings/ctype-uca1400.h @@ -31327,40 +31327,40 @@ static MY_CONTRACTION uca1400_contractions_secondary[939]={ }; -static const uint uca1400_version= 1400; /* 14.0.0 */ +#define uca1400_version 1400 /* [.0000.0000.0000] [.0000.0000.0000] */ -static const my_wc_t uca1400_tertiary_ignorable_first= 0x0000; -static const my_wc_t uca1400_tertiary_ignorable_last= 0xE01EF; +#define uca1400_tertiary_ignorable_first 0x0000 +#define uca1400_tertiary_ignorable_last 0xE01EF /* [.0000.0000.0000] [.0000.0000.0000] */ -static const my_wc_t uca1400_secondary_ignorable_first= 0x0000; -static const my_wc_t uca1400_secondary_ignorable_last= 0xE01EF; +#define uca1400_secondary_ignorable_first 0x0000 +#define uca1400_secondary_ignorable_last 0xE01EF /* [.0000.0021.0002] [.0000.0117.0002] */ -static const my_wc_t uca1400_primary_ignorable_first= 0x0332; -static const my_wc_t uca1400_primary_ignorable_last= 0x101FD; +#define uca1400_primary_ignorable_first 0x0332 +#define uca1400_primary_ignorable_last 0x101FD /* [.0201.0020.0002] [.2017.0020.0002] */ -static const my_wc_t uca1400_variable_first= 0x0009; -static const my_wc_t uca1400_variable_last= 0x1D371; +#define uca1400_variable_first 0x0009 +#define uca1400_variable_last 0x1D371 /* [.0201.0020.0002] [.5E72.0020.0002] */ -static const my_wc_t uca1400_non_ignorable_first= 0x0009; -static const my_wc_t uca1400_non_ignorable_last= 0x14646; +#define uca1400_non_ignorable_first 0x0009 +#define uca1400_non_ignorable_last 0x14646 diff --git a/strings/uca-dump.c b/strings/uca-dump.c index 3270c39a83e..05922cf4302 100644 --- a/strings/uca-dump.c +++ b/strings/uca-dump.c @@ -19,6 +19,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <assert.h> #include "my_global.h" #include "m_ctype.h" @@ -587,11 +588,12 @@ parse_weights(MY_DUCET_WEIGHT *dst, my_bool *is_variable, char *weight) for (s= weights[w]; *s ;) { char *endptr; - size_t part; - part= strtol(s+1,&endptr,16); + ulong part; + part= strtoul(s+1,&endptr,16); if (w == 0 && s[0] == '*') *is_variable= TRUE; - dst->weight[partnum][w]= part; + assert(part <= 0xFFFF); + dst->weight[partnum][w]= (uint16)part; s= endptr; partnum++; } @@ -727,7 +729,8 @@ print_contraction_list(const MY_DUCET_CONTRACTION_LIST *src, uint level, const O int main(int ac, char **av) { char str[1024]; - size_t code, w; + size_t code; + uint w; static MY_DUCET ducet; int pageloaded[MY_UCA_NPAGES]; FILE *file; @@ -816,7 +819,7 @@ int main(int ac, char **av) for (level= 0; level < 4; level++) { MY_UCA_IMPLICIT_WEIGHT weight; - weight= my_uca_implicit_weight_on_level(ducet.version, code, level); + weight= my_uca_implicit_weight_on_level(ducet.version, (my_wc_t)code, level); ducet.single_chars[code].weight.weight[level][0]= weight.weight[0]; ducet.single_chars[code].weight.weight[level][1]= weight.weight[1]; } @@ -905,7 +908,7 @@ int main(int ac, char **av) default: mchars= ducet.single_chars[code].weight.weight_length; } - pagemaxlen[page]= maxnum; + pagemaxlen[page]= (int)maxnum; /* |