]> granicus.if.org Git - php/commitdiff
- Fix [v]uspprintf()
authorMarcus Boerger <helly@php.net>
Thu, 18 Jan 2007 21:39:50 +0000 (21:39 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 18 Jan 2007 21:39:50 +0000 (21:39 +0000)
- Add [v]zspprintf

main/spprintf.c
main/spprintf.h

index 70f25c3104c120591545c6e494b3882edbe08715..425a6105e14568d9542ff740cdacd3a2570ed49b 100644 (file)
@@ -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
index 96af944b5c7e6fa9c02a8c9223a919de225dcd6c..3480e4e9bdd7e0dbad1c22f919d7b11b70738c6d 100644 (file)
@@ -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 */