cvs: php4 /ext/standard php_smart_str.h

From: Date: Mon, 20 Aug 2001 15:26:10 +0000
Subject: cvs: php4 /ext/standard php_smart_str.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6975@lists.php.net to get a copy of this message
stas Mon Aug 20 11:26:10 2001 EDT Modified files: /php4/ext/standard php_smart_str.h Log: Fix long printing in smart_str_print_long Index: php4/ext/standard/php_smart_str.h diff -u php4/ext/standard/php_smart_str.h:1.11 php4/ext/standard/php_smart_str.h:1.12 --- php4/ext/standard/php_smart_str.h:1.11 Sat Aug 11 13:03:37 2001 +++ php4/ext/standard/php_smart_str.h Mon Aug 20 11:26:10 2001 @@ -78,27 +78,32 @@ static inline char *smart_str_print_long(char *buf, long num) { + /* TBFixed: think how to do it one-pass */ + long tmp; char *p = buf; - long tmp = 0; int n = 0; + + if(num == 0) { + *p++ = '0'; + return p; + } if (num < 0) { num = -num; *p++ = '-'; } + for (tmp = num; tmp > 0; n++) { + tmp /= 10; + } + p += n; + while (num > 0) { - tmp = tmp * 10 + (num % 10); + *(--p) = (num % 10) + '0'; num /= 10; - n++; } - do { - *p++ = (tmp % 10) + '0'; - tmp /= 10; - } while (--n > 0); - - return p; + return p+n; } static inline void smart_str_append_long_ex(smart_str *dest, long num, int type)

« previous php.cvs (#6975) next »