34
30
#include <string.h>
37
/* This is needed for the definitions of bzero... on solaris */
38
#if defined(HAVE_STRINGS_H)
43
42
/* This is needed for the definitions of memcpy... on solaris */
44
43
#if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
45
44
#include <memory.h>
47
#if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
48
# define memcpy(d, s, n) bcopy ((s), (d), (n))
49
# define memset(A,C,B) bfill((A),(B),(C))
50
# define memmove(d, s, n) bmove ((d), (s), (n))
51
#elif defined(HAVE_MEMMOVE)
52
# define bmove(d, s, n) memmove((d), (s), (n))
54
# define memmove(d, s, n) bmove((d), (s), (n)) /* our bmove */
58
#if !defined(HAVE_BFILL)
59
# define bfill(A,B,C) memset((A),(C),(B))
60
# define bmove_align(A,B,C) memcpy((A),(B),(C))
63
#if !defined(HAVE_BCMP)
64
# define bcopy(s, d, n) memcpy((d), (s), (n))
65
# define bcmp(A,B,C) memcmp((A),(B),(C))
66
# define bzero(A,B) memset((A),0,(B))
67
# define bmove_align(A,B,C) memcpy((A),(B),(C))
48
70
#if defined(__cplusplus)
56
78
extern void *(*my_str_malloc)(size_t);
57
79
extern void (*my_str_free)(void *);
59
char *my_stpncpy(register char *dst, register const char *src, size_t n);
60
char *my_stpcpy(register char *dst, register const char *src);
62
#define strmov_overlapp(A,B) my_stpcpy(A,B)
81
#if defined(HAVE_STPCPY)
82
#define strmov(A,B) stpcpy((A),(B))
85
/* Declared in int2str() */
86
extern char _dig_vec_upper[];
87
extern char _dig_vec_lower[];
89
#ifdef BAD_STRING_COMPILER
90
#define strmov(A,B) (memccpy(A,B,0,INT_MAX)-1)
92
#define strmov_overlapp(A,B) strmov(A,B)
63
93
#define strmake_overlapp(A,B,C) strmake(A,B,C)
65
extern void bmove_upp(unsigned char *dst,const unsigned char *src,size_t len);
67
extern void bchange(unsigned char *dst,size_t old_len,const unsigned char *src,
96
#ifdef BAD_MEMCPY /* Problem with gcc on Alpha */
97
#define memcpy_fixed(A,B,C) bmove((A),(B),(C))
99
#define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
102
#if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
103
#define bmove512(A,B,C) memcpy(A,B,C)
106
/* Prototypes for string functions */
108
#if !defined(bfill) && !defined(HAVE_BFILL)
109
extern void bfill(uchar *dst,size_t len,char fill);
112
#if !defined(bzero) && !defined(HAVE_BZERO)
113
extern void bzero(uchar * dst,size_t len);
116
#if !defined(bcmp) && !defined(HAVE_BCMP)
117
extern size_t bcmp(const uchar *s1,const uchar *s2,size_t len);
120
extern size_t my_bcmp(const uchar *s1,const uchar *s2,size_t len);
122
#define bcmp(A,B,C) my_bcmp((A),(B),(C))
123
#define bzero_if_purify(A,B) bzero(A,B)
125
#define bzero_if_purify(A,B)
126
#endif /* HAVE_purify */
129
extern void bmove512(uchar *dst,const uchar *src,size_t len);
132
#if !defined(HAVE_BMOVE) && !defined(bmove)
133
extern void bmove(uuchar *dst, const uchar *src,size_t len);
136
extern void bmove_upp(uchar *dst,const uchar *src,size_t len);
137
extern void bchange(uchar *dst,size_t old_len,const uchar *src,
68
138
size_t new_len,size_t tot_len);
139
extern void strappend(char *s,size_t len,char fill);
140
extern char *strend(const char *s);
141
extern char *strcend(const char *, char);
69
142
extern char *strfield(char *src,int fields,int chars,int blanks,
71
144
extern char *strfill(char * s,size_t len,char fill);
75
148
extern char *strmake_overlapp(char *dst,const char *src, size_t length);
152
extern char *strmov(char *dst,const char *src);
154
extern char *strnmov(char *dst,const char *src,size_t n);
78
155
extern char *strsuff(const char *src,const char *suffix);
79
extern char *strxcat(char *dst,const char *src, ...);
80
extern char *strxmov(char *dst,const char *src, ...);
81
extern char *strxcpy(char *dst,const char *src, ...);
82
extern char *strxncat(char *dst,size_t len, const char *src, ...);
83
extern char *strxnmov(char *dst,size_t len, const char *src, ...);
84
extern char *strxncpy(char *dst,size_t len, const char *src, ...);
156
extern char *strcont(const char *src,const char *set);
157
extern char *strxcat _VARARGS((char *dst,const char *src, ...));
158
extern char *strxmov _VARARGS((char *dst,const char *src, ...));
159
extern char *strxcpy _VARARGS((char *dst,const char *src, ...));
160
extern char *strxncat _VARARGS((char *dst,size_t len, const char *src, ...));
161
extern char *strxnmov _VARARGS((char *dst,size_t len, const char *src, ...));
162
extern char *strxncpy _VARARGS((char *dst,size_t len, const char *src, ...));
86
164
/* Prototypes of normal stringfunctions (with may ours) */
90
168
extern char *strchr(const char *, char);
91
169
extern char *strrchr(const char *, char);
92
170
extern char *strcpy(char *, const char *);
171
extern int strcmp(const char *, const char *);
173
extern size_t strlen(const char *);
177
extern size_t strnlen(const char *s, size_t n);
95
180
#if !defined(__cplusplus)
96
181
#ifndef HAVE_STRPBRK
97
182
extern char *strpbrk(const char *, const char *);
185
extern char *strstr(const char *, const char *);
100
188
extern int is_prefix(const char *, const char *);
135
223
(DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
136
224
MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
138
#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + cmax(5, MAX_DECPT_FOR_F_FORMAT))
226
#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + max(5, MAX_DECPT_FOR_F_FORMAT))
141
229
extern char *llstr(int64_t value,char *buff);
142
230
extern char *ullstr(int64_t value,char *buff);
232
extern long strtol(const char *str, char **ptr, int base);
233
extern ulong strtoul(const char *str, char **ptr, int base);
144
236
extern char *int2str(long val, char *dst, int radix, int upcase);
145
237
extern char *int10_to_str(long val,char *dst,int radix);
149
241
#if SIZEOF_LONG == SIZEOF_LONG_LONG
150
242
#define int64_t2str(A,B,C) int2str((A),(B),(C),1)
151
243
#define int64_t10_to_str(A,B,C) int10_to_str((A),(B),(C))
245
#define strtoll(A,B,C) strtol((A),(B),(C))
246
#define strtoull(A,B,C) strtoul((A),(B),(C))
247
#ifndef HAVE_STRTOULL
248
#define HAVE_STRTOULL
153
254
extern char *int64_t2str(int64_t val,char *dst,int radix);
154
255
extern char *int64_t10_to_str(int64_t val,char *dst,int radix);
256
#if (!defined(HAVE_STRTOULL) || defined(NO_STRTOLL_PROTO))
257
extern int64_t strtoll(const char *str, char **ptr, int base);
258
extern uint64_t strtoull(const char *str, char **ptr, int base);
220
325
@return the last non-space character
223
static inline const unsigned char *skip_trailing_space(const unsigned char *ptr,size_t len)
328
static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len)
225
const unsigned char *end= ptr + len;
330
const uchar *end= ptr + len;
229
const unsigned char *end_words= (const unsigned char *)(intptr_t)
334
const uchar *end_words= (const uchar *)(intptr_t)
230
335
(((uint64_t)(intptr_t)end) / SIZEOF_INT * SIZEOF_INT);
231
const unsigned char *start_words= (const unsigned char *)(intptr_t)
336
const uchar *start_words= (const uchar *)(intptr_t)
232
337
((((uint64_t)(intptr_t)ptr) + SIZEOF_INT - 1) / SIZEOF_INT * SIZEOF_INT);
234
assert(((uint64_t)(intptr_t)ptr) >= SIZEOF_INT);
339
DBUG_ASSERT(((uint64_t)(intptr_t)ptr) >= SIZEOF_INT);
235
340
if (end_words > ptr)
237
342
while (end > end_words && end[-1] == 0x20)
239
344
if (end[-1] == 0x20 && start_words < end_words)
240
while (end > start_words && ((const unsigned *)end)[-1] == SPACE_INT)
345
while (end > start_words && ((unsigned *)end)[-1] == SPACE_INT)
241
346
end -= SIZEOF_INT;