1
by brian
clean slate |
1 |
/* Copyright (C) 2002 MySQL AB & tommy@valley.ne.jp.
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2 |
|
1
by brian
clean slate |
3 |
This library is free software; you can redistribute it and/or
|
4 |
modify it under the terms of the GNU Library General Public
|
|
5 |
License as published by the Free Software Foundation; version 2
|
|
6 |
of the License.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
7 |
|
1
by brian
clean slate |
8 |
This library is distributed in the hope that it will be useful,
|
9 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11 |
Library General Public License for more details.
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
12 |
|
1
by brian
clean slate |
13 |
You should have received a copy of the GNU Library General Public
|
14 |
License along with this library; if not, write to the Free
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
15 |
Software Foundation, Inc., 51 Franklin Place - Suite 330, Boston,
|
16 |
MA 02110-1301, USA */
|
|
1
by brian
clean slate |
17 |
|
18 |
/* This file is for binary pseudo charset, created by bar@mysql.com */
|
|
19 |
||
20 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
21 |
#include <config.h> |
22 |
#include <drizzled/definitions.h> |
|
23 |
#include <drizzled/internal/m_string.h> |
|
2281.5.1
by Muhammad Umair
Merged charset declarations of global_charset_info.h and charset_info.h into charset.h header file. |
24 |
#include <drizzled/charset.h> |
1
by brian
clean slate |
25 |
|
1067.4.9
by Nathan Williams
Converted all usages of cmin/cmax in mystrings directory to use std::min/max |
26 |
#include <algorithm> |
27 |
||
28 |
using namespace std; |
|
29 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
30 |
namespace drizzled |
31 |
{
|
|
32 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
33 |
void my_hash_sort_bin(const charset_info_st * const, |
1085.1.2
by Monty Taylor
Fixed -Wmissing-declarations |
34 |
const unsigned char *key, size_t len, |
35 |
uint32_t *nr1, uint32_t *nr2); |
|
36 |
||
1067.4.9
by Nathan Williams
Converted all usages of cmin/cmax in mystrings directory to use std::min/max |
37 |
|
481
by Brian Aker
Remove all of uchar. |
38 |
static unsigned char ctype_bin[]= |
1
by brian
clean slate |
39 |
{
|
40 |
0, |
|
41 |
32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 32, 32, |
|
42 |
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, |
|
43 |
72, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, |
|
44 |
132,132,132,132,132,132,132,132,132,132, 16, 16, 16, 16, 16, 16, |
|
45 |
16,129,129,129,129,129,129, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
|
46 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 16, 16, 16, 16, 16, |
|
47 |
16,130,130,130,130,130,130, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
|
48 |
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 16, 16, 16, 32, |
|
49 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
50 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
51 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
52 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
53 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
54 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
55 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
56 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
57 |
};
|
|
58 |
||
59 |
||
60 |
/* Dummy array for toupper / tolower / sortorder */
|
|
61 |
||
481
by Brian Aker
Remove all of uchar. |
62 |
static unsigned char bin_char_array[] = |
1
by brian
clean slate |
63 |
{
|
64 |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
|
65 |
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, |
|
66 |
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, |
|
67 |
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, |
|
68 |
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
|
69 |
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, |
|
70 |
96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, |
|
71 |
112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, |
|
72 |
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, |
|
73 |
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, |
|
74 |
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, |
|
75 |
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, |
|
76 |
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, |
|
77 |
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, |
|
78 |
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, |
|
79 |
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 |
|
80 |
};
|
|
81 |
||
82 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
83 |
int my_strnncoll_binary(const charset_info_st * const, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
84 |
const unsigned char *s, size_t slen, |
85 |
const unsigned char *t, size_t tlen, |
|
86 |
bool t_is_prefix) |
|
1
by brian
clean slate |
87 |
{
|
1067.4.9
by Nathan Williams
Converted all usages of cmin/cmax in mystrings directory to use std::min/max |
88 |
size_t len= min(slen,tlen); |
1
by brian
clean slate |
89 |
int cmp= memcmp(s,t,len); |
2160.1.8
by Olaf van der Spek
casts |
90 |
return cmp ? cmp : static_cast<int>((t_is_prefix ? len : slen) - tlen); |
1
by brian
clean slate |
91 |
}
|
92 |
||
93 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
94 |
size_t my_lengthsp_binary(const charset_info_st * const, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
95 |
const char *, size_t length) |
1
by brian
clean slate |
96 |
{
|
97 |
return length; |
|
98 |
}
|
|
99 |
||
100 |
||
101 |
/*
|
|
102 |
Compare two strings. Result is sign(first_argument - second_argument)
|
|
103 |
||
104 |
SYNOPSIS
|
|
105 |
my_strnncollsp_binary()
|
|
106 |
cs Chararacter set
|
|
107 |
s String to compare
|
|
108 |
slen Length of 's'
|
|
109 |
t String to compare
|
|
110 |
tlen Length of 't'
|
|
111 |
||
112 |
NOTE
|
|
113 |
This function is used for real binary strings, i.e. for
|
|
114 |
BLOB, BINARY(N) and VARBINARY(N).
|
|
115 |
It compares trailing spaces as spaces.
|
|
116 |
||
117 |
RETURN
|
|
118 |
< 0 s < t
|
|
119 |
0 s == t
|
|
120 |
> 0 s > t
|
|
121 |
*/
|
|
122 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
123 |
int my_strnncollsp_binary(const charset_info_st * const cs, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
124 |
const unsigned char *s, size_t slen, |
125 |
const unsigned char *t, size_t tlen, |
|
126 |
bool) |
|
1
by brian
clean slate |
127 |
{
|
128 |
return my_strnncoll_binary(cs,s,slen,t,tlen,0); |
|
129 |
}
|
|
130 |
||
131 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
132 |
int my_strnncoll_8bit_bin(const charset_info_st * const, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
133 |
const unsigned char *s, size_t slen, |
134 |
const unsigned char *t, size_t tlen, |
|
135 |
bool t_is_prefix) |
|
1
by brian
clean slate |
136 |
{
|
1067.4.9
by Nathan Williams
Converted all usages of cmin/cmax in mystrings directory to use std::min/max |
137 |
size_t len= min(slen,tlen); |
1
by brian
clean slate |
138 |
int cmp= memcmp(s,t,len); |
2160.1.8
by Olaf van der Spek
casts |
139 |
return cmp ? cmp : static_cast<int>((t_is_prefix ? len : slen) - tlen); |
1
by brian
clean slate |
140 |
}
|
141 |
||
142 |
||
143 |
/*
|
|
144 |
Compare two strings. Result is sign(first_argument - second_argument)
|
|
145 |
||
146 |
SYNOPSIS
|
|
147 |
my_strnncollsp_8bit_bin()
|
|
148 |
cs Chararacter set
|
|
149 |
s String to compare
|
|
150 |
slen Length of 's'
|
|
151 |
t String to compare
|
|
152 |
tlen Length of 't'
|
|
153 |
diff_if_only_endspace_difference
|
|
154 |
Set to 1 if the strings should be regarded as different
|
|
155 |
if they only difference in end space
|
|
156 |
||
157 |
NOTE
|
|
158 |
This function is used for character strings with binary collations.
|
|
159 |
The shorter string is extended with end space to be as long as the longer
|
|
160 |
one.
|
|
161 |
||
162 |
RETURN
|
|
163 |
< 0 s < t
|
|
164 |
0 s == t
|
|
165 |
> 0 s > t
|
|
166 |
*/
|
|
167 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
168 |
int my_strnncollsp_8bit_bin(const charset_info_st * const, |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
169 |
const unsigned char *a, size_t a_length, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
170 |
const unsigned char *b, size_t b_length, |
171 |
bool diff_if_only_endspace_difference) |
|
1
by brian
clean slate |
172 |
{
|
481
by Brian Aker
Remove all of uchar. |
173 |
const unsigned char *end; |
1
by brian
clean slate |
174 |
size_t length; |
175 |
int res; |
|
176 |
||
177 |
#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
|
|
178 |
diff_if_only_endspace_difference= 0; |
|
179 |
#endif
|
|
180 |
||
1067.4.9
by Nathan Williams
Converted all usages of cmin/cmax in mystrings directory to use std::min/max |
181 |
end= a + (length= min(a_length, b_length)); |
1
by brian
clean slate |
182 |
while (a < end) |
183 |
{
|
|
184 |
if (*a++ != *b++) |
|
2160.1.8
by Olaf van der Spek
casts |
185 |
return a[-1] - b[-1]; |
1
by brian
clean slate |
186 |
}
|
187 |
res= 0; |
|
188 |
if (a_length != b_length) |
|
189 |
{
|
|
190 |
int swap= 1; |
|
191 |
/*
|
|
192 |
Check the next not space character of the longer key. If it's < ' ',
|
|
193 |
then it's smaller than the other key.
|
|
194 |
*/
|
|
195 |
if (diff_if_only_endspace_difference) |
|
196 |
res= 1; /* Assume 'a' is bigger */ |
|
197 |
if (a_length < b_length) |
|
198 |
{
|
|
199 |
/* put shorter key in s */
|
|
200 |
a_length= b_length; |
|
201 |
a= b; |
|
202 |
swap= -1; /* swap sign of result */ |
|
203 |
res= -res; |
|
204 |
}
|
|
205 |
for (end= a + a_length-length; a < end ; a++) |
|
206 |
{
|
|
207 |
if (*a != ' ') |
|
208 |
return (*a < ' ') ? -swap : swap; |
|
209 |
}
|
|
210 |
}
|
|
211 |
return res; |
|
212 |
}
|
|
213 |
||
214 |
||
215 |
/* This function is used for all conversion functions */
|
|
216 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
217 |
size_t my_case_str_bin(const charset_info_st * const, char *) |
1
by brian
clean slate |
218 |
{
|
219 |
return 0; |
|
220 |
}
|
|
221 |
||
222 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
223 |
size_t my_case_bin(const charset_info_st * const, char *, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
224 |
size_t srclen, char *, size_t) |
1
by brian
clean slate |
225 |
{
|
226 |
return srclen; |
|
227 |
}
|
|
228 |
||
229 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
230 |
int my_strcasecmp_bin(const charset_info_st * const, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
231 |
const char *s, const char *t) |
1
by brian
clean slate |
232 |
{
|
233 |
return strcmp(s,t); |
|
234 |
}
|
|
235 |
||
236 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
237 |
uint32_t my_mbcharlen_8bit(const charset_info_st * const, uint32_t) |
1
by brian
clean slate |
238 |
{
|
239 |
return 1; |
|
240 |
}
|
|
241 |
||
242 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
243 |
int my_mb_wc_bin(const charset_info_st * const, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
244 |
my_wc_t *wc, const unsigned char *str, |
245 |
const unsigned char *end) |
|
1
by brian
clean slate |
246 |
{
|
247 |
if (str >= end) |
|
248 |
return MY_CS_TOOSMALL; |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
249 |
|
1
by brian
clean slate |
250 |
*wc=str[0]; |
251 |
return 1; |
|
252 |
}
|
|
253 |
||
254 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
255 |
int my_wc_mb_bin(const charset_info_st * const, my_wc_t wc, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
256 |
unsigned char *str, unsigned char *end) |
1
by brian
clean slate |
257 |
{
|
612.2.12
by Monty Taylor
Fixed a coupla false positives. |
258 |
if (str >= end) |
1
by brian
clean slate |
259 |
return MY_CS_TOOSMALL; |
260 |
||
261 |
if (wc < 256) |
|
262 |
{
|
|
2160.1.8
by Olaf van der Spek
casts |
263 |
str[0]= wc; |
1
by brian
clean slate |
264 |
return 1; |
265 |
}
|
|
266 |
return MY_CS_ILUNI; |
|
267 |
}
|
|
268 |
||
269 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
270 |
void my_hash_sort_8bit_bin(const charset_info_st * const, |
612.2.11
by Monty Taylor
Cleanup up the extern+static combo (plus some attributes because I got bored.) |
271 |
const unsigned char *key, size_t len, |
272 |
uint32_t *nr1, uint32_t *nr2) |
|
1
by brian
clean slate |
273 |
{
|
481
by Brian Aker
Remove all of uchar. |
274 |
const unsigned char *pos = key; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
275 |
|
1
by brian
clean slate |
276 |
/*
|
277 |
Remove trailing spaces. We have to do this to be able to compare
|
|
278 |
'A ' and 'A' as identical
|
|
279 |
*/
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
280 |
key= internal::skip_trailing_space(key, len); |
1
by brian
clean slate |
281 |
|
2160.1.8
by Olaf van der Spek
casts |
282 |
for (; pos < key ; pos++) |
1
by brian
clean slate |
283 |
{
|
2160.1.8
by Olaf van der Spek
casts |
284 |
nr1[0]^= (((nr1[0] & 63) + nr2[0]) * *pos) + (nr1[0] << 8); |
1
by brian
clean slate |
285 |
nr2[0]+=3; |
286 |
}
|
|
287 |
}
|
|
288 |
||
289 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
290 |
void my_hash_sort_bin(const charset_info_st * const, |
612.2.11
by Monty Taylor
Cleanup up the extern+static combo (plus some attributes because I got bored.) |
291 |
const unsigned char *key, size_t len, |
292 |
uint32_t *nr1, uint32_t *nr2) |
|
1
by brian
clean slate |
293 |
{
|
481
by Brian Aker
Remove all of uchar. |
294 |
const unsigned char *pos = key; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
295 |
|
1
by brian
clean slate |
296 |
key+= len; |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
297 |
|
2160.1.8
by Olaf van der Spek
casts |
298 |
for (; pos < key ; pos++) |
1
by brian
clean slate |
299 |
{
|
2160.1.8
by Olaf van der Spek
casts |
300 |
nr1[0]^= (((nr1[0] & 63) + nr2[0]) * *pos) + (nr1[0] << 8); |
1
by brian
clean slate |
301 |
nr2[0]+=3; |
302 |
}
|
|
303 |
}
|
|
304 |
||
305 |
||
306 |
/*
|
|
307 |
The following defines is here to keep the following code identical to
|
|
308 |
the one in ctype-simple.c
|
|
309 |
*/
|
|
310 |
||
311 |
#define likeconv(s,A) (A)
|
|
312 |
#define INC_PTR(cs,A,B) (A)++
|
|
313 |
||
314 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
315 |
int my_wildcmp_bin(const charset_info_st * const cs, |
1
by brian
clean slate |
316 |
const char *str,const char *str_end, |
317 |
const char *wildstr,const char *wildend, |
|
318 |
int escape, int w_one, int w_many) |
|
319 |
{
|
|
320 |
int result= -1; /* Not found, using wildcards */ |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
321 |
|
1
by brian
clean slate |
322 |
while (wildstr != wildend) |
323 |
{
|
|
324 |
while (*wildstr != w_many && *wildstr != w_one) |
|
325 |
{
|
|
326 |
if (*wildstr == escape && wildstr+1 != wildend) |
|
327 |
wildstr++; |
|
328 |
if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++)) |
|
2318.6.77
by Olaf van der Spek
Refactor |
329 |
return 1; /* No match */ |
1
by brian
clean slate |
330 |
if (wildstr == wildend) |
331 |
return(str != str_end); /* Match if both are at end */ |
|
332 |
result=1; /* Found an anchor char */ |
|
333 |
}
|
|
334 |
if (*wildstr == w_one) |
|
335 |
{
|
|
336 |
do
|
|
337 |
{
|
|
338 |
if (str == str_end) /* Skip one char if possible */ |
|
339 |
return(result); |
|
340 |
INC_PTR(cs,str,str_end); |
|
341 |
} while (++wildstr < wildend && *wildstr == w_one); |
|
342 |
if (wildstr == wildend) |
|
343 |
break; |
|
344 |
}
|
|
345 |
if (*wildstr == w_many) |
|
346 |
{ /* Found w_many */ |
|
481
by Brian Aker
Remove all of uchar. |
347 |
unsigned char cmp; |
1
by brian
clean slate |
348 |
wildstr++; |
349 |
/* Remove any '%' and '_' from the wild search string */
|
|
350 |
for (; wildstr != wildend ; wildstr++) |
|
351 |
{
|
|
352 |
if (*wildstr == w_many) |
|
353 |
continue; |
|
354 |
if (*wildstr == w_one) |
|
355 |
{
|
|
356 |
if (str == str_end) |
|
357 |
return(-1); |
|
358 |
INC_PTR(cs,str,str_end); |
|
359 |
continue; |
|
360 |
}
|
|
361 |
break; /* Not a wild character */ |
|
362 |
}
|
|
363 |
if (wildstr == wildend) |
|
2318.6.58
by Olaf van der Spek
Refactor |
364 |
return 0; /* match if w_many is last */ |
1
by brian
clean slate |
365 |
if (str == str_end) |
366 |
return(-1); |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
367 |
|
1
by brian
clean slate |
368 |
if ((cmp= *wildstr) == escape && wildstr+1 != wildend) |
369 |
cmp= *++wildstr; |
|
370 |
||
371 |
INC_PTR(cs,wildstr,wildend); /* This is compared through cmp */ |
|
372 |
cmp=likeconv(cs,cmp); |
|
373 |
do
|
|
374 |
{
|
|
481
by Brian Aker
Remove all of uchar. |
375 |
while (str != str_end && (unsigned char) likeconv(cs,*str) != cmp) |
1
by brian
clean slate |
376 |
str++; |
377 |
if (str++ == str_end) |
|
378 |
return(-1); |
|
379 |
{
|
|
380 |
int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one, |
|
381 |
w_many); |
|
382 |
if (tmp <= 0) |
|
383 |
return(tmp); |
|
384 |
}
|
|
385 |
} while (str != str_end && wildstr[0] != w_many); |
|
386 |
return(-1); |
|
387 |
}
|
|
388 |
}
|
|
389 |
return(str != str_end ? 1 : 0); |
|
390 |
}
|
|
391 |
||
392 |
||
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
393 |
size_t
|
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
394 |
my_strnxfrm_8bit_bin(const charset_info_st * const cs, |
482
by Brian Aker
Remove uint. |
395 |
unsigned char * dst, size_t dstlen, uint32_t nweights, |
396 |
const unsigned char *src, size_t srclen, uint32_t flags) |
|
1
by brian
clean slate |
397 |
{
|
398 |
set_if_smaller(srclen, dstlen); |
|
937.2.7
by Stewart Smith
typesafe set_if_smaller/set_if_greater fixes from Solaris |
399 |
set_if_smaller(srclen, (size_t) nweights); |
1
by brian
clean slate |
400 |
if (dst != src) |
401 |
memcpy(dst, src, srclen); |
|
402 |
return my_strxfrm_pad_desc_and_reverse(cs, dst, dst + srclen, dst + dstlen, |
|
403 |
nweights - srclen, flags, 0); |
|
404 |
}
|
|
405 |
||
406 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
407 |
uint32_t my_instr_bin(const charset_info_st * const, |
632.1.10
by Monty Taylor
Got rid of Sun Studio warnings. |
408 |
const char *b, size_t b_length, |
409 |
const char *s, size_t s_length, |
|
410 |
my_match_t *match, uint32_t nmatch) |
|
1
by brian
clean slate |
411 |
{
|
2170.5.1
by Olaf van der Spek
Remove register keyword |
412 |
const unsigned char *str, *search, *end, *search_end; |
1
by brian
clean slate |
413 |
|
414 |
if (s_length <= b_length) |
|
415 |
{
|
|
416 |
if (!s_length) |
|
417 |
{
|
|
418 |
if (nmatch) |
|
419 |
{
|
|
420 |
match->beg= 0; |
|
421 |
match->end= 0; |
|
422 |
match->mb_len= 0; |
|
423 |
}
|
|
424 |
return 1; /* Empty string is always found */ |
|
425 |
}
|
|
426 |
||
481
by Brian Aker
Remove all of uchar. |
427 |
str= (const unsigned char*) b; |
428 |
search= (const unsigned char*) s; |
|
429 |
end= (const unsigned char*) b+b_length-s_length+1; |
|
430 |
search_end= (const unsigned char*) s + s_length; |
|
1
by brian
clean slate |
431 |
|
432 |
skip: |
|
433 |
while (str != end) |
|
434 |
{
|
|
435 |
if ( (*str++) == (*search)) |
|
436 |
{
|
|
2170.5.1
by Olaf van der Spek
Remove register keyword |
437 |
const unsigned char *i,*j; |
1
by brian
clean slate |
438 |
|
439 |
i= str; |
|
440 |
j= search+1; |
|
441 |
||
442 |
while (j != search_end) |
|
443 |
if ((*i++) != (*j++)) |
|
444 |
goto skip; |
|
445 |
||
446 |
if (nmatch > 0) |
|
447 |
{
|
|
448 |
match[0].beg= 0; |
|
481
by Brian Aker
Remove all of uchar. |
449 |
match[0].end= (size_t) (str- (const unsigned char*)b-1); |
1
by brian
clean slate |
450 |
match[0].mb_len= match[0].end; |
451 |
||
452 |
if (nmatch > 1) |
|
453 |
{
|
|
454 |
match[1].beg= match[0].end; |
|
455 |
match[1].end= match[0].end+s_length; |
|
456 |
match[1].mb_len= match[1].end-match[1].beg; |
|
457 |
}
|
|
458 |
}
|
|
459 |
return 2; |
|
460 |
}
|
|
461 |
}
|
|
462 |
}
|
|
463 |
return 0; |
|
464 |
}
|
|
465 |
||
466 |
||
467 |
static MY_COLLATION_HANDLER my_collation_binary_handler = |
|
468 |
{
|
|
469 |
NULL, /* init */ |
|
470 |
my_strnncoll_binary, |
|
471 |
my_strnncollsp_binary, |
|
472 |
my_strnxfrm_8bit_bin, |
|
473 |
my_strnxfrmlen_simple, |
|
474 |
my_like_range_simple, |
|
475 |
my_wildcmp_bin, |
|
476 |
my_strcasecmp_bin, |
|
477 |
my_instr_bin, |
|
478 |
my_hash_sort_bin, |
|
479 |
my_propagate_simple
|
|
480 |
};
|
|
481 |
||
482 |
||
483 |
static MY_CHARSET_HANDLER my_charset_handler= |
|
484 |
{
|
|
485 |
NULL, /* init */ |
|
486 |
NULL, /* ismbchar */ |
|
487 |
my_mbcharlen_8bit, /* mbcharlen */ |
|
488 |
my_numchars_8bit, |
|
489 |
my_charpos_8bit, |
|
490 |
my_well_formed_len_8bit, |
|
491 |
my_lengthsp_binary, |
|
492 |
my_numcells_8bit, |
|
493 |
my_mb_wc_bin, |
|
494 |
my_wc_mb_bin, |
|
495 |
my_mb_ctype_8bit, |
|
496 |
my_case_str_bin, |
|
497 |
my_case_str_bin, |
|
498 |
my_case_bin, |
|
499 |
my_case_bin, |
|
500 |
my_snprintf_8bit, |
|
501 |
my_long10_to_str_8bit, |
|
152
by Brian Aker
longlong replacement |
502 |
my_int64_t10_to_str_8bit, |
1
by brian
clean slate |
503 |
my_fill_8bit, |
504 |
my_strntol_8bit, |
|
505 |
my_strntoul_8bit, |
|
506 |
my_strntoll_8bit, |
|
507 |
my_strntoull_8bit, |
|
508 |
my_strntod_8bit, |
|
509 |
my_strtoll10_8bit, |
|
510 |
my_strntoull10rnd_8bit, |
|
511 |
my_scan_8bit
|
|
512 |
};
|
|
513 |
||
514 |
||
2254
by Brian Aker
Shift CHARSET_INFO to charset_info_st |
515 |
DRIZZLED_API charset_info_st my_charset_bin = |
1
by brian
clean slate |
516 |
{
|
517 |
63,0,0, /* number */ |
|
518 |
MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_PRIMARY,/* state */ |
|
519 |
"binary", /* cs name */ |
|
520 |
"binary", /* name */ |
|
521 |
"", /* comment */ |
|
522 |
NULL, /* tailoring */ |
|
523 |
ctype_bin, /* ctype */ |
|
524 |
bin_char_array, /* to_lower */ |
|
525 |
bin_char_array, /* to_upper */ |
|
526 |
NULL, /* sort_order */ |
|
527 |
NULL, /* contractions */ |
|
528 |
NULL, /* sort_order_big*/ |
|
529 |
NULL, /* tab_to_uni */ |
|
530 |
NULL, /* tab_from_uni */ |
|
531 |
my_unicase_default, /* caseinfo */ |
|
532 |
NULL, /* state_map */ |
|
533 |
NULL, /* ident_map */ |
|
534 |
1, /* strxfrm_multiply */ |
|
535 |
1, /* caseup_multiply */ |
|
536 |
1, /* casedn_multiply */ |
|
537 |
1, /* mbminlen */ |
|
538 |
1, /* mbmaxlen */ |
|
539 |
0, /* min_sort_char */ |
|
540 |
255, /* max_sort_char */ |
|
541 |
0, /* pad char */ |
|
542 |
0, /* escape_with_backslash_is_dangerous */ |
|
543 |
1, /* levels_for_compare */ |
|
544 |
1, /* levels_for_order */ |
|
545 |
&my_charset_handler, |
|
546 |
&my_collation_binary_handler |
|
547 |
};
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
548 |
|
549 |
} /* namespace drizzled */ |