~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/charset.h

  • Committer: Mark Atwood
  • Date: 2011-12-11 22:56:39 UTC
  • mfrom: (2465.1.1 drizzle)
  • Revision ID: me@mark.atwood.name-20111211225639-3d8ype7g2y82dci5
mergeĀ lp:~brianaker/drizzle/libdrizzle-breakout

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#include <sys/types.h>
27
27
#include <cstddef>
 
28
 
28
29
#include <drizzled/visibility.h>
 
30
#include <drizzled/common_fwd.h>
29
31
#include <drizzled/definitions.h>
30
32
 
31
33
namespace drizzled {
105
107
#define _MY_X   0200    /* heXadecimal digit */
106
108
 
107
109
/* Some typedef to make it easy for C++ to make function pointers */
108
 
typedef int (*my_charset_conv_mb_wc)(const struct charset_info_st * const, my_wc_t *,
109
 
                                     const unsigned char *, const unsigned char *);
110
 
typedef int (*my_charset_conv_wc_mb)(const struct charset_info_st * const, my_wc_t,
111
 
                                     unsigned char *, unsigned char *);
112
 
typedef size_t (*my_charset_conv_case)(const struct charset_info_st * const,
113
 
                                       char *, size_t, char *, size_t);
114
 
struct charset_info_st;
115
 
typedef struct unicase_info_st
 
110
typedef int (*my_charset_conv_mb_wc)(const charset_info_st*, my_wc_t *, const unsigned char*, const unsigned char *);
 
111
typedef int (*my_charset_conv_wc_mb)(const charset_info_st*, my_wc_t, unsigned char*, unsigned char *);
 
112
typedef size_t (*my_charset_conv_case)(const charset_info_st*, char*, size_t, char*, size_t);
 
113
 
 
114
struct MY_UNICASE_INFO
116
115
{
117
116
  uint16_t toupper;
118
117
  uint16_t tolower;
119
118
  uint16_t sort;
120
 
} MY_UNICASE_INFO;
121
 
 
122
 
typedef struct uni_ctype_st
123
 
{
124
 
  unsigned char  pctype;
125
 
  unsigned char  *ctype;
126
 
} MY_UNI_CTYPE;
127
 
 
128
 
/* A helper function for "need at least n bytes" */
129
 
inline static int my_cs_toosmalln(int n)
130
 
{
131
 
  return -100-n;
132
 
}
133
 
 
134
 
typedef struct my_uni_idx_st
 
119
};
 
120
 
 
121
struct MY_UNI_CTYPE
 
122
{
 
123
  unsigned char pctype;
 
124
  unsigned char* ctype;
 
125
};
 
126
 
 
127
struct MY_UNI_IDX
135
128
{
136
129
  uint16_t from;
137
130
  uint16_t to;
138
131
  unsigned char  *tab;
139
 
} MY_UNI_IDX;
 
132
};
140
133
 
141
 
typedef struct
 
134
struct my_match_t
142
135
{
143
136
  uint32_t beg;
144
137
  uint32_t end;
145
138
  uint32_t mb_len;
146
 
} my_match_t;
 
139
};
147
140
 
148
141
enum my_lex_states
149
142
{
161
154
  MY_LEX_STRING_OR_DELIMITER
162
155
};
163
156
 
164
 
struct charset_info_st;
165
 
 
166
157
/* See strings/charset_info_st.txt for information about this structure  */
167
 
typedef struct my_collation_handler_st
 
158
struct MY_COLLATION_HANDLER
168
159
{
169
160
  bool (*init)(charset_info_st&, unsigned char *(*alloc)(size_t));
170
161
  /* Collation routines */
171
 
  int     (*strnncoll)(const struct charset_info_st * const,
172
 
                       const unsigned char *, size_t, const unsigned char *, size_t, bool);
173
 
  int     (*strnncollsp)(const struct charset_info_st * const,
174
 
                         const unsigned char *, size_t, const unsigned char *, size_t,
175
 
                         bool diff_if_only_endspace_difference);
176
 
  size_t  (*strnxfrm)(const struct charset_info_st * const,
177
 
                      unsigned char *dst, size_t dstlen, uint32_t nweights,
178
 
                      const unsigned char *src, size_t srclen, uint32_t flags);
179
 
  size_t    (*strnxfrmlen)(const struct charset_info_st * const, size_t);
180
 
  bool (*like_range)(const struct charset_info_st * const,
181
 
                        const char *s, size_t s_length,
182
 
                        char escape, char w_one, char w_many,
183
 
                        size_t res_length,
184
 
                        char *min_str, char *max_str,
185
 
                        size_t *min_len, size_t *max_len);
186
 
  int     (*wildcmp)(const struct charset_info_st * const,
187
 
                     const char *str,const char *str_end,
188
 
                     const char *wildstr,const char *wildend,
189
 
                     int escape,int w_one, int w_many);
190
 
 
191
 
  int  (*strcasecmp)(const struct charset_info_st * const, const char *, const char *);
192
 
 
193
 
  uint32_t (*instr)(const struct charset_info_st * const,
194
 
                const char *b, size_t b_length,
195
 
                const char *s, size_t s_length,
196
 
                my_match_t *match, uint32_t nmatch);
 
162
  int (*strnncoll)(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool);
 
163
  int (*strnncollsp)(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool diff_if_only_endspace_difference);
 
164
  size_t (*strnxfrm)(const charset_info_st*, unsigned char *dst, size_t dstlen, uint32_t nweights, const unsigned char *src, size_t srclen, uint32_t flags);
 
165
  size_t (*strnxfrmlen)(const charset_info_st*, size_t);
 
166
  bool (*like_range)(const charset_info_st*, const char *s, size_t s_length, char escape, char w_one, char w_many, 
 
167
    size_t res_length, char *min_str, char *max_str, size_t *min_len, size_t *max_len);
 
168
  int (*wildcmp)(const charset_info_st*, const char *str,const char *str_end, const char *wildstr, const char *wildend, int escape,int w_one, int w_many);
 
169
 
 
170
  int (*strcasecmp)(const charset_info_st*, const char*, const char *);
 
171
 
 
172
  uint32_t (*instr)(const charset_info_st*, const char *b, size_t b_length, const char *s, size_t s_length, my_match_t *match, uint32_t nmatch);
197
173
 
198
174
  /* Hash calculation */
199
 
  void (*hash_sort)(const struct charset_info_st *cs, const unsigned char *key, size_t len,
200
 
                    uint32_t *nr1, uint32_t *nr2);
201
 
  bool (*propagate)(const struct charset_info_st *cs, const unsigned char *str, size_t len);
202
 
} MY_COLLATION_HANDLER;
 
