~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/ctype-utf8.cc

  • Committer: Mark Atwood
  • Date: 2011-10-25 19:08:35 UTC
  • mfrom: (2445.1.6 rf)
  • Revision ID: me@mark.atwood.name-20111025190835-g21cn911ypxjd5fi
mergeĀ lp:~olafvdspek/drizzle/refactor7

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
namespace drizzled
43
43
{
44
44
 
45
 
void my_hash_sort_utf8mb4(const charset_info_st * const cs,
 
45
void my_hash_sort_utf8mb4(const charset_info_st* cs,
46
46
                          const unsigned char *s, size_t slen,
47
47
                          uint32_t *n1, uint32_t *n2);
48
48
 
1725
1725
    @retval  1 if matched with wildcard.
1726
1726
*/
1727
1727
 
1728
 
int my_wildcmp_unicode(const charset_info_st * const cs,
 
1728
int my_wildcmp_unicode(const charset_info_st* cs,
1729
1729
                       const char *str,const char *str_end,
1730
1730
                       const char *wildstr,const char *wildend,
1731
1731
                       int escape, int w_one, int w_many,
1868
1868
          return -1;
1869
1869
 
1870
1870
        str+= scan;
1871
 
        result= my_wildcmp_unicode(cs, str, str_end, wildstr, wildend,
1872
 
                                   escape, w_one, w_many,
1873
 
                                   weights);
 
1871
        result= my_wildcmp_unicode(cs, str, str_end, wildstr, wildend, escape, w_one, w_many, weights);
1874
1872
        if (result <= 0)
1875
1873
          return result;
1876
1874
      }
1877
1875
    }
1878
1876
  }
1879
 
  return (str != str_end ? 1 : 0);
 
1877
  return str != str_end;
1880
1878
}
1881
1879
 
1882
1880
 
1883
 
int make_escape_code(const charset_info_st * const cs, const char *escape)
 
1881
int make_escape_code(const charset_info_st* cs, const char *escape)
1884
1882
{
1885
1883
  my_charset_conv_mb_wc mb_wc= cs->cset->mb_wc;
1886
1884
  my_wc_t escape_wc;
1887
 
  int rc= mb_wc(cs, &escape_wc,
1888
 
                (const unsigned char*) escape,
1889
 
                (const unsigned char*) escape + strlen(escape));
1890
 
  return (int)(rc > 0 ? escape_wc : '\\');
 
1885
  int rc= mb_wc(cs, &escape_wc, (const unsigned char*) escape, (const unsigned char*) escape + strlen(escape));
 
1886
  return rc > 0 ? escape_wc : '\\';
1891
1887
}
1892
1888
 
1893
1889
/*
1971
1967
}
1972
1968
 
1973
1969
 
1974
 
int
1975
 
my_mb_wc_utf8mb4(const charset_info_st * const,
1976
 
                 my_wc_t * pwc, const unsigned char *s, const unsigned char *e)
 
1970
static int my_mb_wc_utf8mb4(const charset_info_st*, my_wc_t * pwc, const unsigned char *s, const unsigned char *e)
1977
1971
{
1978
 
  unsigned char c;
1979
 
 
1980
1972
  if (s >= e)
1981
1973
    return MY_CS_TOOSMALL;
1982
1974
 
1983
 
  c= s[0];
 
1975
  unsigned char c= s[0];
1984
1976
  if (c < 0x80)
1985
1977
  {
1986
1978
    *pwc= c;
2038
2030
  for example, for a null-terminated string
2039
2031
*/
2040
2032
static int
2041
 
