summaryrefslogtreecommitdiff
path: root/ext/standard/php_smart_str.h
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/php_smart_str.h')
-rw-r--r--ext/standard/php_smart_str.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/ext/standard/php_smart_str.h b/ext/standard/php_smart_str.h
index 4681b4a663..8146a057d3 100644
--- a/ext/standard/php_smart_str.h
+++ b/ext/standard/php_smart_str.h
@@ -46,6 +46,7 @@
#define smart_str_free(s) smart_str_free_ex(s, 0)
#define smart_str_appendl(dest,src,len) smart_str_appendl_ex(dest,src,len,0)
#define smart_str_append(dest, src) smart_str_append_ex(dest,src,0)
+#define smart_str_append_long(dest, val) smart_str_append_long_ex(dest,val,0)
static inline void smart_str_appendc_ex(smart_str *dest, char c, int what)
{
@@ -75,6 +76,36 @@ static inline void smart_str_appendl_ex(smart_str *dest, const char *src, size_t
dest->len = newlen;
}
+static inline char *smart_str_print_long(char *buf, long num)
+{
+ char *p = buf;
+ long tmp = 0;
+
+ if (num < 0) {
+ num = -num;
+ *p++ = '-';
+ }
+
+ while (num > 0) {
+ tmp = tmp * 10 + (num % 10);
+ num /= 10;
+ }
+
+ do {
+ *p++ = (tmp % 10) + '0';
+ tmp /= 10;
+ } while (tmp > 0);
+
+ return p;
+}
+
+static inline void smart_str_append_long_ex(smart_str *dest, long num, int type)
+{
+ char buf[32];
+ char *p = smart_str_print_long(buf, num);
+ smart_str_appendl_ex(dest, buf, p - buf, type);
+}
+
static inline void smart_str_append_ex(smart_str *dest, smart_str *src, int what)
{
smart_str_appendl_ex(dest, src->c, src->len, what);