diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-06 09:40:39 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-11-06 09:40:39 +0200 |
commit | df563e0c037f9b2cdb22e145575f92a121b4b529 (patch) | |
tree | 31d39796cebcef916eb7e0888537c18f946170ff /strings | |
parent | e058a251c10350f3727ca1df022dc5786933535b (diff) | |
parent | bdfe2784d5b73a1fdcdacb3d9adcc9dc71af344b (diff) | |
download | mariadb-git-df563e0c037f9b2cdb22e145575f92a121b4b529.tar.gz |
Merge 10.2 into 10.3
main.derived_cond_pushdown: Move all 10.3 tests to the end,
trim trailing white space, and add an "End of 10.3 tests" marker.
Add --sorted_result to tests where the ordering is not deterministic.
main.win_percentile: Add --sorted_result to tests where the
ordering is no longer deterministic.
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-simple.c | 4 | ||||
-rw-r--r-- | strings/ctype-uca.c | 116 | ||||
-rw-r--r-- | strings/ctype-utf8.c | 46 | ||||
-rw-r--r-- | strings/decimal.c | 35 |
4 files changed, 101 insertions, 100 deletions
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 518f6f9842f..aa2ea1aebbe 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -492,7 +492,6 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, register uint cutlim; register uint32 i; register const char *s; - register uchar c; const char *save, *e; int overflow; @@ -527,8 +526,9 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, overflow = 0; i = 0; - for (c = *s; s != e; c = *++s) + for ( ; s != e; ++s) { + register uchar c= *s; if (c>='0' && c<='9') c -= '0'; else if (c>='A' && c<='Z') diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 2cb4652dd0f..9efd7242118 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -32428,11 +32428,11 @@ int my_wildcmp_uca_impl(CHARSET_INFO *cs, const char *wildstr,const char *wildend, int escape, int w_one, int w_many, int recurse_level) { - int result= -1; /* Not found, using wildcards */ + int result= -1; /* Not found, using wildcards */ my_wc_t s_wc, w_wc; int scan; my_charset_conv_mb_wc mb_wc= cs->cset->mb_wc; - + if (my_string_stack_guard && my_string_stack_guard(recurse_level)) return 1; while (wildstr != wildend) @@ -32441,119 +32441,121 @@ int my_wildcmp_uca_impl(CHARSET_INFO *cs, { my_bool escaped= 0; if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, - (const uchar*)wildend)) <= 0) - return 1; + (const uchar*)wildend)) <= 0) + return 1; - if (w_wc == (my_wc_t)w_many) + if (w_wc == (my_wc_t) w_many) { - result= 1; /* Found an anchor char */ + result= 1; /* Found an anchor char */ break; } wildstr+= scan; - if (w_wc == (my_wc_t)escape) + if (w_wc == (my_wc_t) escape && wildstr < wildend) { if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, - (const uchar*)wildend)) <= 0) + (const uchar*)wildend)) <= 0) return 1; wildstr+= scan; escaped= 1; } - + if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, - (const uchar*)str_end)) <= 0) + (const uchar*)str_end)) <= 0) return 1; str+= scan; - - if (!escaped && w_wc == (my_wc_t)w_one) + + if (!escaped && w_wc == (my_wc_t) w_one) { - result= 1; /* Found an anchor char */ + result= 1; /* Found an anchor char */ } else { if (my_uca_charcmp(cs,s_wc,w_wc)) - return 1; + return 1; /* No match */ } if (wildstr == wildend) - return (str != str_end); /* Match if both are at end */ + return (str != str_end); /* Match if both are at end */ } - - - if (w_wc == (my_wc_t)w_many) - { /* Found w_many */ - + + if (w_wc == (my_wc_t) w_many) + { /* Found w_many */ /* Remove any '%' and '_' from the wild search string */ for ( ; wildstr != wildend ; ) { if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, - (const uchar*)wildend)) <= 0) + (const uchar*)wildend)) <= 0) return 1; - - if (w_wc == (my_wc_t)w_many) - { - wildstr+= scan; - continue; - } - - if (w_wc == (my_wc_t)w_one) - { - wildstr+= scan; - if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, - (const uchar*)str_end)) <= 0) + + if (w_wc == (my_wc_t) w_many) + { + wildstr+= scan; + continue; + } + + if (w_wc == (my_wc_t) w_one) + { + wildstr+= scan; + if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, + (const uchar*)str_end)) <= 0) return 1; str+= scan; - continue; - } - break; /* Not a wild character */ + continue; + } + break; /* Not a wild character */ } - + if (wildstr == wildend) - return 0; /* Ok if w_many is last */ - + return 0; /* Ok if w_many is last */ + if (str == str_end) - return -1; - + return -1; + if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, - (const uchar*)wildend)) <= 0) + (const uchar*)wildend)) <= 0) return 1; - - if (w_wc == (my_wc_t)escape) + wildstr+= scan; + + if (w_wc == (my_wc_t) escape) { - wildstr+= scan; - if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, - (const uchar*)wildend)) <= 0) - return 1; + if (wildstr < wildend) + { + if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, + (const uchar*)wildend)) <= 0) + return 1; + wildstr+= scan; + } } - + while (1) { /* Skip until the first character from wildstr is found */ while (str != str_end) { if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, - (const uchar*)str_end)) <= 0) + (const uchar*)str_end)) <= 0) return 1; - + if (!my_uca_charcmp(cs,s_wc,w_wc)) break; str+= scan; } if (str == str_end) return -1; - + + str+= scan; result= my_wildcmp_uca_impl(cs, str, str_end, wildstr, wildend, - escape, w_one, w_many, recurse_level+1); - + escape, w_one, w_many, + recurse_level + 1); if (result <= 0) return result; - - str+= scan; - } + } } } return (str != str_end ? 1 : 0); } + int my_wildcmp_uca(CHARSET_INFO *cs, const char *str,const char *str_end, const char *wildstr,const char *wildend, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index c525ee97b65..4ef376dccc8 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -4479,9 +4479,7 @@ int my_wildcmp_unicode_impl(CHARSET_INFO *cs, int result= -1; /* Not found, using wildcards */ my_wc_t s_wc, w_wc; int scan; - int (*mb_wc)(CHARSET_INFO *, my_wc_t *, - const uchar *, const uchar *); - mb_wc= cs->cset->mb_wc; + my_charset_conv_mb_wc mb_wc= cs->cset->mb_wc; if (my_string_stack_guard && my_string_stack_guard(recurse_level)) return 1; @@ -4509,12 +4507,12 @@ int my_wildcmp_unicode_impl(CHARSET_INFO *cs, wildstr+= scan; escaped= 1; } - + if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, (const uchar*)str_end)) <= 0) return 1; str+= scan; - + if (!escaped && w_wc == (my_wc_t) w_one) { result= 1; /* Found an anchor char */ @@ -4532,86 +4530,84 @@ int my_wildcmp_unicode_impl(CHARSET_INFO *cs, if (wildstr == wildend) return (str != str_end); /* Match if both are at end */ } - - + if (w_wc == (my_wc_t) w_many) { /* Found w_many */ - /* Remove any '%' and '_' from the wild search string */ for ( ; wildstr != wildend ; ) { if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, (const uchar*)wildend)) <= 0) return 1; - - if (w_wc == (my_wc_t)w_many) + + if (w_wc == (my_wc_t) w_many) { wildstr+= scan; continue; } - - if (w_wc == (my_wc_t)w_one) + + if (w_wc == (my_wc_t) w_one) { wildstr+= scan; if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, - (const uchar*)str_end)) <=0) + (const uchar*)str_end)) <= 0) return 1; str+= scan; continue; } break; /* Not a wild character */ } - + if (wildstr == wildend) return 0; /* Ok if w_many is last */ - + if (str == str_end) return -1; - + if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, - (const uchar*)wildend)) <=0) + (const uchar*)wildend)) <= 0) return 1; wildstr+= scan; - - if (w_wc == (my_wc_t)escape) + + if (w_wc == (my_wc_t) escape) { if (wildstr < wildend) { if ((scan= mb_wc(cs, &w_wc, (const uchar*)wildstr, - (const uchar*)wildend)) <=0) + (const uchar*)wildend)) <= 0) return 1; wildstr+= scan; } } - + while (1) { /* Skip until the first character from wildstr is found */ while (str != str_end) { if ((scan= mb_wc(cs, &s_wc, (const uchar*)str, - (const uchar*)str_end)) <=0) + (const uchar*)str_end)) <= 0) return 1; if (weights) { my_tosort_unicode(weights, &s_wc, cs->state); my_tosort_unicode(weights, &w_wc, cs->state); } - + if (s_wc == w_wc) break; str+= scan; } if (str == str_end) return -1; - + str+= scan; result= my_wildcmp_unicode_impl(cs, str, str_end, wildstr, wildend, escape, w_one, w_many, weights, recurse_level + 1); if (result <= 0) return result; - } + } } } return (str != str_end ? 1 : 0); diff --git a/strings/decimal.c b/strings/decimal.c index 325615147c8..9ccbdae1c6c 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -2084,26 +2084,21 @@ int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to) } } - /* Now we have to check for -0.000 case */ - if (to->sign) + /* Remove trailing zero words in frac part */ + frac0= ROUND_UP(to->frac); + + if (frac0 > 0 && to->buf[intg0 + frac0 - 1] == 0) { - dec1 *buf= to->buf; - dec1 *end= to->buf + intg0 + frac0; - DBUG_ASSERT(buf != end); - for (;;) + do { - if (*buf) - break; - if (++buf == end) - { - /* We got decimal zero */ - decimal_make_zero(to); - break; - } - } + frac0--; + } while (frac0 > 0 && to->buf[intg0 + frac0 - 1] == 0); + to->frac= DIG_PER_DEC1 * frac0; } + + /* Remove heading zero words in intg part */ buf1= to->buf; - d_to_move= intg0 + ROUND_UP(to->frac); + d_to_move= intg0 + frac0; while (!*buf1 && (to->intg > DIG_PER_DEC1)) { buf1++; @@ -2116,6 +2111,14 @@ int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to) for (; d_to_move--; cur_d++, buf1++) *cur_d= *buf1; } + + /* Now we have to check for -0.000 case */ + if (to->sign && to->frac == 0 && to->buf[0] == 0) + { + DBUG_ASSERT(to->intg <= DIG_PER_DEC1); + /* We got decimal zero */ + decimal_make_zero(to); + } return error; } |