my_mb_wc_utf8mb4_no_range(const charset_info_st * const,
 
2033
my_mb_wc_utf8mb4_no_range(const charset_info_st*,
2042
2034
                          my_wc_t *pwc, const unsigned char *s)
2043
2035
{
2044
2036
  unsigned char c;
2091
2083
}
2092
2084
 
2093
2085
 
2094
 
int
2095
 
my_wc_mb_utf8mb4(const charset_info_st * const,
2096
 
                 my_wc_t wc, unsigned char *r, unsigned char *e)
 
2086
static int my_wc_mb_utf8mb4(const charset_info_st*, my_wc_t wc, unsigned char *r, unsigned char *e)
2097
2087
{
2098
2088
  int count;
2099
2089
 
2111
2101
  else return MY_CS_ILUNI;
2112
2102
 
2113
2103
  if (r + count > e)
2114
 
    return my_cs_toosmalln(count);
 
2104
    return -100 - count;
2115
2105
 
2116
 
  switch (count) {
 
2106
  switch (count) 
 
2107
  {
2117
2108
    /* Fall through all cases!!! */
2118
2109
    case 4: r[3] = (unsigned char) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x10000;
2119
2110
    case 3: r[2] = (unsigned char) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x800;
2128
2119
  The same as above, but without range check.
2129
2120
*/
2130
2121
static int
2131
 
my_wc_mb_utf8mb4_no_range(const charset_info_st * const,
 
2122
my_wc_mb_utf8mb4_no_range(const charset_info_st*,
2132
2123
                          my_wc_t wc, unsigned char *r)
2133
2124
{
2134
2125
  int count;
2193
2184
}
2194
2185
 
2195
2186
 
2196
 
size_t
2197
 
my_caseup_utf8mb4(const charset_info_st * const cs, char *src, size_t srclen,
2198
 
                  char *dst, size_t dstlen)
 
2187
static size_t my_caseup_utf8mb4(const charset_info_st* cs, char *src, size_t srclen, char *dst, size_t dstlen)
2199
2188
{
2200
2189
  my_wc_t wc;
2201
2190
  int srcres, dstres;
2225
2214
}
2226
2215
 
2227
2216
 
2228
 
void my_hash_sort_utf8mb4(const charset_info_st * const cs,
 
2217
void my_hash_sort_utf8mb4(const charset_info_st* cs,
2229
2218
                          const unsigned char *s, size_t slen,
2230
2219
                          uint32_t *n1, uint32_t *n2)
2231
2220
{
2262
2251
}
2263
2252
 
2264
2253
 
2265
 
size_t
2266
 
my_caseup_str_utf8mb4(const charset_info_st * const cs, char *src)
 
2254
static size_t my_caseup_str_utf8mb4(const charset_info_st* cs, char *src)
2267
2255
{
2268
2256
  my_wc_t wc;
2269
2257
  int srcres, dstres;
2285
2273
}
2286
2274
 
2287
2275
 
2288
 
size_t
2289
 
my_casedn_utf8mb4(const charset_info_st * const cs,
2290
 
                  char *src, size_t srclen,
2291
 
                  char *dst, size_t dstlen)
 
2276
static size_t my_casedn_utf8mb4(const charset_info_st* cs, char *src, size_t srclen, char *dst, size_t dstlen)
2292
2277
{
2293
2278
  my_wc_t wc;
2294
2279
  int srcres, dstres;
2310
2295
}
2311
2296
 
2312
2297
 
2313
 
size_t
2314
 
my_casedn_str_utf8mb4(const charset_info_st * const cs, char *src)
 
2298
static size_t my_casedn_str_utf8mb4(const charset_info_st* cs, char *src)
2315
2299
{
2316
2300
  my_wc_t wc;
2317
2301
  int srcres, dstres;
2349
2333
}
2350
2334
 
2351
2335
 
2352
 
int
2353
 
my_strnncoll_utf8mb4(const charset_info_st * const cs,
 
2336
static int my_strnncoll_utf8mb4(const charset_info_st* cs,
2354
2337
                     const unsigned char *s, size_t slen,
2355
2338
                     const unsigned char *t, size_t tlen,
2356
2339
                     bool t_is_prefix)
2414
2397
    @retval Positive number, if a > b
2415
2398
*/
2416
2399
 
2417
 
int
2418
 
my_strnncollsp_utf8mb4(const charset_info_st * const cs,
 
2400
static int my_strnncollsp_utf8mb4(const charset_info_st* cs,
2419
2401
                       const unsigned char *s, size_t slen,
2420
2402
                       const unsigned char *t, size_t tlen,
2421
2403
                       bool diff_if_only_endspace_difference)
2503
2485
    @retval 0 is the strings are equal
2504
2486
*/
2505
2487
 
2506
 
int my_strcasecmp_utf8mb4(const charset_info_st * const cs,
2507
 
                          const char *s, const char *t)
 
2488
static int my_strcasecmp_utf8mb4(const charset_info_st* cs, const char *s, const char *t)
2508
2489
{
2509
2490
  MY_UNICASE_INFO **uni_plane= cs->caseinfo;
2510
2491
  while (s[0] && t[0])
2563
2544
}
2564
2545
 
2565
2546
 
2566
 
int
2567
 
my_wildcmp_utf8mb4(const charset_info_st * const cs,
 
2547
static int my_wildcmp_utf8mb4(const charset_info_st* cs,
2568
2548
                   const char *str, const char *strend,
2569
2549
                   const char *wildstr, const char *wildend,
2570
2550
                   int escape, int w_one, int w_many)
2571
2551
{
2572
 
  return my_wildcmp_unicode(cs, str, strend, wildstr, wildend,
2573
 
                            escape, w_one, w_many, cs->caseinfo);
 
2552
  return my_wildcmp_unicode(cs, str, strend, wildstr, wildend, escape, w_one, w_many, cs->caseinfo);
2574
2553
}
2575
2554
 
2576
2555
 
2577
 
size_t
2578
 
my_strnxfrmlen_utf8mb4(const charset_info_st * const, size_t len)
 
2556
static size_t my_strnxfrmlen_utf8mb4(const charset_info_st*, size_t len)
2579
2557
{
2580
2558
  /* TODO: fix when working on WL "Unicode new version" */
2581
2559
  return (len * 2 + 2) / 4;
2582
2560
}
2583
2561
 
2584
2562
 
2585
 
size_t
2586
 
my_strnxfrm_utf8mb4(const charset_info_st * const cs,
 
2563
static size_t my_strnxfrm_utf8mb4(const charset_info_st* cs,
2587
2564
                    unsigned char *dst, size_t dstlen, uint32_t nweights,
2588
2565
                    const unsigned char *src, size_t srclen, uint32_t flags)
2589
2566
{
2627
2604
}
2628
2605
 
2629
2606
 
2630
 
unsigned int my_ismbchar_utf8mb4(const charset_info_st * const cs,
2631
 
                                 const char *b, const char *e)
 
2607
static unsigned int my_ismbchar_utf8mb4(const charset_info_st* cs, const char *b, const char *e)
2632
2608
{
2633
2609
  my_wc_t wc;
2634
2610
  int res= my_mb_wc_utf8mb4(cs,&wc, (const unsigned char*)b, (const unsigned char*)e);
2636
2612
}
2637
2613
 
2638
2614
 
2639
 
unsigned int my_mbcharlen_utf8mb4(const charset_info_st * const, uint32_t c)
 
2615
static unsigned int my_mbcharlen_utf8mb4(const charset_info_st*, uint32_t c)
2640
2616
{
2641
2617
  if (c < 0x80)
2642
2618
    return 1;
2686
2662
 
2687
2663
MY_CHARSET_HANDLER my_charset_utf8mb4_handler=
2688
2664
{
2689
 
  NULL,               /* init */
2690
2665
  my_ismbchar_utf8mb4,
2691
2666
  my_mbcharlen_utf8mb4,
2692
2667
  my_numchars_mb,
2744
2719
  0,                  /* min_sort_char */
2745
2720
  0xFFFF,             /* max_sort_char */
2746
2721
  ' ',                /* pad char      */
2747
 
  0,                  /* escape_with_backslash_is_dangerous */
2748
2722
  1,                  /* levels_for_compare */
2749
2723
  1,                  /* levels_for_order   */
2750
2724
  &my_charset_utf8mb4_handler,
2779
2753
  0,                  /* min_sort_char */
2780
2754
  0xFFFF,             /* max_sort_char */
2781
2755
  ' ',                /* pad char      */
2782
 
  0,                  /* escape_with_backslash_is_dangerous */
2783
2756
  1,                  /* levels_for_compare */
2784
2757
  1,                  /* levels_for_order   */
2785
2758
  &my_charset_utf8mb4_handler,