24#ifndef M_STRING_INCLUDED
25#define M_STRING_INCLUDED
56static inline void bchange(uint8_t *dst,
size_t old_length,
const uint8_t *src,
57 size_t new_length,
size_t tot_length) {
58 memmove(dst + new_length, dst + old_length, tot_length - old_length);
59 memcpy(dst, src, new_length);
68static inline const char *
strend(
const char *s) {
84static inline const char *
strcend(
const char *s,
char c) {
86 if (*s == c)
return s;
87 if (!*s++)
return s - 1;
96static inline char *
strfill(
char *s,
size_t len,
char fill) {
97 while (len--) *s++ = fill;
109static inline char *
my_stpmov(
char *dst,
const char *src) {
110 while ((*dst++ = *src++)) {
121static inline char *
my_stpnmov(
char *dst,
const char *src,
size_t n) {
123 if (!(*dst++ = *src++))
return (
char *)dst - 1;
141static inline char *
my_stpcpy(
char *dst,
const char *src) {
142#if defined(HAVE_BUILTIN_STPCPY)
150 return __builtin_stpcpy(dst, src);
151#elif defined(HAVE_STPCPY)
152 return stpcpy(dst, src);
171static inline char *
my_stpncpy(
char *dst,
const char *src,
size_t n) {
172#if defined(HAVE_STPNCPY)
173 return stpncpy(dst, src,
n);
180static inline long long my_strtoll(
const char *nptr,
char **endptr,
int base) {
182 return _strtoi64(nptr, endptr, base);
184 return strtoll(nptr, endptr, base);
188static inline unsigned long long my_strtoull(
const char *nptr,
char **endptr,
191 return _strtoui64(nptr, endptr, base);
193 return strtoull(nptr, endptr, base);
199 return strtok_s(
str, delim, saveptr);
201 return strtok_r(
str, delim, saveptr);
208 return _stricmp(s1, s2);
210 return strcasecmp(s1, s2);
217 return _strnicmp(s1, s2,
n);
219 return strncasecmp(s1, s2,
n);
227static inline int is_prefix(
const char *s,
const char *t) {
229 if (*s++ != *t++)
return 0;
240 const uint8_t *
end = ptr + len;
241 while (
end - ptr >= 8) {
243 memcpy(&chunk,
end - 8,
sizeof(chunk));
244 if (chunk != 0x2020202020202020ULL)
break;
247 while (
end > ptr &&
end[-1] == 0x20)
end--;
266 const char size[] = {
'\0',
'K',
'M',
'G',
'T',
'P',
'E',
'Z',
'Y'};
268 for (i = 0; dbl_val > 1024 && i <
sizeof(size) - 1; i++) dbl_val /= 1024;
269 const char mult = size[i];
273 if (dbl_val > 18446744073709549568.0)
274 snprintf(
buf, buf_len,
"+INF");
276 snprintf(
buf, buf_len,
"%llu%c", (
unsigned long long)dbl_val,
mult);
280 lex_str->
str = c_str;
281 lex_str->
length = strlen(c_str);
285 lex_str->
str = c_str;
286 lex_str->
length = strlen(c_str);
static Bigint * mult(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:916
static const char * strcend(const char *s, char c)
Definition: m_string.h:84
static int is_prefix(const char *s, const char *t)
Definition: m_string.h:227
static int native_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: m_string.h:215
static void bchange(uint8_t *dst, size_t old_length, const uint8_t *src, size_t new_length, size_t tot_length)
Definition: m_string.h:56
static void lex_string_set(LEX_STRING *lex_str, char *c_str)
Definition: m_string.h:279
static const char * strend(const char *s)
Definition: m_string.h:68
static char * my_stpmov(char *dst, const char *src)
Definition: m_string.h:109
static char * my_stpcpy(char *dst, const char *src)
Copy a string from src to dst until (and including) terminating null byte.
Definition: m_string.h:141
static char * my_stpncpy(char *dst, const char *src, size_t n)
Copy fixed-size string from src to dst.
Definition: m_string.h:171
static char * strfill(char *s, size_t len, char fill)
Definition: m_string.h:96
static int native_strcasecmp(const char *s1, const char *s2)
Definition: m_string.h:206
static char * my_stpnmov(char *dst, const char *src, size_t n)
Definition: m_string.h:121
static char * my_strtok_r(char *str, const char *delim, char **saveptr)
Definition: m_string.h:197
static void human_readable_num_bytes(char *buf, int buf_len, double dbl_val)
Definition: m_string.h:264
static unsigned long long my_strtoull(const char *nptr, char **endptr, int base)
Definition: m_string.h:188
static const uint8_t * skip_trailing_space(const uint8_t *ptr, size_t len)
Skip trailing space (ASCII spaces only).
Definition: m_string.h:238
static void lex_cstring_set(LEX_CSTRING *lex_str, const char *c_str)
Definition: m_string.h:284
static long long my_strtoll(const char *nptr, char **endptr, int base)
Definition: m_string.h:180
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1085
Definition: buf0block_hint.cc:29
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
Definition: mysql_lex_string.h:39
const char * str
Definition: mysql_lex_string.h:40
size_t length
Definition: mysql_lex_string.h:41
Definition: mysql_lex_string.h:34
char * str
Definition: mysql_lex_string.h:35
size_t length
Definition: mysql_lex_string.h:36
int n
Definition: xcom_base.cc:508