]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #1906: Huge ratio precision (too many decimal places)
authorCharles Kerr <charles@transmissionbt.com>
Mon, 9 Mar 2009 23:51:58 +0000 (23:51 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Mon, 9 Mar 2009 23:51:58 +0000 (23:51 +0000)
libtransmission/utils.c

index 1ee52ded6201c370c022774c1729c82a8cb879ba..0ff89275fa92921d9e30513c7ec7c24a6be2d5f4 100644 (file)
@@ -1530,8 +1530,10 @@ printf_double_without_rounding( char * buf, int buflen, double d, int places )
     char tmp[128];
     int len;
     tr_snprintf( tmp, sizeof( tmp ), "%'.64f", d );
-    pch = strchr( tmp, '.' );
-    pch += places + 1;
+    pch = tmp;
+    while( isdigit( *pch ) ) ++pch; /* walk to the decimal point */
+    ++pch; /* walk over the decimal point */
+    pch += places;
     len = MIN( buflen - 1, pch - tmp );
     memcpy( buf, tmp, len );
     buf[len] = '\0';