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