summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2005-04-06 11:53:15 +0500
committerunknown <bar@mysql.com>2005-04-06 11:53:15 +0500
commit5687fe36bf21add03b96871215c58bd2e12a4666 (patch)
treee7ff1b9199a6be79542bbe6fbdf4588d1e054d48 /strings
parent81125bc8ceb2de09fb0db1851ca80edb45b290e2 (diff)
downloadmariadb-git-5687fe36bf21add03b96871215c58bd2e12a4666.tar.gz
Adding a new parameter for well_formed_length to
return error. We'll use it for better warnign reporting.
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-big5.c6
-rw-r--r--strings/ctype-mb.c9
-rw-r--r--strings/ctype-simple.c6
-rw-r--r--strings/ctype-sjis.c5
-rw-r--r--strings/ctype-ucs2.c6
-rw-r--r--strings/ctype-ujis.c13
6 files changed, 32 insertions, 13 deletions
diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c
index e083d1371ec..07b30205f89 100644
--- a/strings/ctype-big5.c
+++ b/strings/ctype-big5.c
@@ -6278,10 +6278,13 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
*/
static
uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)),
- const char *b, const char *e, uint pos)
+ const char *b, const char *e,
+ uint pos, int *error)
{
const char *b0= b;
const char *emb= e - 1; /* Last possible end of an MB character */
+
+ *error= 0;
while (pos && b < e)
{
if ((uchar) b[0] < 128)
@@ -6297,6 +6300,7 @@ uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)),
else
{
/* Wrong byte sequence */
+ *error= 1;
break;
}
}
diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c
index 6cf48291c91..dbe3a24324e 100644
--- a/strings/ctype-mb.c
+++ b/strings/ctype-mb.c
@@ -264,18 +264,21 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)),
}
-uint my_well_formed_len_mb(CHARSET_INFO *cs,
- const char *b, const char *e, uint pos)
+uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e,
+ uint pos, int *error)
{
const char *b_start= b;
-
+ *error= 0;
while (pos)
{
my_wc_t wc;
int mblen;
if ((mblen= cs->cset->mb_wc(cs, &wc, (uchar*) b, (uchar*) e)) <= 0)
+ {
+ *error= 1;
break;
+ }
b+= mblen;
pos--;
}
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 080e0b780b7..bd5131b7448 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -1093,11 +1093,11 @@ uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)),
uint my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)),
- const char *start,
- const char *end,
- uint nchars)
+ const char *start, const char *end,
+ uint nchars, int *error)
{
uint nbytes= (uint) (end-start);
+ *error= 0;
return min(nbytes, nchars);
}
diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c
index 20f0081888f..35182db3345 100644
--- a/strings/ctype-sjis.c
+++ b/strings/ctype-sjis.c
@@ -4571,9 +4571,11 @@ uint my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)),
*/
static
uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)),
- const char *b, const char *e, uint pos)
+ const char *b, const char *e,
+ uint pos, int *error)
{
const char *b0= b;
+ *error= 0;
while (pos && b < e)
{
if ((uchar) b[0] < 128)
@@ -4594,6 +4596,7 @@ uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)),
else
{
/* Wrong byte sequence */
+ *error= 1;
break;
}
}
diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c
index 9c67d1b7846..f5d0721fa9b 100644
--- a/strings/ctype-ucs2.c
+++ b/strings/ctype-ucs2.c
@@ -1267,11 +1267,11 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)),
static
uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)),
- const char *b,
- const char *e,
- uint nchars)
+ const char *b, const char *e,
+ uint nchars, int *error)
{
uint nbytes= (e-b) & ~ (uint)1;
+ *error= 0;
nchars*= 2;
return min(nbytes, nchars);
}
diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c
index fc1496df280..612dda2b3eb 100644
--- a/strings/ctype-ujis.c
+++ b/strings/ctype-ujis.c
@@ -8253,11 +8253,12 @@ my_jisx0212_uni_onechar(int code){
static
uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)),
- const char *beg, const char *end, uint pos)
+ const char *beg, const char *end,
+ uint pos, int *error)
{
const uchar *b= (uchar *) beg;
- for ( ; pos && b < (uchar*) end; pos--, b++)
+ for ( *error= 0 ; pos && b < (uchar*) end; pos--, b++)
{
char *chbeg;
uint ch= *b;
@@ -8267,12 +8268,16 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)),
chbeg= (char *) b++;
if (b >= (uchar *) end) /* need more bytes */
+ {
+ *error= 1;
return chbeg - beg; /* unexpected EOL */
+ }
if (ch == 0x8E) /* [x8E][xA0-xDF] */
{
if (*b >= 0xA0 && *b <= 0xDF)
continue;
+ *error= 1;
return chbeg - beg; /* invalid sequence */
}
@@ -8280,12 +8285,16 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)),
{
ch= *b++;
if (b >= (uchar*) end)
+ {
+ *error= 1;
return chbeg - beg; /* unexpected EOL */
+ }
}
if (ch >= 0xA1 && ch <= 0xFE &&
*b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */
continue;
+ *error= 1;
return chbeg - beg; /* invalid sequence */
}
return b - (uchar *) beg;