]> granicus.if.org Git - php/commitdiff
Treat trailing zeroes correctly
authorSascha Schumann <sas@php.net>
Fri, 3 Aug 2001 11:09:13 +0000 (11:09 +0000)
committerSascha Schumann <sas@php.net>
Fri, 3 Aug 2001 11:09:13 +0000 (11:09 +0000)
ext/standard/php_smart_str.h

index 8146a057d3f7fb1ceefc0cba0162152766207954..e90e664eb2a031481d91ed31593aeeeb64e13ffd 100644 (file)
@@ -80,6 +80,7 @@ static inline char *smart_str_print_long(char *buf, long num)
 {
        char *p = buf;
        long tmp = 0;
+       int n = 0;
        
        if (num < 0) {
                num = -num;
@@ -89,12 +90,13 @@ static inline char *smart_str_print_long(char *buf, long num)
        while (num > 0) {
                tmp = tmp * 10 + (num % 10);
                num /= 10;
+               n++;
        }
 
        do {
                *p++ = (tmp % 10) + '0';
                tmp /= 10;
-       } while (tmp > 0);
+       } while (--n > 0);
 
        return p;
 }