diff --git a/ext/compatibility.h b/ext/compatibility.h index 01530f10987..8b80cc2995d 100644 --- a/ext/compatibility.h +++ b/ext/compatibility.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "ext/standard/base64.h" @@ -110,7 +111,6 @@ static zend_always_inline zend_string *zend_string_init_interned(const char *str typedef void zend_type; -#include static inline void smart_str_append_printf(smart_str *dest, const char *format, ...) { va_list arg; va_start(arg, format); @@ -324,6 +324,22 @@ static zend_always_inline zend_result add_next_index_object(zval *arg, zend_obje return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp) ? SUCCESS : FAILURE; } +static zend_always_inline void smart_str_appendl(smart_str *dest, const char *src, size_t length) { + size_t new_len = smart_str_alloc(dest, len, false); + memcpy(ZSTR_VAL(dest->s) + ZSTR_LEN(dest->s), str, len); + ZSTR_LEN(dest->s) = new_len; +} + +static inline void smart_str_append_double(smart_str *str, double num, int precision, bool zero_fraction) { + char buf[ZEND_DOUBLE_MAX_LENGTH]; + /* Model snprintf precision behavior. */ + zend_gcvt(num, precision ? precision : 1, '.', 'E', buf); + smart_str_appends(str, buf); + if (zero_fraction && zend_finite(num) && !strchr(buf, '.')) { + smart_str_appendl(str, ".0", 2); + } +} + #endif #if PHP_VERSION_ID < 80200 diff --git a/libdatadog b/libdatadog index 2a2dc7fe927..fd298acb7ef 160000 --- a/libdatadog +++ b/libdatadog @@ -1 +1 @@ -Subproject commit 2a2dc7fe927331639a55b2e76555087d6faa3e94 +Subproject commit fd298acb7ef91528f6c91d840c3e0a94e36bf3c6