175
  void (*hash_sort)(const charset_info_st*, const unsigned char *key, size_t len, uint32_t *nr1, uint32_t *nr2);
 
176
  bool (*propagate)();
 
177
};
203
178
 
204
179
/* See strings/charset_info_st.txt about information on this structure  */
205
 
typedef struct my_charset_handler_st
 
180
struct MY_CHARSET_HANDLER
206
181
{
207
 
  void (*init_unused)();
208
182
  /* Multibyte routines */
209
 
  uint32_t    (*ismbchar)(const struct charset_info_st * const, const char *, const char *);
210
 
  uint32_t    (*mbcharlen)(const struct charset_info_st * const, uint32_t c);
211
 
  size_t  (*numchars)(const struct charset_info_st * const, const char *b, const char *e);
212
 
  size_t  (*charpos)(const struct charset_info_st * const, const char *b, const char *e,
213
 
                     size_t pos);
214
 
  size_t  (*well_formed_len)(const struct charset_info_st * const,
215
 
                             const char *b,const char *e,
216
 
                             size_t nchars, int *error);
217
 
  size_t  (*lengthsp)(const struct charset_info_st * const, const char *ptr, size_t length);
218
 
  size_t  (*numcells)(const struct charset_info_st * const, const char *b, const char *e);
 
183
  uint32_t (*ismbchar)(const charset_info_st*, const char*, const char *);
 
184
  uint32_t (*mbcharlen)(const charset_info_st*, uint32_t c);
 
185
  size_t (*numchars)(const charset_info_st*, const char *b, const char *e);
 
186
  size_t (*charpos)(const charset_info_st*, const char *b, const char *e, size_t pos);
 
187
  size_t (*well_formed_len)(const charset_info_st&, str_ref, size_t nchars, int *error);
 
188
  size_t (*lengthsp)(const charset_info_st*, const char *ptr, size_t length);
 
189
  size_t (*numcells)(const charset_info_st*, const char *b, const char *e);
219
190
 
220
191
  /* Unicode conversion */
221
192
  my_charset_conv_mb_wc mb_wc;
222
193
  my_charset_conv_wc_mb wc_mb;
223
194
 
224
195
  /* CTYPE scanner */
225
 
  int (*ctype)(const struct charset_info_st *cs, int *ctype,
226
 
               const unsigned char *s, const unsigned char *e);
 
196
  int (*ctype)(const charset_info_st *cs, int *ctype, const unsigned char *s, const unsigned char *e);
227
197
 
228
198
  /* Functions for case and sort conversion */
229
 
  size_t  (*caseup_str)(const struct charset_info_st * const, char *);
230
 
  size_t  (*casedn_str)(const struct charset_info_st * const, char *);
 
199
  size_t (*caseup_str)(const charset_info_st*, char *);
 
200
  size_t (*casedn_str)(const charset_info_st*, char *);
231
201
 
232
202
  my_charset_conv_case caseup;
233
203
  my_charset_conv_case casedn;
234
204
 
235
205
  /* Charset dependant snprintf() */
236
 
  size_t (*snprintf)(const struct charset_info_st * const, char *to, size_t n,
237
 
                     const char *fmt,
238
 
                     ...)
 
206
  size_t (*snprintf)(const charset_info_st*, char *to, size_t n, const char *fmt, ...)
239
207
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
240
208
                         __attribute__((format(printf, 4, 5)))
241
209
#endif
242
210
                         ;
243
 
  size_t (*long10_to_str)(const struct charset_info_st * const, char *to, size_t n,
244
 
                          int radix, long int val);
245
 
  size_t (*int64_t10_to_str)(const struct charset_info_st * const, char *to, size_t n,
246
 
                              int radix, int64_t val);
 
211
  size_t (*long10_to_str)(const charset_info_st*, char *to, size_t n, int radix, long int val);
 
212
  size_t (*int64_t10_to_str)(const charset_info_st*, char *to, size_t n, int radix, int64_t val);
247
213
 
248
 
  void (*fill)(const struct charset_info_st * const, char *to, size_t len, int fill);
 
214
  void (*fill)(const charset_info_st*, char *to, size_t len, int fill);
249
215
 
250
216
  /* String-to-number conversion routines */
251
 
  long        (*strntol)(const struct charset_info_st * const, const char *s, size_t l,
252
 
                         int base, char **e, int *err);
253
 
  unsigned long      (*strntoul)(const struct charset_info_st * const, const char *s, size_t l,
254
 
                         int base, char **e, int *err);
255
 
  int64_t   (*strntoll)(const struct charset_info_st * const, const char *s, size_t l,
256
 
                         int base, char **e, int *err);
257
 
  uint64_t (*strntoull)(const struct charset_info_st * const, const char *s, size_t l,
258
 
                         int base, char **e, int *err);
259
 
  double      (*strntod)(const struct charset_info_st * const, char *s, size_t l, char **e,
260
 
                         int *err);
261
 
  int64_t    (*strtoll10)(const struct charset_info_st *cs,
262
 
                           const char *nptr, char **endptr, int *error);
263
 
  uint64_t   (*strntoull10rnd)(const struct charset_info_st *cs,
264
 
                                const char *str, size_t length,
265
 
                                int unsigned_fl,
266
 
                                char **endptr, int *error);
267
 
  size_t        (*scan)(const struct charset_info_st * const, const char *b, const char *e,
268
 
                        int sq);
269
 
} MY_CHARSET_HANDLER;
270
 
 
 
