diff options
author | Michael Widenius <monty@askmonty.org> | 2013-03-26 00:03:13 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-03-26 00:03:13 +0200 |
commit | 068c61978e3a81836d52b8caf11e044290159ad1 (patch) | |
tree | 2cbca861ab2cebe3bd99379ca9668bb483ca0d2a /strings | |
parent | 35bc8f9f4353b64da215e52ff6f1612a8ce66f43 (diff) | |
download | mariadb-git-068c61978e3a81836d52b8caf11e044290159ad1.tar.gz |
Temporary commit of 10.0-merge
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-big5.c | 4 | ||||
-rw-r--r-- | strings/ctype-bin.c | 10 | ||||
-rw-r--r-- | strings/ctype-gbk.c | 4 | ||||
-rw-r--r-- | strings/ctype-mb.c | 6 | ||||
-rw-r--r-- | strings/ctype-simple.c | 8 | ||||
-rw-r--r-- | strings/ctype-tis620.c | 4 | ||||
-rw-r--r-- | strings/ctype-uca.c | 2 | ||||
-rw-r--r-- | strings/ctype-ucs2.c | 10 | ||||
-rw-r--r-- | strings/ctype-utf8.c | 4 | ||||
-rw-r--r-- | strings/ctype.c | 141 | ||||
-rw-r--r-- | strings/decimal.c | 48 | ||||
-rw-r--r-- | strings/dtoa.c | 6 | ||||
-rw-r--r-- | strings/my_vsnprintf.c | 10 | ||||
-rw-r--r-- | strings/str2int.c | 2 |
14 files changed, 200 insertions, 59 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 7c7d8c7b2f5..f77e705525c 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -870,7 +870,7 @@ static int my_strnncoll_big5(CHARSET_INFO *cs __attribute__((unused)), const uchar *b, size_t b_length, my_bool b_is_prefix) { - size_t length= min(a_length, b_length); + size_t length= MY_MIN(a_length, b_length); int res= my_strnncoll_big5_internal(&a, &b, length); return res ? res : (int)((b_is_prefix ? length : a_length) - b_length); } @@ -883,7 +883,7 @@ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)), const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { - size_t length= min(a_length, b_length); + size_t length= MY_MIN(a_length, b_length); int res= my_strnncoll_big5_internal(&a, &b, length); #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index d28d576c661..80ed047ebf2 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -80,7 +80,7 @@ static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), const uchar *t, size_t tlen, my_bool t_is_prefix) { - size_t len=min(slen,tlen); + size_t len=MY_MIN(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen); } @@ -131,7 +131,7 @@ static int my_strnncoll_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), const uchar *t, size_t tlen, my_bool t_is_prefix) { - size_t len=min(slen,tlen); + size_t len=MY_MIN(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen); } @@ -175,7 +175,7 @@ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), diff_if_only_endspace_difference= 0; #endif - end= a + (length= min(a_length, b_length)); + end= a + (length= MY_MIN(a_length, b_length)); while (a < end) { if (*a++ != *b++) @@ -401,7 +401,7 @@ static size_t my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), const uchar *src, size_t srclen) { if (dest != src) - memcpy(dest, src, min(dstlen,srclen)); + memcpy(dest, src, MY_MIN(dstlen,srclen)); if (dstlen > srclen) bfill(dest + srclen, dstlen - srclen, 0); return dstlen; @@ -414,7 +414,7 @@ size_t my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), const uchar *src, size_t srclen) { if (dest != src) - memcpy(dest, src, min(dstlen,srclen)); + memcpy(dest, src, MY_MIN(dstlen,srclen)); if (dstlen > srclen) bfill(dest + srclen, dstlen - srclen, ' '); return dstlen; diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 8b37de4a5e7..e21c406d2a9 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -3470,7 +3470,7 @@ int my_strnncoll_gbk(CHARSET_INFO *cs __attribute__((unused)), const uchar *b, size_t b_length, my_bool b_is_prefix) { - size_t length= min(a_length, b_length); + size_t length= MY_MIN(a_length, b_length); int res= my_strnncoll_gbk_internal(&a, &b, length); return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length); } @@ -3481,7 +3481,7 @@ static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)), const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { - size_t length= min(a_length, b_length); + size_t length= MY_MIN(a_length, b_length); int res= my_strnncoll_gbk_internal(&a, &b, length); #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 5879bdf7978..5efc6348516 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -473,7 +473,7 @@ my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), const uchar *t, size_t tlen, my_bool t_is_prefix) { - size_t len=min(slen,tlen); + size_t len=MY_MIN(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen); } @@ -518,7 +518,7 @@ my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), diff_if_only_endspace_difference= 0; #endif - end= a + (length= min(a_length, b_length)); + end= a + (length= MY_MIN(a_length, b_length)); while (a < end) { if (*a++ != *b++) @@ -557,7 +557,7 @@ static size_t my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)), const uchar *src, size_t srclen) { if (dest != src) - memcpy(dest, src, min(dstlen, srclen)); + memcpy(dest, src, MY_MIN(dstlen, srclen)); if (dstlen > srclen) bfill(dest + srclen, dstlen - srclen, ' '); return dstlen; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index e25c0783abf..4b47996e315 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -160,7 +160,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, size_t a_length, diff_if_only_endspace_difference= 0; #endif - end= a + (length= min(a_length, b_length)); + end= a + (length= MY_MIN(a_length, b_length)); while (a < end) { if (map[*a++] != map[*b++]) @@ -770,7 +770,7 @@ size_t my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), val= new_val; } - len= min(len, (size_t) (e-p)); + len= MY_MIN(len, (size_t) (e-p)); memcpy(dst, p, len); return len+sign; } @@ -824,7 +824,7 @@ size_t my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), long_val= quo; } - len= min(len, (size_t) (e-p)); + len= MY_MIN(len, (size_t) (e-p)); cnv: memcpy(dst, p, len); return len+sign; @@ -1055,7 +1055,7 @@ size_t my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), { size_t nbytes= (size_t) (end-start); *error= 0; - return min(nbytes, nchars); + return MY_MIN(nbytes, nchars); } diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index d97f8e5ff08..d84d43a67bd 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -566,7 +566,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), a_length= thai2sortable(a, a_length); b_length= thai2sortable(b, b_length); - end= a + (length= min(a_length, b_length)); + end= a + (length= MY_MIN(a_length, b_length)); while (a < end) { if (*a++ != *b++) @@ -623,7 +623,7 @@ size_t my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), const uchar *src, size_t srclen) { size_t dstlen= len; - len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) - + len= (size_t) (strmake((char*) dest, (char*) src, MY_MIN(len, srclen)) - (char*) dest); len= thai2sortable(dest, len); if (dstlen > len) diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index e4a8d7a4067..5feeb661d2a 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -7726,7 +7726,7 @@ static void my_coll_lexem_print_error(MY_COLL_LEXEM *lexem, { char tail[30]; size_t len= lexem->end - lexem->prev; - strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1)); + strmake (tail, lexem->prev, (size_t) MY_MIN(len, sizeof(tail)-1)); errstr[errsize-1]= '\0'; my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail); } diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 6ebbae8fb5a..8e9b0ab7a04 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -58,7 +58,7 @@ my_bincmp(const uchar *s, const uchar *se, const uchar *t, const uchar *te) { int slen= (int) (se - s), tlen= (int) (te - t); - int len= min(slen, tlen); + int len= MY_MIN(slen, tlen); int cmp= memcmp(s, t, len); return cmp ? cmp : slen - tlen; } @@ -2433,7 +2433,7 @@ my_strnncollsp_utf32_bin(CHARSET_INFO *cs __attribute__((unused)), se= s + slen; te= t + tlen; - for (minlen= min(slen, tlen); minlen; minlen-= 4) + for (minlen= MY_MIN(slen, tlen); minlen; minlen-= 4) { my_wc_t s_wc= my_utf32_get(s); my_wc_t t_wc= my_utf32_get(t); @@ -2860,7 +2860,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), se= s + slen; te= t + tlen; - for (minlen= min(slen, tlen); minlen; minlen-= 2) + for (minlen= MY_MIN(slen, tlen); minlen; minlen-= 2) { int s_wc = uni_plane[s[0]] ? (int) uni_plane[s[0]][s[1]].sort : (((int) s[0]) << 8) + (int) s[1]; @@ -2937,7 +2937,7 @@ size_t my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1; *error= 0; nchars*= 2; - return min(nbytes, nchars); + return MY_MIN(nbytes, nchars); } @@ -3012,7 +3012,7 @@ static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), se= s + slen; te= t + tlen; - for (minlen= min(slen, tlen); minlen; minlen-= 2) + for (minlen= MY_MIN(slen, tlen); minlen; minlen-= 2) { int s_wc= s[0] * 256 + s[1]; int t_wc= t[0] * 256 + t[1]; diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 88bab1fac76..6020f9c962f 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2244,7 +2244,7 @@ static inline int bincmp(const uchar *s, const uchar *se, const uchar *t, const uchar *te) { int slen= (int) (se-s), tlen= (int) (te-t); - int len=min(slen,tlen); + int len=MY_MIN(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : slen-tlen; } @@ -4667,7 +4667,7 @@ bincmp_utf8mb4(const uchar *s, const uchar *se, const uchar *t, const uchar *te) { int slen= (int) (se - s), tlen= (int) (te - t); - int len= min(slen, tlen); + int len= MY_MIN(slen, tlen); int cmp= memcmp(s, t, len); return cmp ? cmp : slen - tlen; } diff --git a/strings/ctype.c b/strings/ctype.c index 6b6983ada60..adff69ad680 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -428,3 +428,144 @@ my_charset_is_ascii_compatible(CHARSET_INFO *cs) } return 1; } + + +/* + Convert a string between two character sets. + 'to' must be large enough to store (form_length * to_cs->mbmaxlen) bytes. + + @param to[OUT] Store result here + @param to_length Size of "to" buffer + @param to_cs Character set of result string + @param from Copy from here + @param from_length Length of the "from" string + @param from_cs Character set of the "from" string + @param errors[OUT] Number of conversion errors + + @return Number of bytes copied to 'to' string +*/ + +static uint32 +my_convert_internal(char *to, uint32 to_length, + const CHARSET_INFO *to_cs, + const char *from, uint32 from_length, + const CHARSET_INFO *from_cs, uint *errors) +{ + int cnvres; + my_wc_t wc; + const uchar *from_end= (const uchar*) from + from_length; + char *to_start= to; + uchar *to_end= (uchar*) to + to_length; + my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc; + my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb; + uint error_count= 0; + + while (1) + { + if ((cnvres= (*mb_wc)(from_cs, &wc, (uchar*) from, from_end)) > 0) + from+= cnvres; + else if (cnvres == MY_CS_ILSEQ) + { + error_count++; + from++; + wc= '?'; + } + else if (cnvres > MY_CS_TOOSMALL) + { + /* + A correct multibyte sequence detected + But it doesn't have Unicode mapping. + */ + error_count++; + from+= (-cnvres); + wc= '?'; + } + else + break; // Not enough characters + +outp: + if ((cnvres= (*wc_mb)(to_cs, wc, (uchar*) to, to_end)) > 0) + to+= cnvres; + else if (cnvres == MY_CS_ILUNI && wc != '?') + { + error_count++; + wc= '?'; + goto outp; + } + else + break; + } + *errors= error_count; + return (uint32) (to - to_start); +} + + +/* + Convert a string between two character sets. + Optimized for quick copying of ASCII characters in the range 0x00..0x7F. + 'to' must be large enough to store (form_length * to_cs->mbmaxlen) bytes. + + @param to[OUT] Store result here + @param to_length Size of "to" buffer + @param to_cs Character set of result string + @param from Copy from here + @param from_length Length of the "from" string + @param from_cs Character set of the "from" string + @param errors[OUT] Number of conversion errors + + @return Number of bytes copied to 'to' string +*/ + +uint32 +my_convert(char *to, uint32 to_length, const CHARSET_INFO *to_cs, + const char *from, uint32 from_length, + const CHARSET_INFO *from_cs, uint *errors) +{ + uint32 length, length2; + /* + If any of the character sets is not ASCII compatible, + immediately switch to slow mb_wc->wc_mb method. + */ + if ((to_cs->state | from_cs->state) & MY_CS_NONASCII) + return my_convert_internal(to, to_length, to_cs, + from, from_length, from_cs, errors); + + length= length2= MY_MIN(to_length, from_length); + +#if defined(__i386__) + /* + Special loop for i386, it allows to refer to a + non-aligned memory block as UINT32, which makes + it possible to copy four bytes at once. This + gives about 10% performance improvement comparing + to byte-by-byte loop. + */ + for ( ; length >= 4; length-= 4, from+= 4, to+= 4) + { + if ((*(uint32*)from) & 0x80808080) + break; + *((uint32*) to)= *((const uint32*) from); + } +#endif /* __i386__ */ + + for (; ; *to++= *from++, length--) + { + if (!length) + { + *errors= 0; + return length2; + } + if (*((unsigned char*) from) > 0x7F) /* A non-ASCII character */ + { + uint32 copied_length= length2 - length; + to_length-= copied_length; + from_length-= copied_length; + return copied_length + my_convert_internal(to, to_length, to_cs, + from, from_length, from_cs, + errors); + } + } + + DBUG_ASSERT(FALSE); // Should never get to here + return 0; // Make compiler happy +} diff --git a/strings/decimal.c b/strings/decimal.c index f318a234d3f..75d72890557 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -396,7 +396,7 @@ int decimal2string(const decimal_t *from, char *to, int *to_len, for (; frac>0; frac-=DIG_PER_DEC1) { dec1 x=*buf++; - for (i=min(frac, DIG_PER_DEC1); i; i--) + for (i=MY_MIN(frac, DIG_PER_DEC1); i; i--) { dec1 y=x/DIG_MASK; *s1++='0'+(uchar)y; @@ -419,7 +419,7 @@ int decimal2string(const decimal_t *from, char *to, int *to_len, for (buf=buf0+ROUND_UP(intg); intg>0; intg-=DIG_PER_DEC1) { dec1 x=*--buf; - for (i=min(intg, DIG_PER_DEC1); i; i--) + for (i=MY_MIN(intg, DIG_PER_DEC1); i; i--) { dec1 y=x/10; *--s='0'+(uchar)(x-y*10); @@ -1511,8 +1511,8 @@ decimal_round(const decimal_t *from, decimal_t *to, int scale, if (to != from) { - dec1 *p0= buf0+intg0+max(frac1, frac0); - dec1 *p1= buf1+intg0+max(frac1, frac0); + dec1 *p0= buf0+intg0+MY_MAX(frac1, frac0); + dec1 *p1= buf1+intg0+MY_MAX(frac1, frac0); DBUG_ASSERT(p0 - buf0 <= len); DBUG_ASSERT(p1 - buf1 <= len); @@ -1523,7 +1523,7 @@ decimal_round(const decimal_t *from, decimal_t *to, int scale, buf0=to->buf; buf1=to->buf; to->sign=from->sign; - to->intg=min(intg0, len)*DIG_PER_DEC1; + to->intg=MY_MIN(intg0, len)*DIG_PER_DEC1; } if (frac0 > frac1) @@ -1625,7 +1625,7 @@ decimal_round(const decimal_t *from, decimal_t *to, int scale, scale=frac0*DIG_PER_DEC1; error=E_DEC_TRUNCATED; /* XXX */ } - for (buf1=to->buf+intg0+max(frac0,0); buf1 > to->buf; buf1--) + for (buf1=to->buf+intg0+MY_MAX(frac0,0); buf1 > to->buf; buf1--) { buf1[0]=buf1[-1]; } @@ -1644,7 +1644,7 @@ decimal_round(const decimal_t *from, decimal_t *to, int scale, /* making 'zero' with the proper scale */ dec1 *p0= to->buf + frac0 + 1; to->intg=1; - to->frac= max(scale, 0); + to->frac= MY_MAX(scale, 0); to->sign= 0; for (buf1= to->buf; buf1<p0; buf1++) *buf1= 0; @@ -1693,11 +1693,11 @@ int decimal_result_size(decimal_t *from1, decimal_t *from2, char op, int param) { switch (op) { case '-': - return ROUND_UP(max(from1->intg, from2->intg)) + - ROUND_UP(max(from1->frac, from2->frac)); + return ROUND_UP(MY_MAX(from1->intg, from2->intg)) + + ROUND_UP(MY_MAX(from1->frac, from2->frac)); case '+': - return ROUND_UP(max(from1->intg, from2->intg)+1) + - ROUND_UP(max(from1->frac, from2->frac)); + return ROUND_UP(MY_MAX(from1->intg, from2->intg)+1) + + ROUND_UP(MY_MAX(from1->frac, from2->frac)); case '*': return ROUND_UP(from1->intg+from2->intg)+ ROUND_UP(from1->frac)+ROUND_UP(from2->frac); @@ -1712,7 +1712,7 @@ static int do_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to) { int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg), frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac), - frac0=max(frac1, frac2), intg0=max(intg1, intg2), error; + frac0=MY_MAX(frac1, frac2), intg0=MY_MAX(intg1, intg2), error; dec1 *buf1, *buf2, *buf0, *stop, *stop2, x, carry; sanity(to); @@ -1737,7 +1737,7 @@ static int do_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to) buf0=to->buf+intg0+frac0; to->sign=from1->sign; - to->frac=max(from1->frac, from2->frac); + to->frac=MY_MAX(from1->frac, from2->frac); to->intg=intg0*DIG_PER_DEC1; if (unlikely(error)) { @@ -1748,7 +1748,7 @@ static int do_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to) set_if_smaller(intg2, intg0); } - /* part 1 - max(frac) ... min (frac) */ + /* part 1 - MY_MAX(frac) ... min (frac) */ if (frac1 > frac2) { buf1=from1->buf+intg1+frac1; @@ -1766,14 +1766,14 @@ static int do_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to) while (buf1 > stop) *--buf0=*--buf1; - /* part 2 - min(frac) ... min(intg) */ + /* part 2 - MY_MIN(frac) ... MY_MIN(intg) */ carry=0; while (buf1 > stop2) { ADD(*--buf0, *--buf1, *--buf2, carry); } - /* part 3 - min(intg) ... max(intg) */ + /* part 3 - MY_MIN(intg) ... MY_MAX(intg) */ buf1= intg1 > intg2 ? ((stop=from1->buf)+intg1-intg2) : ((stop=from2->buf)+intg2-intg1) ; while (buf1 > stop) @@ -1794,7 +1794,7 @@ static int do_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to) { int intg1=ROUND_UP(from1->intg), intg2=ROUND_UP(from2->intg), frac1=ROUND_UP(from1->frac), frac2=ROUND_UP(from2->frac); - int frac0=max(frac1, frac2), error; + int frac0=MY_MAX(frac1, frac2), error; dec1 *buf1, *buf2, *buf0, *stop1, *stop2, *start1, *start2; my_bool carry=0; @@ -1870,7 +1870,7 @@ static int do_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to) FIX_INTG_FRAC_ERROR(to->len, intg1, frac0, error); buf0=to->buf+intg1+frac0; - to->frac=max(from1->frac, from2->frac); + to->frac=MY_MAX(from1->frac, from2->frac); to->intg=intg1*DIG_PER_DEC1; if (unlikely(error)) { @@ -1881,7 +1881,7 @@ static int do_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to) } carry=0; - /* part 1 - max(frac) ... min (frac) */ + /* part 1 - MY_MAX(frac) ... min (frac) */ if (frac1 > frac2) { buf1=start1+intg1+frac1; @@ -1905,7 +1905,7 @@ static int do_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to) } } - /* part 2 - min(frac) ... intg2 */ + /* part 2 - MY_MIN(frac) ... intg2 */ while (buf2 > start2) { SUB(*--buf0, *--buf1, *--buf2, carry); @@ -2168,11 +2168,11 @@ static int do_div_mod(const decimal_t *from1, const decimal_t *from2, { /* we're calculating N1 % N2. The result will have - frac=max(frac1, frac2), as for subtraction + frac=MY_MAX(frac1, frac2), as for subtraction intg=intg2 */ to->sign=from1->sign; - to->frac=max(from1->frac, from2->frac); + to->frac=MY_MAX(from1->frac, from2->frac); frac0=0; } else @@ -2305,7 +2305,7 @@ static int do_div_mod(const decimal_t *from1, const decimal_t *from2, /* now the result is in tmp1, it has intg=prec1-frac1 - frac=max(frac1, frac2)=to->frac + frac=MY_MAX(frac1, frac2)=to->frac */ if (dcarry) *--start1=dcarry; @@ -2343,7 +2343,7 @@ static int do_div_mod(const decimal_t *from1, const decimal_t *from2, } DBUG_ASSERT(intg0 <= ROUND_UP(from2->intg)); stop1=start1+frac0+intg0; - to->intg=min(intg0*DIG_PER_DEC1, from2->intg); + to->intg=MY_MIN(intg0*DIG_PER_DEC1, from2->intg); } if (unlikely(intg0+frac0 > to->len)) { diff --git a/strings/dtoa.c b/strings/dtoa.c index 6b216056f66..f3498a7bb1e 100644 --- a/strings/dtoa.c +++ b/strings/dtoa.c @@ -132,7 +132,7 @@ size_t my_fcvt(double x, int precision, char *to, my_bool *error) if (len <= decpt) *dst++= '.'; - for (i= precision - max(0, (len - decpt)); i > 0; i--) + for (i= precision - MY_MAX(0, (len - decpt)); i > 0; i--) *dst++= '0'; } @@ -221,7 +221,7 @@ size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to, if (x < 0.) width--; - res= dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : min(width, FLT_DIG), + res= dtoa(x, 4, type == MY_GCVT_ARG_DOUBLE ? width : MY_MIN(width, FLT_DIG), &decpt, &sign, &end, buf, sizeof(buf)); if (decpt == DTOA_OVERFLOW) { @@ -2182,7 +2182,7 @@ static char *dtoa(double dd, int mode, int ndigits, int *decpt, int *sign, 1 ==> like 0, but with Steele & White stopping rule; e.g. with IEEE P754 arithmetic , mode 0 gives 1e23 whereas mode 1 gives 9.999999999999999e22. - 2 ==> max(1,ndigits) significant digits. This gives a + 2 ==> MY_MAX(1,ndigits) significant digits. This gives a return value similar to that of ecvt, except that trailing zeros are suppressed. 3 ==> through ndigits past the decimal point. This diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 2073d5a93d9..a05f60decf9 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -96,7 +96,7 @@ static const char *get_length_arg(const char *fmt, ARGS_INFO *args_arr, uint *arg_count, size_t *length, uint *flags) { fmt= get_length(fmt+1, length, flags); - *arg_count= max(*arg_count, (uint) *length); + *arg_count= MY_MAX(*arg_count, (uint) *length); (*length)--; DBUG_ASSERT(*fmt == '$' && *length < MAX_ARGS); args_arr[*length].arg_type= 'd'; @@ -243,7 +243,7 @@ static char *process_dbl_arg(char *to, char *end, size_t width, width= FLT_DIG; /* width not set, use default */ else if (width >= NOT_FIXED_DEC) width= NOT_FIXED_DEC - 1; /* max.precision for my_fcvt() */ - width= min(width, (size_t)(end-to) - 1); + width= MY_MIN(width, (size_t)(end-to) - 1); if (arg_type == 'f') to+= my_fcvt(par, (int)width , to, NULL); @@ -292,7 +292,7 @@ static char *process_int_arg(char *to, const char *end, size_t length, /* If %#d syntax was used, we have to pre-zero/pre-space the string */ if (store_start == buff) { - length= min(length, to_length); + length= MY_MIN(length, to_length); if (res_length < length) { size_t diff= (length- res_length); @@ -512,7 +512,7 @@ start: break; /* Copy data after the % format expression until next % */ - length= min(end - to , print_arr[i].end - print_arr[i].begin); + length= MY_MIN(end - to , print_arr[i].end - print_arr[i].begin); if (to + length < end) length++; to= strnmov(to, print_arr[i].begin, length); @@ -533,7 +533,7 @@ start: fmt= get_length(fmt, &arg_index, &unused_flags); DBUG_ASSERT(*fmt == '$'); fmt++; - arg_count= max(arg_count, arg_index); + arg_count= MY_MAX(arg_count, arg_index); goto start; } diff --git a/strings/str2int.c b/strings/str2int.c index 64d4e169891..ec89503af5e 100644 --- a/strings/str2int.c +++ b/strings/str2int.c @@ -94,7 +94,7 @@ char *str2int(register const char *src, register int radix, long int lower, machines all, if +|n| is representable, so is -|n|, but on twos complement machines the converse is not true. So the "maximum" representable number has a negative representative. - Limit is set to min(-|lower|,-|upper|); this is the "largest" + Limit is set to MY_MIN(-|lower|,-|upper|); this is the "largest" number we are concerned with. */ /* Calculate Limit using Scale as a scratch variable */ |