summaryrefslogtreecommitdiff
path: root/ext/standard/php_smart_str.h
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-09-19 23:22:26 +0200
committerNikita Popov <nikic@php.net>2014-09-19 23:39:07 +0200
commit31e842472f46d8aa32e2ef316da245f18806589d (patch)
treee87882472345b757f3b898c441dc9e80e0d4364a /ext/standard/php_smart_str.h
parentad3e1830bafdcbf366f611c8778c5409bd4472d2 (diff)
downloadphp-git-31e842472f46d8aa32e2ef316da245f18806589d.tar.gz
Make number printing functions less generic
Now that zend_ulong is 64bit on 64bit platforms, it should be sufficient to always use it, rather than supporting multiple types. API changes: * _zend_print_unsigned_to_buf and _zend_print_signed_to_buf no longer exist. * smart_str(ing)_print_long and smart_str(ing)_print_unsigned no longer exist. * Instead of all these, zend_print_ulong_to_buf and zend_print_long_to_buf should be used. * smart_str_append_generic_ex no longer exists. * smart_str(ing)_append_off_t(_ex) no longer exists, use smart_str(ing)_append_long(_ex) instead.
Diffstat (limited to 'ext/standard/php_smart_str.h')
-rw-r--r--ext/standard/php_smart_str.h42
1 files changed, 12 insertions, 30 deletions
diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h
index 25d6fe2db4..1c8c418370 100644
--- a/ext/standard/php_smart_str.h
+++ b/ext/standard/php_smart_str.h
@@ -50,8 +50,6 @@
smart_str_setl((dest), (src), strlen(src));
#define smart_str_append_long(dest, val) \
smart_str_append_long_ex((dest), (val), 0)
-#define smart_str_append_off_t(dest, val) \
- smart_str_append_off_t_ex((dest), (val), 0)
#define smart_str_append_unsigned(dest, val) \
smart_str_append_unsigned_ex((dest), (val), 0)
@@ -106,37 +104,21 @@ static zend_always_inline void smart_str_append_ex(smart_str *dest, const smart_
}
}
-static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) {
- smart_str_free(dest);
- smart_str_appendl(dest, src, len);
-}
-
-static inline char *smart_str_print_long(char *buf, zend_long num) {
- char *r;
- _zend_print_signed_to_buf(buf, num, zend_long, r);
- return r;
+static zend_always_inline void smart_str_append_long_ex(smart_str *dest, zend_long num, zend_bool persistent) {
+ char buf[32];
+ char *result = zend_print_long_to_buf(buf + sizeof(buf) - 1, num);
+ smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
}
-static inline char *smart_str_print_unsigned(char *buf, zend_long num) {
- char *r;
- _zend_print_unsigned_to_buf(buf, num, zend_ulong, r);
- return r;
+static zend_always_inline void smart_str_append_unsigned_ex(smart_str *dest, zend_ulong num, zend_bool persistent) {
+ char buf[32];
+ char *result = zend_print_ulong_to_buf(buf + sizeof(buf) - 1, num);
+ smart_str_appendl_ex(dest, result, buf + sizeof(buf) - 1 - result, persistent);
}
-#define smart_str_append_generic_ex(dest, num, type, vartype, func) do { \
- char __b[32]; \
- char *__t; \
- _zend_print##func##_to_buf (__b + sizeof(__b) - 1, (num), vartype, __t); \
- smart_str_appendl_ex((dest), __t, __b + sizeof(__b) - 1 - __t, (type)); \
-} while (0)
-
-#define smart_str_append_unsigned_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), zend_ulong, _unsigned)
-
-#define smart_str_append_long_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), zend_ulong, _signed)
-
-#define smart_str_append_off_t_ex(dest, num, type) \
- smart_str_append_generic_ex((dest), (num), (type), zend_off_t, _signed)
+static zend_always_inline void smart_str_setl(smart_str *dest, const char *src, size_t len) {
+ smart_str_free(dest);
+ smart_str_appendl(dest, src, len);
+}
#endif