Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
0a83caf4
Commit
0a83caf4
authored
Mar 23, 2016
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing duplicate code: sharing implementation of "strnxfrm"
between gbk_chinese_ci and big5_chinese_ci.
parent
0d42d4e9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
68 deletions
+46
-68
strings/ctype-big5.c
strings/ctype-big5.c
+3
-35
strings/ctype-gbk.c
strings/ctype-gbk.c
+2
-33
strings/strcoll.ic
strings/strcoll.ic
+41
-0
No files found.
strings/ctype-big5.c
View file @
0a83caf4
...
...
@@ -45,8 +45,6 @@
#define isbig5code(c,d) (isbig5head(c) && isbig5tail(d))
#define big5code(c,d) (((uchar)(c) <<8) | (uchar)(d))
#define big5head(e) ((uchar)(e>>8))
#define big5tail(e) ((uchar)(e&0xff))
#define MY_FUNCTION_NAME(x) my_ ## x ## _big5
#define IS_MB1_CHAR(x) ((uchar) (x) < 0x80)
...
...
@@ -850,38 +848,6 @@ static uint16 big5strokexfrm(uint16 i)
}
static
size_t
my_strnxfrm_big5
(
CHARSET_INFO
*
cs
,
uchar
*
dst
,
size_t
dstlen
,
uint
nweights
,
const
uchar
*
src
,
size_t
srclen
,
uint
flags
)
{
uchar
*
d0
=
dst
;
uchar
*
de
=
dst
+
dstlen
;
const
uchar
*
se
=
src
+
srclen
;
const
uchar
*
sort_order
=
cs
->
sort_order
;
for
(;
dst
<
de
&&
src
<
se
&&
nweights
;
nweights
--
)
{
if
(
my_charlen
(
cs
,
(
const
char
*
)
src
,
(
const
char
*
)
se
)
>
1
)
{
/*
Note, it is safe not to check (src < se)
in the code below, because my_charlen() would
not return 2 if src was too short
*/
uint16
e
=
big5strokexfrm
((
uint16
)
big5code
(
*
src
,
*
(
src
+
1
)));
*
dst
++=
big5head
(
e
);
if
(
dst
<
de
)
*
dst
++=
big5tail
(
e
);
src
+=
2
;
}
else
*
dst
++=
sort_order
?
sort_order
[
*
src
++
]
:
*
src
++
;
}
return
my_strxfrm_pad_desc_and_reverse
(
cs
,
d0
,
dst
,
de
,
nweights
,
flags
,
0
);
}
static
uint
mbcharlen_big5
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
uint
c
)
{
return
(
isbig5head
(
c
)
?
2
:
1
);
...
...
@@ -6719,6 +6685,8 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)),
#define MY_FUNCTION_NAME(x) my_ ## x ## _big5_chinese_ci
#define WEIGHT_MB1(x) (sort_order_big5[(uchar) (x)])
#define WEIGHT_MB2(x,y) (big5code(x, y))
#define WEIGHT_MB2_FRM(x,y) (big5strokexfrm((uint16) WEIGHT_MB2(x, y)))
#define DEFINE_STRNXFRM
#include "strcoll.ic"
...
...
@@ -6733,7 +6701,7 @@ static MY_COLLATION_HANDLER my_collation_handler_big5_chinese_ci=
NULL
,
/* init */
my_strnncoll_big5_chinese_ci
,
my_strnncollsp_big5_chinese_ci
,
my_strnxfrm_big5
,
my_strnxfrm_big5
_chinese_ci
,
my_strnxfrmlen_simple
,
my_like_range_mb
,
my_wildcmp_mb
,
...
...
strings/ctype-gbk.c
View file @
0a83caf4
...
...
@@ -3451,38 +3451,6 @@ static uint16 gbksortorder(uint16 i)
}
static
size_t
my_strnxfrm_gbk
(
CHARSET_INFO
*
cs
,
uchar
*
dst
,
size_t
dstlen
,
uint
nweights
,
const
uchar
*
src
,
size_t
srclen
,
uint
flags
)
{
uchar
*
d0
=
dst
;
uchar
*
de
=
dst
+
dstlen
;
const
uchar
*
se
=
src
+
srclen
;
const
uchar
*
sort_order
=
cs
->
sort_order
;
for
(;
dst
<
de
&&
src
<
se
&&
nweights
;
nweights
--
)
{
if
(
my_charlen
(
cs
,
(
const
char
*
)
src
,
(
const
char
*
)
se
)
>
1
)
{
/*
Note, it is safe not to check (src < se)
in the code below, because my_charlen() would
not return 2 if src was too short
*/
uint16
e
=
gbksortorder
((
uint16
)
gbkcode
(
*
src
,
*
(
src
+
1
)));
*
dst
++=
gbkhead
(
e
);
if
(
dst
<
de
)
*
dst
++=
gbktail
(
e
);
src
+=
2
;
}
else
*
dst
++=
sort_order
?
sort_order
[
*
src
++
]
:
*
src
++
;
}
return
my_strxfrm_pad_desc_and_reverse
(
cs
,
d0
,
dst
,
de
,
nweights
,
flags
,
0
);
}
static
uint
mbcharlen_gbk
(
CHARSET_INFO
*
cs
__attribute__
((
unused
)),
uint
c
)
{
return
(
isgbkhead
(
c
)
?
2
:
1
);
...
...
@@ -10652,6 +10620,7 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)),
#define MY_FUNCTION_NAME(x) my_ ## x ## _gbk_chinese_ci
#define WEIGHT_MB1(x) (sort_order_gbk[(uchar) (x)])
#define WEIGHT_MB2(x,y) (gbksortorder(gbkcode(x,y)))
#define DEFINE_STRNXFRM
#include "strcoll.ic"
...
...
@@ -10666,7 +10635,7 @@ static MY_COLLATION_HANDLER my_collation_handler_gbk_chinese_ci=
NULL
,
/* init */
my_strnncoll_gbk_chinese_ci
,
my_strnncollsp_gbk_chinese_ci
,
my_strnxfrm_gbk
,
my_strnxfrm_gbk
_chinese_ci
,
my_strnxfrmlen_simple
,
my_like_range_mb
,
my_wildcmp_mb
,
...
...
strings/strcoll.ic
View file @
0a83caf4
...
...
@@ -262,6 +262,45 @@ MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)),
return 0;
}
#ifdef DEFINE_STRNXFRM
#ifndef WEIGHT_MB2_FRM
#define WEIGHT_MB2_FRM(x,y) WEIGHT_MB2(x,y)
#endif
static size_t
MY_FUNCTION_NAME(strnxfrm)(CHARSET_INFO *cs,
uchar *dst, size_t dstlen, uint nweights,
const uchar *src, size_t srclen, uint flags)
{
uchar *d0= dst;
uchar *de= dst + dstlen;
const uchar *se= src + srclen;
const uchar *sort_order= cs->sort_order;
for (; dst < de && src < se && nweights; nweights--)
{
if (my_charlen(cs, (const char *) src, (const char *) se) > 1)
{
/*
Note, it is safe not to check (src < se)
in the code below, because my_charlen() would
not return 2 if src was too short
*/
uint16 e= WEIGHT_MB2_FRM(src[0], src[1]);
*dst++= (uchar) (e >> 8);
if (dst < de)
*dst++= (uchar) (e & 0xFF);
src+= 2;
}
else
*dst++= sort_order ? sort_order[*src++] : *src++;
}
return my_strxfrm_pad_desc_and_reverse(cs, d0, dst, de, nweights, flags, 0);
}
#endif /* DEFINE_STRNXFRM */
/*
We usually include this file at least two times from the same source file,
for the _ci and the _bin collations. Prepare for the second inclusion.
...
...
@@ -273,3 +312,5 @@ MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)),
#undef WEIGHT_MB3
#undef WEIGHT_MB4
#undef WEIGHT_PAD_SPACE
#undef WEIGHT_MB2_FRM
#undef DEFINE_STRNXFRM
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment