Changeset 10822 for trunk/libtransmission/utils.c
- Timestamp:
- Jun 22, 2010, 10:30:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/utils.c
r10819 r10822 1366 1366 1367 1367 char* 1368 tr_strpercent( char * buf, double x, size_t buflen ) 1369 { 1370 if( x < 10.0 ) 1371 tr_strtruncd( buf, x, 2, buflen ); 1372 else if( x < 100.0 ) 1373 tr_strtruncd( buf, x, 1, buflen ); 1374 else 1375 tr_strtruncd( buf, x, 0, buflen ); 1376 return buf; 1377 } 1378 1379 char* 1368 1380 tr_strratio( char * buf, size_t buflen, double ratio, const char * infinity ) 1369 1381 { … … 1372 1384 else if( (int)ratio == TR_RATIO_INF ) 1373 1385 tr_strlcpy( buf, infinity, buflen ); 1374 else if( ratio < 10.0 )1375 tr_snprintf( buf, buflen, "%.2f", tr_truncd( ratio, 2 ) );1376 else if( ratio < 100.0 )1377 tr_snprintf( buf, buflen, "%.1f", tr_truncd( ratio, 1 ) );1378 1386 else 1379 tr_snprintf( buf, buflen, "%'.0f", ratio ); 1387 tr_strpercent( buf, ratio, buflen ); 1388 return buf; 1389 } 1390 1391 char* 1392 tr_strtruncd( char * buf, double x, int precision, size_t buflen ) 1393 { 1394 tr_snprintf( buf, buflen, "%.*f", precision, tr_truncd( x, precision ) ); 1395 1380 1396 return buf; 1381 1397 }
Note: See TracChangeset
for help on using the changeset viewer.