22#define SMART_STR_OVERHEAD (ZEND_MM_OVERHEAD + _ZSTR_HEADER_SIZE + 1)
23#define SMART_STR_START_SIZE 256
24#define SMART_STR_START_LEN (SMART_STR_START_SIZE - SMART_STR_OVERHEAD)
25#define SMART_STR_PAGE 4096
27#define SMART_STR_NEW_LEN(len) \
28 (ZEND_MM_ALIGNED_SIZE_EX(len + SMART_STR_OVERHEAD, SMART_STR_PAGE) - SMART_STR_OVERHEAD)
36 str->
s = zend_string_alloc(str->
a, 0);
50 str->
s = zend_string_alloc(str->
a, 1);
63static size_t zend_compute_escaped_string_len(
const char *
s,
size_t l) {
65 for (i = 0; i < l; ++i) {
67 if (c ==
'\n' || c ==
'\r' || c ==
'\t' ||
68 c ==
'\f' || c ==
'\v' || c ==
'\\' || c ==
VK_ESCAPE) {
70 }
else if (c < 32 || c > 126) {
79 size_t i,
len = zend_compute_escaped_string_len(
s, l);
81 smart_str_alloc(str,
len, 0);
85 for (i = 0; i < l; ++i) {
86 unsigned char c =
s[i];
87 if (c < 32 || c ==
'\\' || c > 126) {
90 case '\n': *
res++ =
'n';
break;
91 case '\r': *
res++ =
'r';
break;
92 case '\t': *
res++ =
't';
break;
93 case '\f': *
res++ =
'f';
break;
94 case '\v': *
res++ =
'v';
break;
95 case '\\': *
res++ =
'\\';
break;
100 *
res++ = (c >> 4) +
'0';
102 *
res++ = (c >> 4) +
'A' - 10;
104 if ((c & 0xf) < 10) {
105 *
res++ = (c & 0xf) +
'0';
107 *
res++ = (c & 0xf) +
'A' - 10;
117 smart_str *str,
double num,
int precision,
bool zero_fraction) {
120 zend_gcvt(num, precision ? precision : 1,
'.',
'E',
buf);
121 smart_str_appends(str,
buf);
123 smart_str_appendl(str,
".0", 2);
129 va_start(
arg, format);
134#define SMART_STRING_OVERHEAD (ZEND_MM_OVERHEAD + 1)
135#define SMART_STRING_START_SIZE 256
136#define SMART_STRING_START_LEN (SMART_STRING_START_SIZE - SMART_STRING_OVERHEAD)
137#define SMART_STRING_PAGE 4096
190 smart_str_appendl(str,
"...",
sizeof(
"...")-1);
200 smart_str_appendl(dest,
"NULL",
sizeof(
"NULL")-1);
217 smart_str_appendc(dest,
'\'');
219 smart_str_appendc(dest,
'\'');
232 smart_str_appends(dest,
"::");
strchr(string $haystack, string $needle, bool $before_needle=false)
zend_ffi_ctype_name_buf buf
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format,...)
void(* zend_printf_to_smart_str)(smart_str *buf, const char *format, va_list ap)
#define ZEND_MM_ALIGNED_SIZE_EX(size, alignment)
#define perealloc(ptr, size, persistent)
#define erealloc2(ptr, size, copy_size)
#define pemalloc(size, persistent)
#define emalloc_large(size)
#define ZEND_MM_CHUNK_SIZE
struct _zend_string zend_string
#define EXPECTED(condition)
#define EMPTY_SWITCH_DEFAULT_CASE()
#define UNEXPECTED(condition)
#define SMART_STR_START_LEN
ZEND_API void ZEND_FASTCALL smart_str_realloc(smart_str *str, size_t len)
ZEND_API void ZEND_FASTCALL smart_str_append_escaped_truncated(smart_str *str, const zend_string *value, size_t length)
ZEND_API void ZEND_FASTCALL smart_str_erealloc(smart_str *str, size_t len)
ZEND_API void ZEND_FASTCALL smart_str_append_double(smart_str *str, double num, int precision, bool zero_fraction)
ZEND_API void ZEND_FASTCALL smart_str_append_escaped(smart_str *str, const char *s, size_t l)
#define SMART_STR_NEW_LEN(len)
ZEND_API zend_result ZEND_FASTCALL smart_str_append_zval(smart_str *dest, const zval *value, size_t truncate)
ZEND_API void smart_str_append_printf(smart_str *dest, const char *format,...)
#define SMART_STRING_PAGE
ZEND_API void ZEND_FASTCALL smart_str_append_scalar(smart_str *dest, const zval *value, size_t truncate)
ZEND_API void ZEND_FASTCALL _smart_string_alloc_persistent(smart_string *str, size_t len)
#define SMART_STRING_START_LEN
#define SMART_STRING_OVERHEAD
ZEND_API void ZEND_FASTCALL _smart_string_alloc(smart_string *str, size_t len)
#define _ZSTR_HEADER_SIZE
ZEND_API char * zend_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf)
#define ZEND_DOUBLE_MAX_LENGTH
#define Z_OBJCE_P(zval_p)
ZEND_RESULT_CODE zend_result