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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
aad71de1
Commit
aad71de1
authored
Apr 25, 2003
by
hf@deer.mysql.r18.ru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trimming code with Monty's suggestions
parent
8534b43f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
91 deletions
+83
-91
strings/ctype-tis620.c
strings/ctype-tis620.c
+83
-91
No files found.
strings/ctype-tis620.c
View file @
aad71de1
...
@@ -453,82 +453,78 @@ uchar NEAR sort_order_tis620[]=
...
@@ -453,82 +453,78 @@ uchar NEAR sort_order_tis620[]=
Arg: const source string and length of converted string
Arg: const source string and length of converted string
Ret: Sortable string
Ret: Sortable string
*/
*/
/*
NOTE: isn't it faster to alloc buffer in calling function?
*/
static
uchar
*
thai2sortable
(
const
uchar
*
tstr
,
uint
len
)
static
uchar
*
thai2sortable
(
const
uchar
*
tstr
,
uint
len
)
{
{
/* We use only 3 levels (neglect capitalization). */
/* We use only 3 levels (neglect capitalization). */
const
uchar
*
p
=
tstr
;
const
uchar
*
p
=
tstr
;
uchar
*
outBuf
;
uchar
*
outBuf
;
/* uchar *pRight1, *pRight2, *pRight3, *pRight4; */
/* uchar *pLeft1, *pLeft2, *pLeft3, *pLeft4; */
uchar
*
pRight1
,
*
pRight2
,
*
pRight3
;
uchar
*
pRight1
,
*
pRight2
,
*
pRight3
;
uchar
*
pLeft1
,
*
pLeft2
,
*
pLeft3
;
uchar
*
pLeft1
,
*
pLeft2
,
*
pLeft3
;
uint
bufSize
;
uint
bufSize
;
uint
RightSize
;
len
=
(
uint
)
strnlen
((
char
*
)
tstr
,
len
);
bufSize
=
(
uint
)
buffsize
((
char
*
)
tstr
);
len
=
(
uint
)
strnlen
((
char
*
)
tstr
,
len
);
if
(
!
(
pRight1
=
(
uchar
*
)
malloc
(
sizeof
(
uchar
)
*
bufSize
)))
{
bufSize
=
(
uint
)
buffsize
((
char
*
)
tstr
);
return
(
(
uchar
*
)
tstr
);
RightSize
=
sizeof
(
uchar
)
*
(
len
+
1
);
}
if
(
!
(
outBuf
=
pLeft1
=
pRight1
=
pLeft1
=
pRight1
;
(
uchar
*
)
malloc
(
sizeof
(
uchar
)
*
bufSize
+
RightSize
*
2
)))
outBuf
=
pRight1
;
return
(
uchar
*
)
tstr
;
if
(
!
(
pRight2
=
(
uchar
*
)
malloc
(
sizeof
(
uchar
)
*
(
len
+
1
))))
{
pLeft2
=
pRight2
=
pRight1
+
sizeof
(
uchar
)
*
bufSize
;
free
(
pRight1
);
pLeft3
=
pRight3
=
pRight2
+
RightSize
;
return
((
uchar
*
)
tstr
);
}
while
(
--
len
)
pLeft2
=
pRight2
;
{
if
(
!
(
pRight3
=
(
uchar
*
)
malloc
(
sizeof
(
uchar
)
*
(
len
+
1
))))
{
int
*
t_ctype0
=
t_ctype
[
p
[
0
]];
free
(
pRight1
);
if
(
isldvowel
(
*
p
)
&&
isconsnt
(
p
[
1
]))
free
(
pRight2
);
{
return
((
uchar
*
)
tstr
);
int
*
t_ctype1
=
t_ctype
[
p
[
1
]];
}
*
pRight1
++=
t_ctype1
[
0
];
pLeft3
=
pRight3
;
*
pRight2
++=
t_ctype1
[
1
];
/* if(!(pRight4 = (uchar *)malloc(sizeof(uchar) * (len + 1)))) {
*
pRight3
++=
t_ctype1
[
2
];
free(pRight1);
*
pRight1
++=
t_ctype0
[
0
];
free(pRight2);
*
pRight2
++=
t_ctype0
[
1
];
free(pRight3);
*
pRight3
++=
t_ctype0
[
2
];
return((uchar*) tstr);
p
+=
2
;
}
pLeft4 = pRight4;*/
while
(
len
--
)
{
if
(
isldvowel
(
*
p
)
&&
len
>
0
&&
isconsnt
(
p
[
1
]))
{
*
pRight1
++
=
t_ctype
[
p
[
1
]][
0
];
*
pRight2
++
=
t_ctype
[
p
[
1
]][
1
];
*
pRight3
++
=
t_ctype
[
p
[
1
]][
2
];
/* *pRight4++ = t_ctype[p[1]][3]; */
*
pRight1
++
=
t_ctype
[
*
p
][
0
];
*
pRight2
++
=
t_ctype
[
*
p
][
1
];
*
pRight3
++
=
t_ctype
[
*
p
][
2
];
/* *pRight4++ = t_ctype[*p][3]; */
len
--
;
len
--
;
p
+=
2
;
}
}
else
{
else
*
pRight1
=
t_ctype
[
*
p
][
0
];
{
if
(
*
pRight1
!=
IGNORE
)
pRight1
++
;
*
pRight1
=
t_ctype0
[
0
];
*
pRight2
=
t_ctype
[
*
p
][
1
];
if
(
*
pRight1
!=
IGNORE
)
if
(
*
pRight2
!=
IGNORE
)
pRight2
++
;
pRight1
++
;
*
pRight3
=
t_ctype
[
*
p
][
2
];
*
pRight2
=
t_ctype0
[
1
];
if
(
*
pRight3
!=
IGNORE
)
pRight3
++
;
if
(
*
pRight2
!=
IGNORE
)
/* *pRight4 = t_ctype[*p][3];
pRight2
++
;
if(*pRight4 != IGNORE) pRight4++;*/
*
pRight3
=
t_ctype0
[
2
];
if
(
*
pRight3
!=
IGNORE
)
pRight3
++
;
p
++
;
p
++
;
}
}
}
}
*
pRight1
++
=
L2_BLANK
;
if
(
!
len
)
*
pRight2
++
=
L3_BLANK
;
{
/* *pRight3++ = L4_BLANK; */
int
*
t_ctype0
=
t_ctype
[
p
[
0
]];
*
pRight3
++
=
'\0'
;
*
pRight1
=
t_ctype0
[
0
];
/* *pRight4++ = '\0'; */
if
(
*
pRight1
!=
IGNORE
)
pRight1
++
;
*
pRight2
=
t_ctype0
[
1
];
if
(
*
pRight2
!=
IGNORE
)
pRight2
++
;
*
pRight3
=
t_ctype0
[
2
];
if
(
*
pRight3
!=
IGNORE
)
pRight3
++
;
}
*
pRight1
++=
L2_BLANK
;
*
pRight2
++=
L3_BLANK
;
*
pRight3
++=
'\0'
;
memcpy
(
pRight1
,
pLeft2
,
pRight2
-
pLeft2
);
memcpy
(
pRight1
,
pLeft2
,
pRight2
-
pLeft2
);
pRight1
+=
pRight2
-
pLeft2
;
pRight1
+=
pRight2
-
pLeft2
;
memcpy
(
pRight1
,
pLeft3
,
pRight3
-
pLeft3
);
memcpy
(
pRight1
,
pLeft3
,
pRight3
-
pLeft3
);
/* pRight1 += pRight3 - pLeft3; */
return
outBuf
;
/* memcpy(pRight1, pLeft4, pRight4 - pLeft4); */
free
(
pLeft2
);
free
(
pLeft3
);
/* free(pLeft4); */
return
(
outBuf
);
}
}
/* strncoll() replacement, compare 2 string, both are conveted to sortable string
/* strncoll() replacement, compare 2 string, both are conveted to sortable string
...
@@ -539,12 +535,12 @@ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2)
...
@@ -539,12 +535,12 @@ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2)
{
{
uchar
*
tc1
,
*
tc2
;
uchar
*
tc1
,
*
tc2
;
int
i
;
int
i
;
tc1
=
thai2sortable
(
s1
,
len1
);
tc1
=
thai2sortable
(
s1
,
len1
);
tc2
=
thai2sortable
(
s2
,
len2
);
tc2
=
thai2sortable
(
s2
,
len2
);
i
=
strcmp
((
char
*
)
tc1
,
(
char
*
)
tc2
);
i
=
strcmp
((
char
*
)
tc1
,
(
char
*
)
tc2
);
free
(
tc1
);
free
(
tc1
);
free
(
tc2
);
free
(
tc2
);
return
(
i
)
;
return
i
;
}
}
/* strnxfrm replacment, convert Thai string to sortable string
/* strnxfrm replacment, convert Thai string to sortable string
...
@@ -555,12 +551,12 @@ int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen)
...
@@ -555,12 +551,12 @@ int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen)
{
{
uint
bufSize
;
uint
bufSize
;
uchar
*
tmp
;
uchar
*
tmp
;
bufSize
=
(
uint
)
buffsize
((
char
*
)
src
);
bufSize
=
(
uint
)
buffsize
((
char
*
)
src
);
tmp
=
thai2sortable
(
src
,
srclen
);
tmp
=
thai2sortable
(
src
,
srclen
);
set_if_smaller
(
bufSize
,(
uint
)
len
);
set_if_smaller
(
bufSize
,(
uint
)
len
);
memcpy
((
uchar
*
)
dest
,
tmp
,
bufSize
);
memcpy
((
uchar
*
)
dest
,
tmp
,
bufSize
);
free
(
tmp
);
free
(
tmp
);
return
(
int
)
bufSize
;
return
(
int
)
bufSize
;
}
}
/* strcoll replacment, compare 2 strings
/* strcoll replacment, compare 2 strings
...
@@ -571,12 +567,12 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2)
...
@@ -571,12 +567,12 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2)
{
{
uchar
*
tc1
,
*
tc2
;
uchar
*
tc1
,
*
tc2
;
int
i
;
int
i
;
tc1
=
thai2sortable
(
s1
,
(
uint
)
strlen
((
char
*
)
s1
));
tc1
=
thai2sortable
(
s1
,
(
uint
)
strlen
((
char
*
)
s1
));
tc2
=
thai2sortable
(
s2
,
(
uint
)
strlen
((
char
*
)
s2
));
tc2
=
thai2sortable
(
s2
,
(
uint
)
strlen
((
char
*
)
s2
));
i
=
strcmp
((
char
*
)
tc1
,
(
char
*
)
tc2
);
i
=
strcmp
((
char
*
)
tc1
,
(
char
*
)
tc2
);
free
(
tc1
);
free
(
tc1
);
free
(
tc2
);
free
(
tc2
);
return
(
i
)
;
return
i
;
}
}
/* strxfrm replacment, convert Thai string to sortable string
/* strxfrm replacment, convert Thai string to sortable string
...
@@ -588,9 +584,9 @@ int my_strxfrm_tis620(uchar * dest, const uchar * src, int len)
...
@@ -588,9 +584,9 @@ int my_strxfrm_tis620(uchar * dest, const uchar * src, int len)
uint
bufSize
;
uint
bufSize
;
uchar
*
tmp
;
uchar
*
tmp
;
bufSize
=
(
uint
)
buffsize
((
char
*
)
src
);
bufSize
=
(
uint
)
buffsize
((
char
*
)
src
);
tmp
=
thai2sortable
(
src
,
len
);
tmp
=
thai2sortable
(
src
,
len
);
memcpy
((
uchar
*
)
dest
,
tmp
,
bufSize
);
memcpy
((
uchar
*
)
dest
,
tmp
,
bufSize
);
free
(
tmp
);
free
(
tmp
);
return
bufSize
;
return
bufSize
;
}
}
...
@@ -620,7 +616,7 @@ my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape,
...
@@ -620,7 +616,7 @@ my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape,
if
(
*
ptr
==
escape
&&
ptr
+
1
!=
end
)
if
(
*
ptr
==
escape
&&
ptr
+
1
!=
end
)
{
{
ptr
++
;
/* Skipp escape */
ptr
++
;
/* Skipp escape */
*
min_str
++=
*
max_str
++
=
*
ptr
;
*
min_str
++
=
*
max_str
++
=
*
ptr
;
continue
;
continue
;
}
}
if
(
*
ptr
==
wild_one
)
/* '_' in SQL */
if
(
*
ptr
==
wild_one
)
/* '_' in SQL */
...
@@ -654,26 +650,22 @@ my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape,
...
@@ -654,26 +650,22 @@ my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape,
*/
*/
void
ThNormalize
(
uchar
*
ptr
,
uint
field_length
,
const
uchar
*
from
,
uint
length
)
void
ThNormalize
(
uchar
*
ptr
,
uint
field_length
,
const
uchar
*
from
,
uint
length
)
{
{
const
uchar
*
fr
=
from
;
const
uchar
*
fr
=
from
;
uchar
*
p
=
ptr
;
uchar
*
p
=
ptr
;
if
(
length
>
field_length
)
length
=
field_length
;
if
(
length
>
field_length
)
{
length
=
field_length
;
}
while
(
length
--
)
while
(
length
--
)
{
if
((
istone
(
*
fr
)
||
isdiacrt1
(
*
fr
))
&&
if
((
istone
(
*
fr
)
||
isdiacrt1
(
*
fr
))
&&
(
islwrvowel
(
fr
[
1
])
||
isuprvowel
(
fr
[
1
])))
(
islwrvowel
(
fr
[
1
])
||
isuprvowel
(
fr
[
1
])))
{
{
*
p
=
fr
[
1
];
*
p
=
fr
[
1
];
p
[
1
]
=
*
fr
;
p
[
1
]
=
*
fr
;
fr
+=
2
;
fr
+=
2
;
p
+=
2
;
p
+=
2
;
length
--
;
length
--
;
}
}
else
else
{
*
p
++
=
*
fr
++
;
*
p
++
=
*
fr
++
;
}
}
}
}
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