~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to strings/ctype-cp932.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
 
1
/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
11
11
 
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
 
15
*/
15
16
 
16
17
/* This file is for cp932 charaset (Windows Japanese),
17
18
   and created based on ctype-sjis.c file  */
306
307
}
307
308
 
308
309
 
309
 
/*
310
 
** Calculate min_str and max_str that ranges a LIKE string.
311
 
** Arguments:
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.
321
 
**
322
 
** The function should return 0 if ok and 1 if the LIKE string can't be
323
 
** optimized !
324
 
*/
325
 
 
326
 
#define max_sort_char ((char) 255)
327
 
 
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,
331
 
                                   size_t res_length,
332
 
                                   char *min_str,char *max_str,
333
 
                                   size_t *min_length, size_t *max_length)
334
 
{
335
 
  const char *end=ptr+ptr_length;
336
 
  char *min_org=min_str;
337
 
  char *min_end=min_str+res_length;
338
 
 
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++;
344
 
      continue;
345
 
    }
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++;
352
 
      continue;
353
 
    }
354
 
    if (*ptr == w_one) {                /* '_' in SQL */
355
 
      *min_str++ = '\0';                /* This should be min char */
356
 
      *max_str++ = max_sort_char;
357
 
      ptr++;
358
 
      continue;
359
 
    }
360
 
    if (*ptr == w_many)
361
 
    {                                           /* '%' in SQL */
362
 
      *min_length = (size_t)(min_str - min_org);
363
 
      *max_length = res_length;
364
 
      do
365
 
      {
366
 
        *min_str++= 0;
367
 
        *max_str++= max_sort_char;
368
 
      } while (min_str < min_end);
369
 
      return 0;
370
 
    }
371
 
    *min_str++ = *max_str++ = *ptr++;
372
 
  }
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 */
376
 
  return 0;
377
 
}
378
 
 
379
310
/* page 0 0x00A1-0x00DF */
380
311
static uint16 tab_cp932_uni0[]={
381
312
0xFF61,0xFF62,0xFF63,0xFF64,0xFF65,0xFF66,0xFF67,0xFF68,
5467
5398
  my_strnncollsp_cp932,
5468
5399
  my_strnxfrm_cp932,
5469
5400
  my_strnxfrmlen_simple,
5470
 
  my_like_range_cp932,
 
5401
  my_like_range_mb,
5471
5402
  my_wildcmp_mb,        /* wildcmp  */
5472
5403
  my_strcasecmp_8bit,
5473
5404
  my_instr_mb,
5533
5464
    1,                  /* mbminlen   */
5534
5465
    2,                  /* mbmaxlen */
5535
5466
    0,                  /* min_sort_char */
5536
 
    255,                /* max_sort_char */
 
5467
    0xFCFC,             /* max_sort_char */
5537
5468
    ' ',                /* pad char      */
5538
5469
    1,                  /* escape_with_backslash_is_dangerous */
5539
5470
    &my_charset_handler,
5565
5496
    1,                  /* mbminlen   */
5566
5497
    2,                  /* mbmaxlen */
5567
5498
    0,                  /* min_sort_char */
5568
 
    255,                /* max_sort_char */
 
5499
    0xFCFC,             /* max_sort_char */
5569
5500
    ' ',                /* pad char      */
5570
5501
    1,                  /* escape_with_backslash_is_dangerous */
5571
5502
    &my_charset_handler,