217
  long (*strntol)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
 
218
  unsigned long (*strntoul)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
 
219
  int64_t (*strntoll)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
 
220
  uint64_t (*strntoull)(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
 
221
  double (*strntod)(const charset_info_st*, char *s, size_t l, char **e, int *err);
 
222
  int64_t (*strtoll10)(const charset_info_st*, const char *nptr, char **endptr, int *error);
 
223
  uint64_t (*strntoull10rnd)(const charset_info_st*, const char *str, size_t length, int unsigned_fl, char **endptr, int *error);
 
224
  size_t (*scan)(const charset_info_st*, const char *b, const char *e, int sq);
 
225
};
271
226
 
272
227
/* See strings/charset_info_st.txt about information on this structure  */
273
228
struct charset_info_st
299
254
  uint16_t    min_sort_char;
300
255
  uint16_t    max_sort_char; /* For LIKE optimization */
301
256
  unsigned char     pad_char;
302
 
  bool   escape_with_backslash_is_dangerous;
303
257
  unsigned char     levels_for_compare;
304
258
  unsigned char     levels_for_order;
305
259
 
306
260
  MY_CHARSET_HANDLER *cset;
307
261
  MY_COLLATION_HANDLER *coll;
308
262
 
 
263
  bool isalpha(unsigned char c) const
 
264
  {
 
265
    return ctype[c + 1] & (_MY_U | _MY_L);
 
266
  }
 
267
 
 
268
  bool isupper(unsigned char c) const
 
269
  {
 
270
    return ctype[c + 1] & _MY_U;
 
271
  }
 
272
 
 
273
  bool islower(unsigned char c) const
 
274
  {
 
275
    return ctype[c + 1] & _MY_L;
 
276
  }
 
277
 
 
278
  bool isdigit(unsigned char c) const
 
279
  {
 
280
    return ctype[c + 1] & _MY_NMR;
 
281
  }
 
282
 
 
283
  bool isxdigit(unsigned char c) const
 
284
  {
 
285
    return ctype[c + 1] & _MY_X;
 
286
  }
 
287
 
 
288
  bool isalnum(unsigned char c) const
 
289
  {
 
290
    return ctype[c + 1] & (_MY_U | _MY_L | _MY_NMR);
 
291
  }
 
292
 
 
293
  bool isspace(unsigned char c) const
 
294
  {
 
295
    return ctype[c + 1] & _MY_SPC;
 
296
  }
 
297
 
 
298
  bool ispunct(unsigned char c) const  
 
299
  {
 
300
    return ctype[c + 1] & _MY_PNT;
 
301
  }
 
302
 
 
303
  bool isprint(unsigned char c) const
 
304
  {
 
305
    return ctype[c + 1] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B);
 
306
  }
 
307
 
 
308
  bool isgraph(unsigned char c) const
 
309
  {
 
310
    return ctype[c + 1] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR);
 
311
  }
 
312
 
 
313
  bool iscntrl(unsigned char c) const
 
314
  {
 
315
    return ctype[c + 1] & _MY_CTR;
 
316
  }
 
317
 
 
318
  bool isvar(char c) const
 
319
  {
 
320
    return isalnum(c) || (c) == '_';
 
321
  }
 
322
 
 
323
  char toupper(unsigned char c) const
 
324
  {
 
325
    return to_upper[c];
 
326
  }
 
327
 
 
328
  char tolower(unsigned char c) const
 
329
  {
 
330
    return to_lower[c];
 
331
  }
 
332
 
 
333
  bool binary_compare() const
 
334
  {
 
335
    return state  & MY_CS_BINSORT;
 
336
  }
 
337
 
 
338
  bool use_strnxfrm() const
 
339
  {
 
340
    return state & MY_CS_STRNXFRM;
 
341
  }
 
342
 
 
343
  size_t strnxfrm(unsigned char *dst, const size_t dstlen, const unsigned char *src, const uint32_t srclen) const
 
344
  {
 
345
    return coll->strnxfrm(this, dst, dstlen, dstlen, src, srclen, MY_STRXFRM_PAD_WITH_SPACE);
 
346
  }
 
347
 
 
348
  int strcasecmp(const char *s, const char *t) const
 
349
  {
 
350
    return coll->strcasecmp(this, s, t);
 
351
  }
 
352
 
 
353
  size_t caseup_str(char* src) const
 
354
  {
 
355
    return cset->caseup_str(this, src);
 
356
  }
 
357
 
 
358
  size_t casedn_str(char* src) const
 
359
  {
 
360
    return cset->casedn_str(this, src);
 
361
  }
309
362
};
310
363
 
311
364
extern DRIZZLED_API charset_info_st *all_charsets[256];
312
 
extern charset_info_st compiled_charsets[];
313
 
extern uint32_t get_charset_number(const char *cs_name, uint32_t cs_flags);
314
 
extern uint32_t get_collation_number(const char *name);
315
 
extern const char *get_charset_name(uint32_t cs_number);
316
 
extern bool resolve_charset(const char *cs_name,
317
 
                            const charset_info_st *default_cs,
318
 
                            const charset_info_st **cs);
319
 
extern bool resolve_collation(const char *cl_name,
320
 
                             const charset_info_st *default_cl,
321
 
                             const charset_info_st **cl);
322
 
extern void free_charsets();
323
 
extern char *get_charsets_dir(char *buf);
324
 
extern bool my_charset_same(const charset_info_st *cs1, const charset_info_st *cs2);
325
 
extern size_t escape_string_for_drizzle(const charset_info_st *charset_info,
326
 
                                        char *to, size_t to_length,
327
 
                                        const char *from, size_t length);
328
 
