Changeset d8831151 for core


Ignore:
Timestamp:
Jul 7, 2017 5:25:25 PM (3 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
e83d31f
Parents:
87d6c30
Message:

Console: Fix log file size config bug on /configlogging bug (ticket #1996)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/DataHelper.java

    r87d6c30 rd8831151  
    15501550        }
    15511551    }
    1552    
     1552
    15531553    /**
    15541554     * Like formatSize but with a non-breaking space after the number
    15551555     * This seems consistent with most style guides out there.
    1556      * Use only in HTML
    1557      * @since 0.7.14
     1556     * Use only in HTML, and not inside form values (use
     1557     * formatSize2(bytes, false) there instead).
     1558     * @since 0.7.14, uses thin non-breaking space since 0.9.31
    15581559     */
    15591560    public static String formatSize2(long bytes) {
     1561        return formatSize2(bytes, true);
     1562    }
     1563
     1564    /**
     1565     * Like formatSize but with a space after the number
     1566     * This seems consistent with most style guides out there.
     1567     * @param nonBreaking use an HTML thin non-breaking space (&#8239;)
     1568     * @since 0.9.31
     1569     */
     1570    public static String formatSize2(long bytes, boolean nonBreaking) {
    15601571        double val = bytes;
    15611572        int scale = 0;
     
    15691580        // Replace &nbsp; with thin non-breaking space &#8239; (more consistent/predictable width between fonts & point sizes)
    15701581
    1571         String str = fmt.format(val);
     1582        String space = nonBreaking ? "&#8239;" : " ";
     1583        String str = fmt.format(val) + space;
    15721584        switch (scale) {
    1573             case 1: return str + "&#8239;K";
    1574             case 2: return str + "&#8239;M";
    1575             case 3: return str + "&#8239;G";
    1576             case 4: return str + "&#8239;T";
    1577             case 5: return str + "&#8239;P";
    1578             case 6: return str + "&#8239;E";
    1579             case 7: return str + "&#8239;Z";
    1580             case 8: return str + "&#8239;Y";
    1581             default: return bytes + "&#8239;";
     1585            case 1: return str + "K";
     1586            case 2: return str + "M";
     1587            case 3: return str + "G";
     1588            case 4: return str + "T";
     1589            case 5: return str + "P";
     1590            case 6: return str + "E";
     1591            case 7: return str + "Z";
     1592            case 8: return str + "Y";
     1593            default: return bytes + space;
    15821594        }
    15831595    }
Note: See TracChangeset for help on using the changeset viewer.