Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/libbb/human_readable.c

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/*
    23 * June 30, 2001                 Manuel Novoa III
     
    2627 */
    2728
    28 #include <stdio.h>
    2929#include "libbb.h"
    3030
     
    3232    unsigned long block_size, unsigned long display_unit)
    3333{
    34     /* The code will adjust for additional (appended) units. */
    35     static const char zero_and_units[] = { '0', 0, 'k', 'M', 'G', 'T' };
    36     static const char fmt[] = "%llu";
    37     static const char fmt_tenths[] = "%llu.%d%c";
     34    /* The code will adjust for additional (appended) units */
     35    static const char zero_and_units[] ALIGN1 = { '0', 0, 'k', 'M', 'G', 'T' };
     36    static const char fmt[] ALIGN1 = "%llu";
     37    static const char fmt_tenths[] ALIGN1 = "%llu.%d%c";
    3838
    39     static char str[21];        /* Sufficient for 64 bit unsigned integers. */
     39    static char str[21] ALIGN1;  /* Sufficient for 64 bit unsigned integers */
    4040
    4141    unsigned long long val;
     
    5454
    5555    if (display_unit) {
    56         val += display_unit/2;  /* Deal with rounding. */
     56        val += display_unit/2;  /* Deal with rounding */
    5757        val /= display_unit;    /* Don't combine with the line above!!! */
    5858    } else {
    5959        ++u;
    60         while ((val >= KILOBYTE)
    61                && (u < zero_and_units + sizeof(zero_and_units) - 1)) {
     60        while ((val >= 1024)
     61         && (u < zero_and_units + sizeof(zero_and_units) - 1)
     62        ) {
    6263            f = fmt_tenths;
    6364            ++u;
    64             frac = ((((int)(val % KILOBYTE)) * 10) + (KILOBYTE/2)) / KILOBYTE;
    65             val /= KILOBYTE;
     65            frac = (((int)(val % 1024)) * 10 + 1024/2) / 1024;
     66            val /= 1024;
    6667        }
    6768        if (frac >= 10) {       /* We need to round up here. */
     
    7172#if 0
    7273        /* Sample code to omit decimal point and tenths digit. */
    73         if ( /* no_tenths */ 1 ) {
    74             if ( frac >= 5 ) {
     74        if (/* no_tenths */ 1) {
     75            if (frac >= 5) {
    7576                ++val;
    7677            }
    77             f = "%llu%*c" /* fmt_no_tenths */ ;
     78            f = "%llu%*c" /* fmt_no_tenths */;
    7879            frac = 1;
    7980        }
Note: See TracChangeset for help on using the changeset viewer.