25#ifndef M_STRING_INCLUDED
26#define M_STRING_INCLUDED
57static inline void bchange(uint8_t *dst,
size_t old_length,
const uint8_t *src,
58 size_t new_length,
size_t tot_length) {
59 memmove(dst + new_length, dst + old_length, tot_length - old_length);
60 memcpy(dst, src, new_length);
69static inline const char *
strend(
const char *s) {
85static inline const char *
strcend(
const char *s,
char c) {
87 if (*s == c)
return s;
88 if (!*s++)
return s - 1;
97static inline char *
strfill(
char *s,
size_t len,
char fill) {
98 while (len--) *s++ = fill;
110static inline char *
my_stpmov(
char *dst,
const char *src) {
111 while ((*dst++ = *src++)) {
122static inline char *
my_stpnmov(
char *dst,
const char *src,
size_t n) {
124 if (!(*dst++ = *src++))
return (
char *)dst - 1;
142static inline char *
my_stpcpy(
char *dst,
const char *src) {
143#if defined(HAVE_BUILTIN_STPCPY)
151 return __builtin_stpcpy(dst, src);
152#elif defined(HAVE_STPCPY)
153 return stpcpy(dst, src);
172static inline char *
my_stpncpy(
char *dst,
const char *src,
size_t n) {
173#if defined(HAVE_STPNCPY)
174 return stpncpy(dst, src,
n);
181static inline long long my_strtoll(
const char *nptr,
char **endptr,
int base) {
183 return _strtoi64(nptr, endptr, base);
185 return strtoll(nptr, endptr, base);
189static inline unsigned long long my_strtoull(
const char *nptr,
char **endptr,
192 return _strtoui64(nptr, endptr, base);
194 return strtoull(nptr, endptr, base);
200 return strtok_s(
str, delim, saveptr);
202 return strtok_r(
str, delim, saveptr);
209 return _stricmp(s1, s2);
211 return strcasecmp(s1, s2);
218 return _strnicmp(s1, s2,
n);
220 return strncasecmp(s1, s2,
n);
228static inline int is_prefix(
const char *s,
const char *t) {
230 if (*s++ != *t++)
return 0;
241 const uint8_t *
end = ptr + len;
242 while (
end - ptr >= 8) {
244 memcpy(&chunk,
end - 8,
sizeof(chunk));
245 if (chunk != 0x2020202020202020ULL)
break;
248 while (
end > ptr &&
end[-1] == 0x20)
end--;
267 const char size[] = {
'\0',
'K',
'M',
'G',
'T',
'P',
'E',
'Z',
'Y'};
269 for (i = 0; dbl_val > 1024 && i <
sizeof(
size) - 1; i++) dbl_val /= 1024;
274 if (dbl_val > 18446744073709549568.0)
275 snprintf(
buf, buf_len,
"+INF");
277 snprintf(
buf, buf_len,
"%llu%c", (
unsigned long long)dbl_val,
mult);
281 lex_str->
str = c_str;
282 lex_str->
length = strlen(c_str);
286 lex_str->
str = c_str;
287 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:85
static int is_prefix(const char *s, const char *t)
Definition: m_string.h:228
static int native_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: m_string.h:216
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:57
static void lex_string_set(LEX_STRING *lex_str, char *c_str)
Definition: m_string.h:280
static const char * strend(const char *s)
Definition: m_string.h:69
static char * my_stpmov(char *dst, const char *src)
Definition: m_string.h:110
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:142
static char * my_stpncpy(char *dst, const char *src, size_t n)
Copy fixed-size string from src to dst.
Definition: m_string.h:172
static char * strfill(char *s, size_t len, char fill)
Definition: m_string.h:97
static int native_strcasecmp(const char *s1, const char *s2)
Definition: m_string.h:207
static char * my_stpnmov(char *dst, const char *src, size_t n)
Definition: m_string.h:122
static char * my_strtok_r(char *str, const char *delim, char **saveptr)
Definition: m_string.h:198
static void human_readable_num_bytes(char *buf, int buf_len, double dbl_val)
Definition: m_string.h:265
static unsigned long long my_strtoull(const char *nptr, char **endptr, int base)
Definition: m_string.h:189
static const uint8_t * skip_trailing_space(const uint8_t *ptr, size_t len)
Skip trailing space (ASCII spaces only).
Definition: m_string.h:239
static void lex_cstring_set(LEX_CSTRING *lex_str, const char *c_str)
Definition: m_string.h:285
static long long my_strtoll(const char *nptr, char **endptr, int base)
Definition: m_string.h:181
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
Definition: buf0block_hint.cc:30
size_t size(const char *const c)
Definition: base64.h:46
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
Definition: mysql_lex_string.h:40
const char * str
Definition: mysql_lex_string.h:41
size_t length
Definition: mysql_lex_string.h:42
Definition: mysql_lex_string.h:35
char * str
Definition: mysql_lex_string.h:36
size_t length
Definition: mysql_lex_string.h:37
int n
Definition: xcom_base.cc:509