extern size_t escape_quotes_for_drizzle(const charset_info_st *charset_info,
329
 
                                        char *to, size_t to_length,
330
 
                                        const char *from, size_t length);
 
365
uint32_t get_charset_number(const char *cs_name, uint32_t cs_flags);
 
366
uint32_t get_collation_number(const char *name);
 
367
const char *get_charset_name(uint32_t cs_number);
 
368
void free_charsets();
 
369
bool my_charset_same(const charset_info_st*, const charset_info_st*);
 
370
size_t escape_string_for_drizzle(const charset_info_st *charset_info, char *to, size_t to_length, const char *from, size_t length);
 
371
size_t escape_quotes_for_drizzle(const charset_info_st *charset_info, char *to, size_t to_length, const char *from, size_t length);
331
372
extern DRIZZLED_API const charset_info_st *default_charset_info;
332
373
extern DRIZZLED_API const charset_info_st *system_charset_info;
333
374
extern const charset_info_st *files_charset_info;
339
380
extern DRIZZLED_API charset_info_st my_charset_utf8mb4_bin;
340
381
extern DRIZZLED_API charset_info_st my_charset_utf8mb4_general_ci;
341
382
extern DRIZZLED_API charset_info_st my_charset_utf8mb4_unicode_ci;
342
 
size_t my_strnxfrmlen_simple(const charset_info_st * const, size_t);
343
 
extern int  my_strnncollsp_simple(const charset_info_st * const, const unsigned char *, size_t,
344
 
                                  const unsigned char *, size_t,
345
 
                                  bool diff_if_only_endspace_difference);
346
 
extern size_t my_lengthsp_8bit(const charset_info_st * const cs, const char *ptr, size_t length);
347
 
extern uint32_t my_instr_simple(const charset_info_st * const,
348
 
                            const char *b, size_t b_length,
349
 
                            const char *s, size_t s_length,
350
 
                            my_match_t *match, uint32_t nmatch);
351
 
extern MY_CHARSET_HANDLER my_charset_8bit_handler;
352
 
extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
353
 
extern int my_strcasecmp_mb(const charset_info_st * const  cs, const char *s, const char *t);
354
 
extern bool my_parse_charset_xml(const char *bug, size_t len,
355
 
                                    int (*add)(charset_info_st *cs));
 
383
size_t my_strnxfrmlen_simple(const charset_info_st*, size_t);
 
384
int my_strnncollsp_simple(const charset_info_st*, const unsigned char*, size_t, const unsigned char*, size_t, bool diff_if_only_endspace_difference);
 
385
size_t my_lengthsp_8bit(const charset_info_st*, const char *ptr, size_t length);
 
386
uint32_t my_instr_simple(const charset_info_st*, const char *b, size_t b_length, const char *s, size_t s_length, my_match_t *match, uint32_t nmatch);
 
387
int my_strcasecmp_mb(const charset_info_st*, const char *s, const char *t);
356
388
 
357
389
DRIZZLED_API const charset_info_st *get_charset(uint32_t cs_number);
358
390
DRIZZLED_API const charset_info_st *get_charset_by_name(const char *cs_name);
359
391
DRIZZLED_API const charset_info_st *get_charset_by_csname(const char *cs_name, uint32_t cs_flags);
360
392
 
361
393
/* Functions for 8bit */
362
 
int my_mb_ctype_8bit(const charset_info_st * const,int *, const unsigned char *,const unsigned char *);
363
 
int my_mb_ctype_mb(const charset_info_st * const,int *, const unsigned char *,const unsigned char *);
364
 
 
365
 
size_t my_scan_8bit(const charset_info_st * const cs, const char *b, const char *e, int sq);
366
 
 
367
 
size_t my_snprintf_8bit(const charset_info_st * const, char *to, size_t n,
368
 
                        const char *fmt, ...)
369
 
  __attribute__((format(printf, 4, 5)));
370
 
 
371
 
long       my_strntol_8bit(const charset_info_st * const, const char *s, size_t l, int base,
372
 
                           char **e, int *err);
373
 
unsigned long      my_strntoul_8bit(const charset_info_st * const, const char *s, size_t l, int base,
374
 
                            char **e, int *err);
375
 
int64_t   my_strntoll_8bit(const charset_info_st * const, const char *s, size_t l, int base,
376
 
                            char **e, int *err);
377
 
uint64_t my_strntoull_8bit(const charset_info_st * const, const char *s, size_t l, int base,
378
 
                            char **e, int *err);
379
 
double      my_strntod_8bit(const charset_info_st * const, char *s, size_t l,char **e,
380
 
                            int *err);
381
 
size_t my_long10_to_str_8bit(const charset_info_st * const, char *to, size_t l, int radix,
382
 
                             long int val);
383
 
size_t my_int64_t10_to_str_8bit(const charset_info_st * const, char *to, size_t l, int radix,
384
 
                                 int64_t val);
385
 
int64_t my_strtoll10_8bit(const charset_info_st * const cs,
386
 
                           const char *nptr, char **endptr, int *error);
387
 
int64_t my_strtoll10_ucs2(charset_info_st *cs,
388
 
                           const char *nptr, char **endptr, int *error);
389
 
 
390
 
uint64_t my_strntoull10rnd_8bit(const charset_info_st * const cs,
391
 
                                 const char *str, size_t length, int
392
 
                                 unsigned_fl, char **endptr, int *error);
393
 
uint64_t my_strntoull10rnd_ucs2(charset_info_st *cs,
394
 
                                 const char *str, size_t length,
395
 
                                 int unsigned_fl, char **endptr, int *error);
396
 
 
397
 
void my_fill_8bit(const charset_info_st * const cs, char* to, size_t l, int fill);
398
 
 
399
 
