666
655
#define _MY_X 0200 /* heXadecimal digit */
669
inline static bool my_isascii(char c)
671
return (!(c & ~0177));
674
inline static char my_toascii(char c)
679
inline static char my_tocntrl(char c)
684
inline static char my_toprint(char c)
689
inline static char my_toupper(const charset_info_st *s, unsigned char c)
691
return s->to_upper[c];
694
inline static char my_tolower(const charset_info_st *s, unsigned char c)
696
return s->to_lower[c];
699
inline static bool my_isalpha(const charset_info_st *s, unsigned char c)
701
return (s->ctype+1)[c] & (_MY_U | _MY_L);
704
inline static bool my_isupper(const charset_info_st *s, unsigned char c)
706
return (s->ctype+1)[c] & _MY_U;
709
inline static bool my_islower(const charset_info_st *s, unsigned char c)
711
return (s->ctype+1)[c] & _MY_L;
714
inline static bool my_isdigit(const charset_info_st *s, unsigned char c)
716
return (s->ctype+1)[c] & _MY_NMR;
719
inline static bool my_isxdigit(const charset_info_st *s, unsigned char c)
721
return (s->ctype+1)[c] & _MY_X;
724
inline static bool my_isalnum(const charset_info_st *s, unsigned char c)
726
return (s->ctype+1)[c] & (_MY_U | _MY_L | _MY_NMR);
729
inline static bool my_isspace(const charset_info_st *s, unsigned char c)
731
return (s->ctype+1)[c] & _MY_SPC;
734
inline static bool my_ispunct(const charset_info_st *s, unsigned char c)
736
return (s->ctype+1)[c] & _MY_PNT;
739
inline static bool my_isprint(const charset_info_st *s, unsigned char c)
741
return (s->ctype+1)[c] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B);
744
inline static bool my_isgraph(const charset_info_st *s, unsigned char c)
746
return (s->ctype+1)[c] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR);
749
inline static bool my_iscntrl(const charset_info_st *s, unsigned char c)
751
return (s->ctype+1)[c] & _MY_CTR;
658
#define my_isascii(c) (!((c) & ~0177))
659
#define my_toascii(c) ((c) & 0177)
660
#define my_tocntrl(c) ((c) & 31)
661
#define my_toprint(c) ((c) | 64)
662
#define my_toupper(s,c) (char) ((s)->to_upper[(unsigned char) (c)])
663
#define my_tolower(s,c) (char) ((s)->to_lower[(unsigned char) (c)])
664
#define my_isalpha(s, c) (((s)->ctype+1)[(unsigned char) (c)] & (_MY_U | _MY_L))
665
#define my_isupper(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_U)
666
#define my_islower(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_L)
667
#define my_isdigit(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_NMR)
668
#define my_isxdigit(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_X)
669
#define my_isalnum(s, c) (((s)->ctype+1)[(unsigned char) (c)] & (_MY_U | _MY_L | _MY_NMR))
670
#define my_isspace(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_SPC)
671
#define my_ispunct(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_PNT)
672
#define my_isprint(s, c) (((s)->ctype+1)[(unsigned char) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
673
#define my_isgraph(s, c) (((s)->ctype+1)[(unsigned char) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
674
#define my_iscntrl(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_CTR)
754
676
/* Some macros that should be cleaned up a little */
755
inline static bool my_isvar(const charset_info_st *s, char c)
757
return my_isalnum(s,c) || (c) == '_';
760
inline static bool my_isvar_start(const charset_info_st *s, char c)
762
return my_isalpha(s,c) || (c) == '_';
765
inline static bool my_binary_compare(const charset_info_st *s)
767
return s->state & MY_CS_BINSORT;
770
inline static bool use_strnxfrm(const charset_info_st *s)
772
return s->state & MY_CS_STRNXFRM;
775
inline static size_t my_strnxfrm(const charset_info_st *cs,
778
const unsigned char *src,
779
const uint32_t srclen)
781
return (cs->coll->strnxfrm(cs, dst, dstlen, dstlen, src, srclen, MY_STRXFRM_PAD_WITH_SPACE));
784
inline static int my_strnncoll(const charset_info_st *cs,
785
const unsigned char *s,
787
const unsigned char *t,
790
return (cs->coll->strnncoll(cs, s, slen, t, tlen, 0));
793
inline static bool my_like_range(const charset_info_st *cs,
794
const char *ptr, const size_t ptrlen,
799
char *minstr, char *maxstr,
800
size_t *minlen, size_t *maxlen)
802
return (cs->coll->like_range(cs, ptr, ptrlen, escape, w_one, w_many, reslen,
803
minstr, maxstr, minlen, maxlen));
806
inline static int my_wildcmp(const charset_info_st *cs,
807
const char *str, const char *strend,
808
const char *w_str, const char *w_strend,
810
const int w_one, const int w_many)
812
return (cs->coll->wildcmp(cs, str, strend, w_str, w_strend, escape, w_one, w_many));
815
inline static int my_strcasecmp(const charset_info_st *cs, const char *s, const char *t)
817
return (cs->coll->strcasecmp(cs, s, t));
820
template <typename CHAR_T>
821
inline static size_t my_charpos(const charset_info_st *cs,
822
const CHAR_T *b, const CHAR_T* e, size_t num)
824
return cs->cset->charpos(cs, reinterpret_cast<const char*>(b), reinterpret_cast<const char*>(e), num);
827
inline static bool use_mb(const charset_info_st *cs)
829
return cs->cset->ismbchar != NULL;
832
inline static unsigned int my_ismbchar(const charset_info_st *cs, const char *a, const char *b)
834
return cs->cset->ismbchar(cs, a, b);
837
inline static unsigned int my_mbcharlen(const charset_info_st *cs, uint32_t c)
839
return cs->cset->mbcharlen(cs, c);
843
inline static size_t my_caseup_str(const charset_info_st *cs, char *src)
845
return cs->cset->caseup_str(cs, src);
848
inline static size_t my_casedn_str(const charset_info_st *cs, char *src)
850
return cs->cset->casedn_str(cs, src);
853
inline static long my_strntol(const charset_info_st *cs,
854
const char* s, const size_t l, const int base, char **e, int *err)
856
return (cs->cset->strntol(cs, s, l, base, e, err));
859
inline static unsigned long my_strntoul(const charset_info_st *cs,
860
const char* s, const size_t l, const int base,
863
return (cs->cset->strntoul(cs, s, l, base, e, err));
866
inline static int64_t my_strntoll(const charset_info_st *cs,
867
const char* s, const size_t l, const int base, char **e, int *err)
869
return (cs->cset->strntoll(cs, s, l, base, e, err));
872
inline static int64_t my_strntoull(const charset_info_st *cs,
873
const char* s, const size_t l, const int base,
876
return (cs->cset->strntoull(cs, s, l, base, e, err));
880
inline static double my_strntod(const charset_info_st *cs,
881
char* s, const size_t l, char **e, int *err)
883
return (cs->cset->strntod(cs, s, l, e, err));
677
#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
678
#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_')
680
#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
681
#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
682
#define my_strnxfrm(cs, d, dl, s, sl) \
683
((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
684
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
685
#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
686
((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
687
#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
688
#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b)))
689
#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
692
#define use_mb(s) ((s)->cset->ismbchar != NULL)
693
#define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b)))
694
#define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a)))
696
#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a)))
697
#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a)))
698
#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
699
#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
700
#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
701
#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
702
#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d)))
886
704
int make_escape_code(const CHARSET_INFO * const cs, const char *escape);