25#ifndef M_STRING_INCLUDED
26#define M_STRING_INCLUDED
53#define NullS (char *)0
60extern void *(*my_str_malloc)(size_t);
61extern void *(*my_str_realloc)(
void *, size_t);
70extern char *
strmake(
char *dst,
const char *src,
size_t length);
71extern char *
strcont(
char *src,
const char *
set);
72extern char *
strxmov(
char *dst,
const char *src, ...);
73extern char *
strxnmov(
char *dst,
size_t len,
const char *src, ...);
81 size_t new_length,
size_t tot_length) {
82 memmove(dst + new_length, dst + old_length, tot_length - old_length);
83 memcpy(dst, src, new_length);
92static inline const char *
strend(
const char *s) {
108static inline const char *
strcend(
const char *s,
char c) {
110 if (*s == c)
return s;
111 if (!*s++)
return s - 1;
120static inline char *
strfill(
char *s,
size_t len,
char fill) {
121 while (len--) *s++ = fill;
133static inline char *
my_stpmov(
char *dst,
const char *src) {
134 while ((*dst++ = *src++)) {
145static inline char *
my_stpnmov(
char *dst,
const char *src,
size_t n) {
147 if (!(*dst++ = *src++))
return (
char *)dst - 1;
165static inline char *
my_stpcpy(
char *dst,
const char *src) {
166#if defined(HAVE_BUILTIN_STPCPY)
174 return __builtin_stpcpy(dst, src);
175#elif defined(HAVE_STPCPY)
176 return stpcpy(dst, src);
195static inline char *
my_stpncpy(
char *dst,
const char *src,
size_t n) {
196#if defined(HAVE_STPNCPY)
197 return stpncpy(dst, src,
n);
206 return _strtoi64(nptr, endptr, base);
208 return strtoll(nptr, endptr, base);
214 return _strtoui64(nptr, endptr, base);
216 return strtoull(nptr, endptr, base);
222 return strtok_s(
str, delim, saveptr);
224 return strtok_r(
str, delim, saveptr);
231 return _stricmp(s1, s2);
233 return strcasecmp(s1, s2);
240 return _strnicmp(s1, s2,
n);
242 return strncasecmp(s1, s2,
n);
250static inline int is_prefix(
const char *s,
const char *t) {
252 if (*s++ != *t++)
return 0;
260size_t my_fcvt(
double x,
int precision,
char *to,
bool *
error);
281#define MAX_DECPT_FOR_F_FORMAT DBL_DIG
288#define MY_GCVT_MAX_FIELD_WIDTH \
289 (DBL_DIG + 4 + std::max(5, MAX_DECPT_FOR_F_FORMAT))
294char *
ll2str(int64_t val,
char *dst,
int radix,
bool upcase);
298 return ll2str(val, dst, radix,
true);
315#define STRING_WITH_LEN(X) (X), ((sizeof(X) - 1))
324 while (
end - ptr >= 8) {
326 memcpy(&chunk,
end - 8,
sizeof(chunk));
327 if (chunk != 0x2020202020202020ULL)
break;
330 while (
end > ptr &&
end[-1] == 0x20)
end--;
349 const char size[] = {
'\0',
'K',
'M',
'G',
'T',
'P',
'E',
'Z',
'Y'};
351 for (i = 0; dbl_val > 1024 && i <
sizeof(size) - 1; i++) dbl_val /= 1024;
352 const char mult = size[i];
356 if (dbl_val > 18446744073709549568.0)
357 snprintf(
buf, buf_len,
"+INF");
359 snprintf(
buf, buf_len,
"%llu%c", (
unsigned long long)dbl_val,
mult);
363 lex_str->
str = c_str;
364 lex_str->
length = strlen(c_str);
368 lex_str->
str = c_str;
369 lex_str->
length = strlen(c_str);
static constexpr int DECIMAL_NOT_SPECIFIED
Definition: decimal.h:154
static Bigint * mult(Bigint *a, Bigint *b, Stack_alloc *alloc)
Definition: dtoa.cc:924
const char _dig_vec_lower[]
Definition: int2str.cc:41
static const char * strcend(const char *s, char c)
Definition: m_string.h:108
static int is_prefix(const char *s, const char *t)
Definition: m_string.h:250
char * longlong10_to_str(int64_t val, char *dst, int radix)
Converts a 64-bit integer to its string representation in decimal notation.
Definition: int2str.cc:101
static int native_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: m_string.h:238
char * strxmov(char *dst, const char *src,...)
Definition: strxmov.cc:48
size_t my_fcvt_compact(double x, char *to, bool *error)
Converts a given floating point number to a zero-terminated string representation using the 'f' forma...
Definition: dtoa.cc:234
static void bchange(uchar *dst, size_t old_length, const uchar *src, size_t new_length, size_t tot_length)
Definition: m_string.h:80
static constexpr int FLOATING_POINT_BUFFER
Definition: m_string.h:271
static void lex_string_set(LEX_STRING *lex_str, char *c_str)
Definition: m_string.h:362
char * strcont(char *src, const char *set)
Definition: strcont.cc:37
longlong my_strtoll10(const char *nptr, const char **endptr, int *error)
Definition: my_strtoll10.cc:87
const char _dig_vec_upper[]
Definition: int2str.cc:40
static const char * strend(const char *s)
Definition: m_string.h:92
size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to, bool *error)
Converts a given floating point number to a zero-terminated string representation with a given field ...
Definition: dtoa.cc:302
static char * my_stpmov(char *dst, const char *src)
Definition: m_string.h:133
static const uchar * skip_trailing_space(const uchar *ptr, size_t len)
Skip trailing space (ASCII spaces only).
Definition: m_string.h:322
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:165
static longlong my_strtoll(const char *nptr, char **endptr, int base)
Definition: m_string.h:204
static char * my_stpncpy(char *dst, const char *src, size_t n)
Copy fixed-size string from src to dst.
Definition: m_string.h:195
char * longlong2str(int64_t val, char *dst, int radix)
Definition: m_string.h:297
static char * strfill(char *s, size_t len, char fill)
Definition: m_string.h:120
static ulonglong my_strtoull(const char *nptr, char **endptr, int base)
Definition: m_string.h:212
char * ll2str(int64_t val, char *dst, int radix, bool upcase)
Converts a 64-bit integer value to its character form and moves it to the destination buffer followed...
Definition: int2str.cc:60
static int native_strcasecmp(const char *s1, const char *s2)
Definition: m_string.h:229
static char * my_stpnmov(char *dst, const char *src, size_t n)
Definition: m_string.h:145
my_gcvt_arg_type
Definition: m_string.h:257
@ MY_GCVT_ARG_DOUBLE
Definition: m_string.h:257
@ MY_GCVT_ARG_FLOAT
Definition: m_string.h:257
char * strxnmov(char *dst, size_t len, const char *src,...)
Definition: strxnmov.cc:54
static char * my_strtok_r(char *str, const char *delim, char **saveptr)
Definition: m_string.h:220
static void human_readable_num_bytes(char *buf, int buf_len, double dbl_val)
Definition: m_string.h:347
static char * llstr(longlong value, char *buff)
Definition: m_string.h:305
void(* my_str_free)(void *)
Definition: str_alloc.cc:44
static void lex_cstring_set(LEX_CSTRING *lex_str, const char *c_str)
Definition: m_string.h:367
const char * str2int(const char *src, int radix, long lower, long upper, long *val)
size_t my_fcvt(double x, int precision, char *to, bool *error)
Converts a given floating point number to a zero-terminated string representation using the 'f' forma...
Definition: dtoa.cc:203
double my_strtod(const char *str, const char **end, int *error)
Converts string to double (string does not have to be zero-terminated)
Definition: dtoa.cc:515
static char * ullstr(longlong value, char *buff)
Definition: m_string.h:310
char * strmake(char *dst, const char *src, size_t length)
Definition: strmake.cc:43
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1052
Definition: buf0block_hint.cc:30
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
static std::string lower(std::string str)
Definition: config_parser.cc:65
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2882
required string type
Definition: replication_group_member_actions.proto:34
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