bool  my_like_range_simple(const charset_info_st * const cs,
 
394
int my_mb_ctype_8bit(const charset_info_st*, int*, const unsigned char*, const unsigned char *);
 
395
int my_mb_ctype_mb(const charset_info_st*, int*, const unsigned char*, const unsigned char *);
 
396
 
 
397
size_t my_scan_8bit(const charset_info_st*, const char *b, const char *e, int sq);
 
398
size_t my_snprintf_8bit(const charset_info_st*, char *to, size_t n, const char *fmt, ...) __attribute__((format(printf, 4, 5)));
 
399
 
 
400
long my_strntol_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
 
401
unsigned long my_strntoul_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
 
402
int64_t my_strntoll_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
 
403
uint64_t my_strntoull_8bit(const charset_info_st*, const char *s, size_t l, int base, char **e, int *err);
 
404
double my_strntod_8bit(const charset_info_st*, char *s, size_t l,char **e, int *err);
 
405
size_t my_long10_to_str_8bit(const charset_info_st*, char *to, size_t l, int radix, long int val);
 
406
size_t my_int64_t10_to_str_8bit(const charset_info_st*, char *to, size_t l, int radix, int64_t val);
 
407
int64_t my_strtoll10_8bit(const charset_info_st*, const char *nptr, char **endptr, int *error);
 
408
 
 
409
uint64_t my_strntoull10rnd_8bit(const charset_info_st*, const char *str, size_t length, int unsigned_fl, char **endptr, int *error);
 
410
 
 
411
void my_fill_8bit(const charset_info_st*, char* to, size_t l, int fill);
 
412
 
 
413
bool  my_like_range_simple(const charset_info_st*,
400
414
                              const char *ptr, size_t ptr_length,
401
415
                              char escape, char w_one, char w_many,
402
416
                              size_t res_length,
403
417
                              char *min_str, char *max_str,
404
418
                              size_t *min_length, size_t *max_length);
405
419
 
406
 
bool  my_like_range_mb(const charset_info_st * const cs,
 
420
bool  my_like_range_mb(const charset_info_st*,
407
421
                          const char *ptr, size_t ptr_length,
408
422
                          char escape, char w_one, char w_many,
409
423
                          size_t res_length,
410
424
                          char *min_str, char *max_str,
411
425
                          size_t *min_length, size_t *max_length);
412
426
 
413
 
bool  my_like_range_ucs2(const charset_info_st * const cs,
414
 
                            const char *ptr, size_t ptr_length,
415
 
                            char escape, char w_one, char w_many,
416
 
                            size_t res_length,
417
 
                            char *min_str, char *max_str,
418
 
                            size_t *min_length, size_t *max_length);
419
 
 
420
 
bool  my_like_range_utf16(const charset_info_st * const cs,
421
 
                             const char *ptr, size_t ptr_length,
422
 
                             char escape, char w_one, char w_many,
423
 
                             size_t res_length,
424
 
                             char *min_str, char *max_str,
425
 
                             size_t *min_length, size_t *max_length);
426
 
 
427
 
bool  my_like_range_utf32(const charset_info_st * const cs,
428
 
                             const char *ptr, size_t ptr_length,
429
 
                             char escape, char w_one, char w_many,
430
 
                             size_t res_length,
431
 
                             char *min_str, char *max_str,
432
 
                             size_t *min_length, size_t *max_length);
433
 
 
434
 
 
435
 
int my_wildcmp_8bit(const charset_info_st * const,
 
427
int my_wildcmp_8bit(const charset_info_st*,
436
428
                    const char *str,const char *str_end,
437
429
                    const char *wildstr,const char *wildend,
438
430
                    int escape, int w_one, int w_many);
439
431
 
440
 
int my_wildcmp_bin(const charset_info_st * const,
 
432
int my_wildcmp_bin(const charset_info_st*,
441
433
                   const char *str,const char *str_end,
442
434
                   const char *wildstr,const char *wildend,
443
435
                   int escape, int w_one, int w_many);
444
436
 
445
 
size_t my_numchars_8bit(const charset_info_st * const, const char *b, const char *e);
446
 
size_t my_numcells_8bit(const charset_info_st * const, const char *b, const char *e);
447
 
size_t my_charpos_8bit(const charset_info_st * const, const char *b, const char *e, size_t pos);
448
 
size_t my_well_formed_len_8bit(const charset_info_st * const, const char *b, const char *e,
449
 
                             size_t pos, int *error);
 
437
size_t my_numchars_8bit(const charset_info_st*, const char *b, const char *e);
 
438
size_t my_numcells_8bit(const charset_info_st*, const char *b, const char *e);
 
439
size_t my_charpos_8bit(const charset_info_st*, const char *b, const char *e, size_t pos);
 
440
size_t my_well_formed_len_8bit(const charset_info_st&, str_ref, size_t pos, int *error);
450
441
typedef unsigned char *(*cs_alloc_func)(size_t);
451
442
bool my_coll_init_simple(charset_info_st *cs, cs_alloc_func alloc);
452
443
bool my_cset_init_8bit(charset_info_st *cs, cs_alloc_func alloc);
453
 
uint32_t my_mbcharlen_8bit(const charset_info_st * const, uint32_t c);
 
444
uint32_t my_mbcharlen_8bit(const charset_info_st*, uint32_t c);
454
445
 
455
446
/* Functions for multibyte charsets */
456
 
int my_wildcmp_mb(const charset_info_st * const,
 
447
int my_wildcmp_mb(const charset_info_st*,
457
448
                  const char *str,const char *str_end,
458
449
                  const char *wildstr,const char *wildend,
459
450
                  int escape, int w_one, int w_many);
460
 
size_t my_numchars_mb(const charset_info_st * const, const char *b, const char *e);
461
 
size_t my_numcells_mb(const charset_info_st * const, const char *b, const char *e);
462
 
size_t my_charpos_mb(const charset_info_st * const, const char *b, const char *e, size_t pos);
463
 
size_t my_well_formed_len_mb(const charset_info_st * const, const char *b, const char *e,
464
 
                             size_t pos, int *error);
465
 
uint32_t my_instr_mb(const charset_info_st * const,
 
451
size_t my_numchars_mb(const charset_info_st*, const char *b, const char *e);
 
452
size_t my_numcells_mb(const charset_info_st*, const char *b, const char *e);
 
453
size_t my_charpos_mb(const charset_info_st*, const char *b, const char *e, size_t pos);
 
454
size_t my_well_formed_len_mb(const charset_info_st&, str_ref, size_t pos, int *error);
 
455
uint32_t my_instr_mb(const charset_info_st*,
466
456
                 const char *b, size_t b_length,
467
457
                 const char *s, size_t s_length,
468
458
                 my_match_t *match, uint32_t nmatch);
469
459
 
470
 
int my_strnncoll_mb_bin(const charset_info_st * const  cs,
 
460
int my_strnncoll_mb_bin(const charset_info_st*  cs,
471
461
                        const unsigned char *s, size_t slen,
472
462
                        const unsigned char *t, size_t tlen,
473
463
                        bool t_is_prefix);
474
464
 
475
 
int my_strnncollsp_mb_bin(const charset_info_st * const cs,
 
465
int my_strnncollsp_mb_bin(const charset_info_st*,
476
466
                          const unsigned char *a, size_t a_length,
477
467
                          const unsigned char *b, size_t b_length,
478
468
                          bool diff_if_only_endspace_difference);
479
469
 
480
 
int my_wildcmp_mb_bin(const charset_info_st * const cs,
 
470
int my_wildcmp_mb_bin(const charset_info_st*,
481
471
                      const char *str,const char *str_end,
482
472
                      const char *wildstr,const char *wildend,
483
473
                      int escape, int w_one, int w_many);
484
474
 
485
 
int my_strcasecmp_mb_bin(const charset_info_st * const, const char *s, const char *t);
 
475
int my_strcasecmp_mb_bin(const charset_info_st*, const char *s, const char *t);
486
476
 
487
 
void my_hash_sort_mb_bin(const charset_info_st * const,
 
477
void my_hash_sort_mb_bin(const charset_info_st*,
488
478
                         const unsigned char *key, size_t len, uint32_t *nr1, uint32_t *nr2);
489
479
 
490
 
size_t my_strnxfrm_mb(const charset_info_st * const,
 
480
size_t my_strnxfrm_mb(const charset_info_st*,
491
481
                      unsigned char *dst, size_t dstlen, uint32_t nweights,
492
482
                      const unsigned char *src, size_t srclen, uint32_t flags);
493
483
 
494
 
int my_wildcmp_unicode(const charset_info_st * const cs,
 
484
int my_wildcmp_unicode(const charset_info_st*,
495
485
                       const char *str, const char *str_end,
496
486
                       const char *wildstr, const char *wildend,
497
487
                       int escape, int w_one, int w_many,
498
488
                       MY_UNICASE_INFO **weights);
499
489
 
500
 
bool my_propagate_simple(const charset_info_st * const cs, const unsigned char *str, size_t len);
501
 
bool my_propagate_complex(const charset_info_st * const cs, const unsigned char *str, size_t len);
 
490
bool my_propagate_simple();
 
491
bool my_propagate_complex();
502
492
 
503
493
 
504
494
uint32_t my_strxfrm_flag_normalize(uint32_t flags, uint32_t nlevels);
505
495
void my_strxfrm_desc_and_reverse(unsigned char *str, unsigned char *strend,
506
496
                                 uint32_t flags, uint32_t level);
507
 
size_t my_strxfrm_pad_desc_and_reverse(const charset_info_st * const cs,
 
497
size_t my_strxfrm_pad_desc_and_reverse(const charset_info_st*,
508
498
                                       unsigned char *str, unsigned char *frmend, unsigned char *strend,
509
499
                                       uint32_t nweights, uint32_t flags, uint32_t level);
510
500
 
511
 
bool my_charset_is_ascii_compatible(const charset_info_st * const cs);
 
501
bool my_charset_is_ascii_compatible(const charset_info_st*);
512
502
 
513
503
/*
514
504
  Compare 0-terminated UTF8 strings.
526
516
    - positive number if s > t
527
517
    - 0 is the strings are equal
528
518
*/
529
 
int my_wc_mb_filename(const charset_info_st * const,
530
 
                  my_wc_t wc, unsigned char *s, unsigned char *e);
531
 
 
532
 
int my_mb_wc_filename(const charset_info_st * const,
533
 
                  my_wc_t *pwc, const unsigned char *s, const unsigned char *e);
534
 
 
535
 
 
536
 
unsigned int my_ismbchar_utf8mb4(const charset_info_st * const cs, const char *b, const char *e);
537
 
unsigned int my_mbcharlen_utf8mb4(const charset_info_st * const, uint32_t c);
538
 
 
539
 
size_t my_strnxfrmlen_utf8mb4(const charset_info_st * const, size_t len);
540
 
size_t
541
 
my_strnxfrm_utf8mb4(const charset_info_st * const cs,
542
 
                    unsigned char *dst, size_t dstlen, uint32_t nweights,
543
 
                    const unsigned char *src, size_t srclen, uint32_t flags);
544
 
 
545
 
int my_wildcmp_utf8mb4(const charset_info_st * const cs,
546
 
                   const char *str, const char *strend,
547
 
                   const char *wildstr, const char *wildend,
548
 
                   int escape, int w_one, int w_many);
549
 
int my_strnncollsp_utf8mb4(const charset_info_st * const cs,
550
 
                       const unsigned char *s, size_t slen,
551
 
                       const unsigned char *t, size_t tlen,
552
 
                       bool diff_if_only_endspace_difference);
553
 
int my_strcasecmp_utf8mb4(const charset_info_st * const cs,
554
 
                          const char *s, const char *t);
555
 
 
556
 
int my_strnncoll_utf8mb4(const charset_info_st * const cs,
557
 
                     const unsigned char *s, size_t slen,
558
 
                     const unsigned char *t, size_t tlen,
559
 
                     bool t_is_prefix);
560
 
 
561
 
int my_mb_wc_utf8mb4(const charset_info_st * const cs,
562
 
                 my_wc_t * pwc, const unsigned char *s, const unsigned char *e);
563
 
 
564
 
int my_wc_mb_utf8mb4(const charset_info_st * const cs,
565
 
                 my_wc_t wc, unsigned char *r, unsigned char *e);
566
 
 
567
 
size_t my_caseup_str_utf8mb4(const charset_info_st * const cs, char *src);
568
 
size_t my_casedn_str_utf8mb4(const charset_info_st * const cs, char *src);
569
 
 
570
 
size_t my_caseup_utf8mb4(const charset_info_st * const cs, char *src, size_t srclen,
571
 
                  char *dst, size_t dstlen);
572
 
size_t my_casedn_utf8mb4(const charset_info_st * const cs,
573
 
                  char *src, size_t srclen,
574
 
                  char *dst, size_t dstlen);
575
 
 
576
 
 
577
 
int my_strnncoll_any_uca(const charset_info_st * const cs,
578
 
                         const unsigned char *s, size_t slen,
579
 
                         const unsigned char *t, size_t tlen,
580
 
                         bool t_is_prefix);
581
 
 
582
 
int my_strnncollsp_any_uca(const charset_info_st * const cs,
583
 
                           const unsigned char *s, size_t slen,
584
 
                           const unsigned char *t, size_t tlen,
585
 
                           bool diff_if_only_endspace_difference);
586
 
 
587
 
void my_hash_sort_any_uca(const charset_info_st * const cs,
588
 
                          const unsigned char *s, size_t slen,
589
 
                          uint32_t *n1, uint32_t *n2);
590
 
 
591
 
size_t my_strnxfrm_any_uca(const charset_info_st * const cs,
592
 
                           unsigned char *dst, size_t dstlen, uint32_t nweights,
593
 
                           const unsigned char *src, size_t srclen,
594
 
                           uint32_t flags);
595
 
 
596
 
int my_wildcmp_uca(const charset_info_st * const cs,
597
 
                   const char *str,const char *str_end,
598
 
                   const char *wildstr,const char *wildend,
599
 
                   int escape, int w_one, int w_many);
600
 
 
601
 
int my_strnncoll_8bit_bin(const charset_info_st * const,
 
519
int my_wc_mb_filename(const charset_info_st*, my_wc_t wc, unsigned char *s, unsigned char *e);
 
520
int my_mb_wc_filename(const charset_info_st*, my_wc_t *pwc, const unsigned char *s, const unsigned char *e);
 
521
 
 
522
int my_strnncoll_8bit_bin(const charset_info_st*,
602
523
                          const unsigned char *s, size_t slen,
603
524
                          const unsigned char *t, size_t tlen,
604
525
                          bool t_is_prefix);
605
 
int my_strnncollsp_8bit_bin(const charset_info_st * const,
 
526
int my_strnncollsp_8bit_bin(const charset_info_st*,
606
527
                            const unsigned char *a, size_t a_length,
607
528
                            const unsigned char *b, size_t b_length,
608
529
                            bool diff_if_only_endspace_difference);
609
 
size_t my_case_str_bin(const charset_info_st * const, char *);
610
 
size_t my_case_bin(const charset_info_st * const, char *,
611
 
                   size_t srclen, char *, size_t);
612
 
int my_strcasecmp_bin(const charset_info_st * const,
 
530
size_t my_case_str_bin(const charset_info_st*, char *);
 
531
size_t my_case_bin(const charset_info_st*, char*,
 
532
                   size_t srclen, char*, size_t);
 
533
int my_strcasecmp_bin(const charset_info_st*,
613
534
                      const char *s, const char *t);
614
 
size_t my_strnxfrm_8bit_bin(const charset_info_st * const cs,
 
535
size_t my_strnxfrm_8bit_bin(const charset_info_st*,
615
536
                     unsigned char * dst, size_t dstlen, uint32_t nweights,
616
537
                     const unsigned char *src, size_t srclen, uint32_t flags);
617
 
uint32_t my_instr_bin(const charset_info_st * const,
 
538
uint32_t my_instr_bin(const charset_info_st*,
618
539
                      const char *b, size_t b_length,
619
540
                      const char *s, size_t s_length,
620
541
                      my_match_t *match, uint32_t nmatch);
621
 
size_t my_lengthsp_binary(const charset_info_st * const,
622
 
                          const char *, size_t length);
623
 
int my_mb_wc_bin(const charset_info_st * const,
 
542
size_t my_lengthsp_binary(const charset_info_st*,
 
543
                          const char*, size_t length);
 
544
int my_mb_wc_bin(const charset_info_st*,
624
545
                 my_wc_t *wc, const unsigned char *str,
625
546
                 const unsigned char *end);
626
 
int my_wc_mb_bin(const charset_info_st * const, my_wc_t wc,
 
547
int my_wc_mb_bin(const charset_info_st*, my_wc_t wc,
627
548
                 unsigned char *str, unsigned char *end);
628
 
void my_hash_sort_8bit_bin(const charset_info_st * const,
 
549
void my_hash_sort_8bit_bin(const charset_info_st*,
629
550
                           const unsigned char *key, size_t len,
630
551
                           uint32_t *nr1, uint32_t *nr2);
631
552
bool my_coll_init_8bit_bin(charset_info_st *cs,
632
553
                           cs_alloc_func);
633
 
int my_strnncoll_binary(const charset_info_st * const,
 
554
int my_strnncoll_binary(const charset_info_st*,
634
555
                        const unsigned char *s, size_t slen,
635
556
                        const unsigned char *t, size_t tlen,
636
557
                        bool t_is_prefix);
637
 
int my_strnncollsp_binary(const charset_info_st * const cs,
 
558
int my_strnncollsp_binary(const charset_info_st*,
638
559
                          const unsigned char *s, size_t slen,
639
560
                          const unsigned char *t, size_t tlen,
640
561
                          bool);
641
562
 
642
 
inline static bool my_isascii(char c)      
643
 
{
644
 
  return (!(c & ~0177));
645
 
}
646
 
 
647
 
inline static char my_toascii(char c)
648
 
{
649
 
  return (c & 0177);
650
 
}
651
 
 
652
 
inline static char my_tocntrl(char c) 
653
 
{
654
 
  return (c & 31);
655
 
}
656
 
 
657
 
inline static char my_toprint(char c)
658
 
{
659
 
  return (c | 64);
660
 
}
661
 
 
662
 
inline static char my_toupper(const charset_info_st *s, unsigned char c)
663
 
{
664
 
  return s->to_upper[c];
665
 
}
666
 
 
667
 
inline static char my_tolower(const charset_info_st *s, unsigned char c)
668
 
{
669
 
  return s->to_lower[c];
670
 
}
671
 
 
672
 
inline static bool my_isalpha(const charset_info_st *s, unsigned char c)
673
 
{
674
 
  return (s->ctype+1)[c] & (_MY_U | _MY_L);
675
 
}
676
 
 
677
 
inline static bool my_isupper(const charset_info_st *s, unsigned char c)
678
 
{
679
 
  return (s->ctype+1)[c] & _MY_U;
680
 
}
681
 
 
682
 
inline static bool my_islower(const charset_info_st *s, unsigned char c)
683
 
{
684
 
  return (s->ctype+1)[c] & _MY_L;
685
 
}
686
 
 
687
 
inline static bool my_isdigit(const charset_info_st *s, unsigned char c)
688
 
{
689
 
  return (s->ctype+1)[c] & _MY_NMR;
690
 
}
691
 
 
692
 
inline static bool my_isxdigit(const charset_info_st *s, unsigned char c)
693
 
{
694
 
  return (s->ctype+1)[c] & _MY_X;
695
 
}
696
 
 
697
 
inline static bool my_isalnum(const charset_info_st *s, unsigned char c) 
698
 
{
699
 
  return (s->ctype+1)[c] & (_MY_U | _MY_L | _MY_NMR);
700
 
}
701
 
 
702
 
inline static bool my_isspace(const charset_info_st *s, unsigned char c)
703
 
{
704
 
  return (s->ctype+1)[c] & _MY_SPC;
705
 
}
706
 
 
707
 
inline static bool my_ispunct(const charset_info_st *s, unsigned char c)  
708
 
{
709
 
  return (s->ctype+1)[c] & _MY_PNT;
710
 
}
711
 
 
712
 
inline static bool my_isprint(const charset_info_st *s, unsigned char c)  
713
 
{
714
 
  return (s->ctype+1)[c] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B);
715
 
}
716
 
 
717
 
inline static bool my_isgraph(const charset_info_st *s, unsigned char c)
718
 
{
719
 
  return (s->ctype+1)[c] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR);
720
 
}
721
 
 
722
 
inline static bool my_iscntrl(const charset_info_st *s, unsigned char c)  
723
 
{
724
 
  return (s->ctype+1)[c] & _MY_CTR;
725
 
}
726
 
 
727
 
/* Some macros that should be cleaned up a little */
728
 
inline static bool my_isvar(const charset_info_st *s, char c)
729
 
{
730
 
  return my_isalnum(s,c) || (c) == '_';
731
 
}
732
 
 
733
 
inline static bool my_isvar_start(const charset_info_st *s, char c)
734
 
{
735
 
  return my_isalpha(s,c) || (c) == '_';
736
 
}
737
 
 
738
 
inline static bool my_binary_compare(const charset_info_st *s)
739
 
{
740
 
  return s->state  & MY_CS_BINSORT;
741
 
}
742
 
 
743
 
inline static bool use_strnxfrm(const charset_info_st *s)
744
 
{
745
 
  return s->state & MY_CS_STRNXFRM;
746
 
}
747
 
 
748
 
inline static size_t my_strnxfrm(const charset_info_st *cs, 
749
 
                                 unsigned char *dst, 
750
 
                                 const size_t dstlen, 
751
 
                                 const unsigned char *src, 
752
 
                                 const uint32_t srclen)
753
 
{
754
 
  return (cs->coll->strnxfrm(cs, dst, dstlen, dstlen, src, srclen, MY_STRXFRM_PAD_WITH_SPACE));
755
 
}
756
 
 
757
563
inline static int my_strnncoll(const charset_info_st *cs, 
758
564
                               const unsigned char *s, 
759
565
                               const size_t slen, 
785
591
  return (cs->coll->wildcmp(cs, str, strend, w_str, w_strend, escape, w_one, w_many));
786
592
}
787
593
 
788
 
inline static int my_strcasecmp(const charset_info_st *cs, const char *s, const char *t)
789
 
{
790
 
  return (cs->coll->strcasecmp(cs, s, t));
791
 
}
792
 
 
793
594
template <typename CHAR_T>
794
595
inline static size_t my_charpos(const charset_info_st *cs, 
795
596
                                const CHAR_T *b, const CHAR_T* e, size_t num)
813
614
}
814
615
 
815
616
 
816
 
inline static size_t my_caseup_str(const charset_info_st *cs, char *src)
817
 
{
818
 
  return cs->cset->caseup_str(cs, src);
819
 
}
820
 
 
821
 
inline static size_t my_casedn_str(const charset_info_st *cs, char *src)
822
 
{
823
 
  return cs->cset->casedn_str(cs, src);
824
 
}
825
 
 
826
617
inline static long my_strntol(const charset_info_st *cs, 
827
618
                              const char* s, const size_t l, const int base, char **e, int *err)
828
619
{
856
647
  return (cs->cset->strntod(cs, s, l, e, err));
857
648
}
858
649
 
859
 
int make_escape_code(const charset_info_st * const cs, const char *escape);
 
650
int make_escape_code(const charset_info_st*, const char *escape);
860
651
 
861
652
} /* namespace drizzled */
862