From fcef8d4836d6f4176f6a36e33438141920fbd24c Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Thu, 18 Jan 2007 21:39:50 +0000 Subject: [PATCH] - Fix [v]uspprintf() - Add [v]zspprintf --- main/spprintf.c | 27 +++++++++++++++++++++++---- main/spprintf.h | 10 ++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/main/spprintf.c b/main/spprintf.c index 70f25c3104..425a6105e1 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -859,7 +859,7 @@ PHPAPI int spprintf(char **pbuf, size_t max_len, const char *format, ...) return (cc); } -PHPAPI int vuspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) +PHPAPI int vuspprintf(UChar **pbuf, size_t max_len, const char *format, va_list ap) { smart_str xbuf = {0}; @@ -870,13 +870,12 @@ PHPAPI int vuspprintf(char **pbuf, size_t max_len, const char *format, va_list a } smart_str_0(&xbuf); - *pbuf = xbuf.c; + *pbuf = (UChar*)xbuf.c; return xbuf.len; } - -PHPAPI int uspprintf(char **pbuf, size_t max_len, const char *format, ...) +PHPAPI int uspprintf(UChar **pbuf, size_t max_len, const char *format, ...) { int cc; va_list ap; @@ -887,6 +886,26 @@ PHPAPI int uspprintf(char **pbuf, size_t max_len, const char *format, ...) return (cc); } +PHPAPI int vzspprintf(zend_uchar type, zstr *pbuf, size_t max_len, const char *format, va_list ap) +{ + if (type == IS_UNICODE) { + return vuspprintf(&pbuf->u, max_len, format, ap); + } else { + return vspprintf(&pbuf->s, max_len, format, ap); + } +} + +PHPAPI int zspprintf( zend_uchar type, zstr *pbuf, size_t max_len, const char *format, ...) +{ + int cc; + va_list ap; + + va_start(ap, format); + cc = vzspprintf(type, pbuf, max_len, format, ap); + va_end(ap); + return (cc); +} + /* * Local variables: * tab-width: 4 diff --git a/main/spprintf.h b/main/spprintf.h index 96af944b5c..3480e4e9bd 100644 --- a/main/spprintf.h +++ b/main/spprintf.h @@ -37,10 +37,12 @@ There is also snprintf: See difference explained in snprintf.h #include "snprintf.h" BEGIN_EXTERN_C() -PHPAPI int spprintf( char **pbuf, size_t max_len, const char *format, ...); -PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap); -PHPAPI int uspprintf( char **pbuf, size_t max_len, const char *format, ...); -PHPAPI int vuspprintf(char **pbuf, size_t max_len, const char *format, va_list ap); +PHPAPI int spprintf( char **pbuf, size_t max_len, const char *format, ...); +PHPAPI int vspprintf( char **pbuf, size_t max_len, const char *format, va_list ap); +PHPAPI int uspprintf( UChar **pbuf, size_t max_len, const char *format, ...); +PHPAPI int vuspprintf(UChar **pbuf, size_t max_len, const char *format, va_list ap); +PHPAPI int zspprintf( zend_uchar type, zstr *pbuf, size_t max_len, const char *format, ...); +PHPAPI int vzspprintf(zend_uchar type, zstr *pbuf, size_t max_len, const char *format, va_list ap); END_EXTERN_C() #endif /* SNPRINTF_H */ -- 2.50.1