12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
17
/* This file is for cp932 charaset (Windows Japanese),
17
18
and created based on ctype-sjis.c file */
310
** Calculate min_str and max_str that ranges a LIKE string.
312
** ptr Pointer to LIKE string.
313
** ptr_length Length of LIKE string.
314
** escape Escape character in LIKE. (Normally '\').
315
** All escape characters should be removed from min_str and max_str
316
** res_length Length of min_str and max_str.
317
** min_str Smallest case sensitive string that ranges LIKE.
318
** Should be space padded to res_length.
319
** max_str Largest case sensitive string that ranges LIKE.
320
** Normally padded with the biggest character sort value.
322
** The function should return 0 if ok and 1 if the LIKE string can't be
326
#define max_sort_char ((char) 255)
328
static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)),
329
const char *ptr,size_t ptr_length,
330
pbool escape, pbool w_one, pbool w_many,
332
char *min_str,char *max_str,
333
size_t *min_length, size_t *max_length)
335
const char *end=ptr+ptr_length;
336
char *min_org=min_str;
337
char *min_end=min_str+res_length;
339
while (ptr < end && min_str < min_end) {
340
if (ismbchar_cp932(cs, ptr, end)) {
341
*min_str++ = *max_str++ = *ptr++;
342
if (min_str < min_end)
343
*min_str++ = *max_str++ = *ptr++;
346
if (*ptr == escape && ptr+1 < end) {
347
ptr++; /* Skip escape */
348
if (ismbchar_cp932(cs, ptr, end))
349
*min_str++ = *max_str++ = *ptr++;
350
if (min_str < min_end)
351
*min_str++ = *max_str++ = *ptr++;
354
if (*ptr == w_one) { /* '_' in SQL */
355
*min_str++ = '\0'; /* This should be min char */
356
*max_str++ = max_sort_char;
362
*min_length = (size_t)(min_str - min_org);
363
*max_length = res_length;
367
*max_str++= max_sort_char;
368
} while (min_str < min_end);
371
*min_str++ = *max_str++ = *ptr++;
373
*min_length = *max_length = (size_t) (min_str - min_org);
374
while (min_str < min_end)
375
*min_str++ = *max_str++ = ' '; /* Because if key compression */
379
310
/* page 0 0x00A1-0x00DF */
380
311
static uint16 tab_cp932_uni0[]={
381
312
0xFF61,0xFF62,0xFF63,0xFF64,0xFF65,0xFF66,0xFF67,0xFF68,