helly           Sun Aug 14 16:11:09 2005 EDT

  Modified files:              
    /php-src/main       spprintf.c 
  Log:
  - Handle different cases of the actual strings correctly
  
http://cvs.php.net/diff.php/php-src/main/spprintf.c?r1=1.27&r2=1.28&ty=u
Index: php-src/main/spprintf.c
diff -u php-src/main/spprintf.c:1.27 php-src/main/spprintf.c:1.28
--- php-src/main/spprintf.c:1.27        Sun Aug 14 13:14:42 2005
+++ php-src/main/spprintf.c     Sun Aug 14 16:11:05 2005
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: spprintf.c,v 1.27 2005/08/14 17:14:42 helly Exp $ */
+/* $Id: spprintf.c,v 1.28 2005/08/14 20:11:05 helly Exp $ */
 
 /* This is the spprintf implementation.
  * It has emerged from apache snprintf. See original header:
@@ -126,14 +126,22 @@
        }                                                                       
                        \
 } while (0)
 
-#define INS_STRING(unicode, xbuf, s, slen) do {        \
-       if (unicode) {                                                          
        \
-               smart_str_appendl(xbuf, s, slen);                       \
-       } else {                                                                
                \
-               size_t newlen, sz = 2*(slen);                           \
+#define INS_STRING(unicode, s_uni, xbuf, s, slen)      \
+do {                                                                           
                \
+       if (unicode) {
+               size_t newlen, p, sz = 2*(slen);                        \
                smart_str_alloc(xbuf, (sz), 0);                         \
-               memcpy(xbuf->c + xbuf->len, s, (sz));           \
+               if (s_uni) {                                                    
        \
+                       memcpy(xbuf->c + xbuf->len, s, (sz));   \
+               } else {                                                        
                \
+                       p = (slen);                                             
                \
+                       while(p--) {                            \
+                               smart_str_append2c(xbuf, *s++);         \
+                       }                                                       
                        \
+               }                                                               
                        \
                xbuf->len += (sz);                                              
        \
+       } else {                                                                
                \
+               smart_str_appendl(xbuf, s, slen);                       \
        }                                                                       
                        \
 } while (0)
        
@@ -151,7 +159,7 @@
                        p = sz;                                                 
                \
                        sz <<= 1;                                               
                \
                        smart_str_alloc(xbuf, sz, 0);                   \
-                       while(p--) smart_str_appendc(xbuf, ch); \
+                       while(p--) smart_str_append2c(xbuf, ch);\
                } else {                                                        
                \
                        smart_str_alloc(xbuf, sz, 0);                   \
                        memset(xbuf->c + xbuf->len, ch, sz);    \
@@ -786,7 +794,7 @@
                        /*
                         * Print the string s. 
                         */
-                       INS_STRING(s_unicode, xbuf, s, s_len);
+                       INS_STRING(unicode, s_unicode, xbuf, s, s_len);
                        if (free_s) efree(s);
 
                        if (adjust_width && adjust == LEFT && min_width > 
s_len) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to