659
664
#define _MY_X 0200 /* heXadecimal digit */
662
#define my_isascii(c) (!((c) & ~0177))
663
#define my_toascii(c) ((c) & 0177)
664
#define my_tocntrl(c) ((c) & 31)
665
#define my_toprint(c) ((c) | 64)
666
#define my_toupper(s,c) (char) ((s)->to_upper[(unsigned char) (c)])
667
#define my_tolower(s,c) (char) ((s)->to_lower[(unsigned char) (c)])
668
#define my_isalpha(s, c) (((s)->ctype+1)[(unsigned char) (c)] & (_MY_U | _MY_L))
669
#define my_isupper(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_U)
670
#define my_islower(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_L)
671
#define my_isdigit(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_NMR)
672
#define my_isxdigit(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_X)
673
#define my_isalnum(s, c) (((s)->ctype+1)[(unsigned char) (c)] & (_MY_U | _MY_L | _MY_NMR))
674
#define my_isspace(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_SPC)
675
#define my_ispunct(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_PNT)
676
#define my_isprint(s, c) (((s)->ctype+1)[(unsigned char) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
677
#define my_isgraph(s, c) (((s)->ctype+1)[(unsigned char) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
678
#define my_iscntrl(s, c) (((s)->ctype+1)[(unsigned char) (c)] & _MY_CTR)
667
inline static bool my_isascii(char c)
669
return (!(c & ~0177));
672
inline static char my_toascii(char c)
677
inline static char my_tocntrl(char c)
682
inline static char my_toprint(char c)
687
inline static char my_toupper(const charset_info_st *s, char c)
689
return (char)(s->to_upper[(unsigned char)c]);
692
inline static char my_tolower(const charset_info_st *s, char c)
694
return (char)(s->to_lower[(unsigned char)c]);
697
inline static bool my_isalpha(const charset_info_st *s, char c)
699
return ((s->ctype+1)[(unsigned char)c] & (_MY_U | _MY_L));
702
inline static bool my_isupper(const charset_info_st *s, char c)
704
return ((s->ctype+1)[(unsigned char)c] & _MY_U);
707
inline static bool my_islower(const charset_info_st *s, char c)
709
return ((s->ctype+1)[(unsigned char)c] & _MY_L);
712
inline static bool my_isdigit(const charset_info_st *s, char c)
714
return ((s->ctype+1)[(unsigned char)c] & _MY_NMR);
717
inline static bool my_isxdigit(const charset_info_st *s, char c)
719
return ((s->ctype+1)[(unsigned char)c] & _MY_X);
722
inline static bool my_isalnum(const charset_info_st *s, char c)
724
return ((s->ctype+1)[(unsigned char)c] & (_MY_U | _MY_L | _MY_NMR));
727
inline static bool my_isspace(const charset_info_st *s, char c)
729
return ((s->ctype+1)[(unsigned char)c] & _MY_SPC);
732
inline static bool my_ispunct(const charset_info_st *s, char c)
734
return ((s->ctype+1)[(unsigned char)c] & _MY_PNT);
737
inline static bool my_isprint(const charset_info_st *s, char c)
739
return ((s->ctype+1)[(unsigned char)c] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B));
742
inline static bool my_isgraph(const charset_info_st *s, char c)
744
return ((s->ctype+1)[(unsigned char)c] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR));
747
inline static bool my_iscntrl(const charset_info_st *s, char c)
749
return ((s->ctype+1)[(unsigned char)c] & _MY_CTR);
680
752
/* Some macros that should be cleaned up a little */
681
#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
682
#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_')
684
#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
685
#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
686
#define my_strnxfrm(cs, d, dl, s, sl) \
687
((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
688
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
689
#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
690
((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
691
#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
692
#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b)))
693
#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
696
#define use_mb(s) ((s)->cset->ismbchar != NULL)
697
#define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b)))
698
#define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a)))
700
#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a)))
701
#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a)))
702
#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
703
#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
704
#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
705
#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
706
#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d)))
753
inline static bool my_isvar(const charset_info_st *s, char c)
755
return (my_isalnum(s,c) || (c) == '_');
758
inline static bool my_isvar_start(const charset_info_st *s, char c)
760
return (my_isalpha(s,c) || (c) == '_');
763
inline static bool my_binary_compare(const charset_info_st *s)
765
return (s->state & MY_CS_BINSORT);
768
inline static bool use_strnxfrm(const charset_info_st *s)
770
return (s->state & MY_CS_STRNXFRM);
773
inline static size_t my_strnxfrm(const charset_info_st *cs,
776
const unsigned char *src,
777
const uint32_t srclen)
779
return (cs->coll->strnxfrm(cs, dst, dstlen, dstlen, src, srclen, MY_STRXFRM_PAD_WITH_SPACE));
782
inline static int my_strnncoll(const charset_info_st *cs,
783
const unsigned char *s,
785
const unsigned char *t,
788
return (cs->coll->strnncoll(cs, s, slen, t, tlen, 0));
791
inline static bool my_like_range(const charset_info_st *cs,
792
const char *ptr, const size_t ptrlen,
797
char *minstr, char *maxstr,
798
size_t *minlen, size_t *maxlen)
800
return (cs->coll->like_range(cs, ptr, ptrlen, escape, w_one, w_many, reslen,
801
minstr, maxstr, minlen, maxlen));
804
inline static int my_wildcmp(const charset_info_st *cs,
805
const char *str, const char *strend,
806
const char *w_str, const char *w_strend,
808
const int w_one, const int w_many)
810
return (cs->coll->wildcmp(cs, str, strend, w_str, w_strend, escape, w_one, w_many));
813
inline static int my_strcasecmp(const charset_info_st *cs, const char *s, const char *t)
815
return (cs->coll->strcasecmp(cs, s, t));
818
template <typename CHAR_T>
819
inline static size_t my_charpos(const charset_info_st *cs,
820
const CHAR_T *b, const CHAR_T* e, size_t num)
822
return (cs->cset->charpos(cs, (const char*) b, (const char *)e, num));
825
inline static bool use_mb(const charset_info_st *cs)
827
return (cs->cset->ismbchar != NULL);
830
inline static unsigned int my_ismbchar(const charset_info_st *cs, const char *a, const char *b)
832
return (cs->cset->ismbchar(cs, a, b));
835
inline static unsigned int my_mbcharlen(const charset_info_st *cs, uint32_t c)
837
return (cs->cset->mbcharlen(cs, c));
841
inline static size_t my_caseup_str(const charset_info_st *cs, char *src)
843
return (cs->cset->caseup_str(cs, src));
846
inline static size_t my_casedn_str(const charset_info_st *cs, char *src)
848
return (cs->cset->casedn_str(cs, src));
851
inline static long my_strntol(const charset_info_st *cs,
852
const char* s, const size_t l, const int base, char **e, int *err)
854
return (cs->cset->strntol(cs, s, l, base, e, err));
857
inline static unsigned long my_strntoul(const charset_info_st *cs,
858
const char* s, const size_t l, const int base,
861
return (cs->cset->strntoul(cs, s, l, base, e, err));
864
inline static int64_t my_strntoll(const charset_info_st *cs,
865
const char* s, const size_t l, const int base, char **e, int *err)
867
return (cs->cset->strntoll(cs, s, l, base, e, err));
870
inline static int64_t my_strntoull(const charset_info_st *cs,
871
const char* s, const size_t l, const int base,
874
return (cs->cset->strntoull(cs, s, l, base, e, err));
878
inline static double my_strntod(const charset_info_st *cs,
879
char* s, const size_t l, char **e, int *err)
881
return (cs->cset->strntod(cs, s, l, e, err));
708
884
int make_escape_code(const CHARSET_INFO * const cs, const char *escape);