diff options
author | Derick Rethans <derick@php.net> | 2005-08-16 18:02:41 +0000 |
---|---|---|
committer | Derick Rethans <derick@php.net> | 2005-08-16 18:02:41 +0000 |
commit | 1ee41e0d92045c967c98919850a6c9f9fe560f5d (patch) | |
tree | 97175b3ece230e229298a43931edee6bdd602d60 /main/spprintf.c | |
parent | 5adc3ce7c605f64edf1c3da0e993a3c47aeff91a (diff) | |
download | php-git-1ee41e0d92045c967c98919850a6c9f9fe560f5d.tar.gz |
- Fixed a couple of bugs in the new smart_str macros, and allow them to
allocate two extra bytes (so that we can pad them with two \0's for UTF-16)
- Fixed usage of smart_str's in the PAD and INS_STRING macros.
Diffstat (limited to 'main/spprintf.c')
-rw-r--r-- | main/spprintf.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/main/spprintf.c b/main/spprintf.c index 4d22e968cc..4d51b80ecd 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -126,22 +126,22 @@ } \ } while (0) -#define INS_STRING(unicode, s_uni, xbuf, s, slen) \ +#define INS_STRING(unicode, s_unicode, xbuf, s, s_len) \ do { \ if (unicode) { \ - size_t newlen, p, sz = 2*(slen); \ + size_t newlen, p, sz = 2*(s_len); \ smart_str_alloc(xbuf, (sz), 0); \ - if (s_uni) { \ + if (s_unicode) { \ memcpy(xbuf->c + xbuf->len, s, (sz)); \ } else { \ - p = (slen); \ + p = (s_len); \ while(p--) { \ - smart_str_append2c(xbuf, *s++); \ + smart_str_append2c(xbuf, *s); \ + *s++; \ } \ } \ - xbuf->len += (sz); \ } else { \ - smart_str_appendl(xbuf, s, slen); \ + smart_str_appendl(xbuf, s, s_len); \ } \ } while (0) @@ -163,8 +163,8 @@ do { \ } else { \ smart_str_alloc(xbuf, sz, 0); \ memset(xbuf->c + xbuf->len, ch, sz); \ + xbuf->len += sz; \ } \ - xbuf->len += sz; \ } \ } while (0) @@ -847,7 +847,6 @@ PHPAPI int vuspprintf(char **pbuf, size_t max_len, const char *format, va_list a if (max_len && xbuf.len > max_len) { xbuf.len = max_len; } - smart_str_appendc(&xbuf, '\0'); /* we need \0\0 as termination */ smart_str_0(&xbuf); *pbuf = xbuf.c; |