summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-04-15 15:09:22 +0200
committerSergei Golubchik <sergii@pisem.net>2013-04-15 15:09:22 +0200
commita9035be5b7a7b3865ddb4ef34a5d0cfc65dfc254 (patch)
treea9df7341e91623f62fe37cd47fce139d8888fc95 /strings
parent3a1c91d87d69ef243b3e78be6089102cafef0a8e (diff)
parentf57ecb7786177e0af3b1e3ec94302720b2e0f967 (diff)
downloadmariadb-git-a9035be5b7a7b3865ddb4ef34a5d0cfc65dfc254.tar.gz
10.0-base merge
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-latin1.c11
-rw-r--r--strings/ctype-ucs2.c10
-rw-r--r--strings/ctype-utf8.c71
-rw-r--r--strings/decimal.c10
-rw-r--r--strings/my_strtoll10.c10
5 files changed, 55 insertions, 57 deletions
diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c
index fd327925fb8..f8455344498 100644
--- a/strings/ctype-latin1.c
+++ b/strings/ctype-latin1.c
@@ -364,9 +364,14 @@ int my_mb_wc_latin1(CHARSET_INFO *cs __attribute__((unused)),
{
if (str >= end)
return MY_CS_TOOSMALL;
-
- *wc=cs_to_uni[*str];
- return (!wc[0] && str[0]) ? -1 : 1;
+ /*
+ There are no unassigned characters in latin1.
+ Every code point in latin1 is mapped to some Unicode code point.
+ We can always return 1, no needs to check the value of cs_to_uni[*str].
+ */
+ *wc= cs_to_uni[*str];
+ DBUG_ASSERT(wc[0] || !str[0]);
+ return 1;
}
static
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index fa43f36fb84..edb42862e50 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2003, 2012, Oracle and/or its affiliates
- Copyright (c) 2009, 2011, Monty Program Ab
+ Copyright (c) 2009, 2013, Monty Program Ab.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -40,11 +40,11 @@
#undef ULONGLONG_MAX
#define ULONGLONG_MAX (~(ulonglong) 0)
-#define MAX_NEGATIVE_NUMBER ((ulonglong) LL(0x8000000000000000))
+#define MAX_NEGATIVE_NUMBER ((ulonglong) 0x8000000000000000LL)
#define INIT_CNT 9
-#define LFACTOR ULL(1000000000)
-#define LFACTOR1 ULL(10000000000)
-#define LFACTOR2 ULL(100000000000)
+#define LFACTOR 1000000000ULL
+#define LFACTOR1 10000000000ULL
+#define LFACTOR2 100000000000ULL
#if defined(HAVE_CHARSET_utf32) || defined(HAVE_CHARSET_mb2)
static unsigned long lfactor[9]=
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 88bab1fac76..b96ca0e5bbe 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -2404,46 +2404,33 @@ static int my_utf8_uni_no_range(CHARSET_INFO *cs __attribute__((unused)),
static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)),
my_wc_t wc, uchar *r, uchar *e)
{
- int count;
-
- if (r >= e)
- return MY_CS_TOOSMALL;
-
if (wc < 0x80)
- count = 1;
- else if (wc < 0x800)
- count = 2;
- else if (wc < 0x10000)
- count = 3;
-#ifdef UNICODE_32BIT
- else if (wc < 0x200000)
- count = 4;
- else if (wc < 0x4000000)
- count = 5;
- else if (wc <= 0x7fffffff)
- count = 6;
-#endif
- else return MY_CS_ILUNI;
-
- /*
- e is a character after the string r, not the last character of it.
- Because of it (r+count > e), not (r+count-1 >e )
- */
- if ( r+count > e )
- return MY_CS_TOOSMALLN(count);
-
- switch (count) {
- /* Fall through all cases!!! */
-#ifdef UNICODE_32BIT
- case 6: r[5] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x4000000;
- case 5: r[4] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x200000;
- case 4: r[3] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x10000;
-#endif
- case 3: r[2] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x800;
- case 2: r[1] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0xc0;
- case 1: r[0] = (uchar) wc;
+ {
+ if (r >= e)
+ return MY_CS_TOOSMALL;
+ *r= (uchar) wc;
+ return 1;
}
- return count;
+ if (wc < 0x800)
+ {
+ if (r + 2 > e)
+ return MY_CS_TOOSMALLN(2);
+ /* U+0080..U+07FF: 00000xxx.xxyyyyyy -> 110xxxxx 10yyyyyy */
+ *r++= (uchar) (0xC0 | (wc >> 6));
+ *r= (uchar) (0x80 | (wc & 0x3F));
+ return 2;
+ }
+ if (wc < 0x10000)
+ {
+ if (r + 3 > e)
+ return MY_CS_TOOSMALLN(3);
+ /* U+0800..U+FFFF: xxxxyyyy.yyzzzzzz -> 1110xxxx 10yyyyyy 10zzzzzz */
+ *r++= (uchar) (0xE0 | (wc >> 12));
+ *r++= (uchar) (0x80 | ((wc >> 6) & 0x3f));
+ *r= (uchar) (0x80 | (wc & 0x3f));
+ return 3;
+ }
+ return MY_CS_ILUNI;
}
@@ -4353,6 +4340,10 @@ static const char filename_safe_char[128]=
#define MY_FILENAME_ESCAPE '@'
+/*
+ note, that we cannot trust 'e' here, it's may be fake,
+ see strconvert()
+*/
static int
my_mb_wc_filename(CHARSET_INFO *cs __attribute__((unused)),
my_wc_t *pwc, const uchar *s, const uchar *e)
@@ -4374,7 +4365,7 @@ my_mb_wc_filename(CHARSET_INFO *cs __attribute__((unused)),
return MY_CS_TOOSMALL3;
byte1= s[1];
- byte2= s[2];
+ byte2= byte1 ? s[2] : 0;
if (byte1 >= 0x30 && byte1 <= 0x7F &&
byte2 >= 0x30 && byte2 <= 0x7F)
@@ -4399,7 +4390,7 @@ my_mb_wc_filename(CHARSET_INFO *cs __attribute__((unused)),
(byte2= hexlo(byte2)) >= 0)
{
int byte3= hexlo(s[3]);
- int byte4= hexlo(s[4]);
+ int byte4= hexlo(s[3] ? s[4] : 0);
if (byte3 >=0 && byte4 >=0)
{
*pwc= (byte1 << 12) + (byte2 << 8) + (byte3 << 4) + byte4;
diff --git a/strings/decimal.c b/strings/decimal.c
index f318a234d3f..edff4c02885 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
- Copyright (c) 2009, 2011, Monty Program Ab
+ Copyright (c) 2009, 2013, Monty Program Ab
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -669,7 +669,7 @@ int decimal_shift(decimal_t *dec, int shift)
if (do_left)
{
do_mini_left_shift(dec, l_mini_shift, beg, end);
- mini_shift=- l_mini_shift;
+ mini_shift= -l_mini_shift;
}
else
{
@@ -1032,7 +1032,7 @@ int decimal2ulonglong(const decimal_t *from, ulonglong *to)
if (from->sign)
{
- *to=ULL(0);
+ *to= 0;
return E_DEC_OVERFLOW;
}
@@ -1445,7 +1445,9 @@ int decimal_bin_size(int precision, int scale)
intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
- DBUG_ASSERT(scale >= 0 && precision > 0 && scale <= precision);
+ DBUG_ASSERT(scale >= 0);
+ DBUG_ASSERT(precision > 0);
+ DBUG_ASSERT(scale <= precision);
return intg0*sizeof(dec1)+dig2bytes[intg0x]+
frac0*sizeof(dec1)+dig2bytes[frac0x];
}
diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c
index 48d548242a8..7130f6253a8 100644
--- a/strings/my_strtoll10.c
+++ b/strings/my_strtoll10.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2003 TXT DataKonsult Ab
- Copyright (c) 2009-2011, Monty Program Ab
+ Copyright (c) 2009, 2013, Monty Program Ab.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -29,11 +29,11 @@
#include "strings_def.h"
#include <my_sys.h> /* Needed for MY_ERRNO_ERANGE */
-#define MAX_NEGATIVE_NUMBER ((ulonglong) LL(0x8000000000000000))
+#define MAX_NEGATIVE_NUMBER ((ulonglong) 0x8000000000000000ULL)
#define INIT_CNT 9
-#define LFACTOR ULL(1000000000)
-#define LFACTOR1 ULL(10000000000)
-#define LFACTOR2 ULL(100000000000)
+#define LFACTOR 1000000000ULL
+#define LFACTOR1 10000000000ULL
+#define LFACTOR2 100000000000ULL
static unsigned long lfactor[9]=
{