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