* Added small patch to support negative values (such as negative disk capacity) ...
authorBrenden Matthews <brenden1@rty.ca>
Fri, 12 Sep 2008 05:03:38 +0000 (05:03 +0000)
committerBrenden Matthews <brenden1@rty.ca>
Fri, 12 Sep 2008 05:03:38 +0000 (05:03 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1251 7f574dfc-610e-0410-a909-a81674777703

AUTHORS
ChangeLog
src/conky.c

diff --git a/AUTHORS b/AUTHORS
index d383e01..3e766b1 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -115,6 +115,9 @@ Gwenhael LE MOINE <cycojesus at yahoo dot fr>
 Hannu Saransaari <hipo at users dot sourceforge dot net>
   Main code
 
+hinokind <hinokind at users dot sourceforge dot net>
+  support negative values in human_readable()
+
 Jason Mitchell <jason.mitchell03 at saintleo dot edu>
   developer
   UTF8 fix
index 01ff7ba..edf02ca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
        (http://bugs.gentoo.org/show_bug.cgi?id=235233)
        * Improve timed_thread interval timing
        * Improve Conky's overall interval timing
+       * Added small patch to support negative values (such as negative disk
+       capacity) (thanks hinokind)
 
 2008-09-10
        * Improved hddtemp support
index 5597e21..471e81a 100644 (file)
@@ -1055,7 +1055,7 @@ static void human_readable(long long num, char *buf, int size, const char *func_
        int precision, len;
        static const int WIDTH = 10, SHORT_WIDTH = 8;
 
-       if (num < 1024LL) {
+       if (num < 1024LL && num > -1024LL) {
                if (short_units) {
                        spaced_print(buf, size, "%lld%c", SHORT_WIDTH, func_name, num,
                                **suffix);
@@ -1065,7 +1065,7 @@ static void human_readable(long long num, char *buf, int size, const char *func_
                return;
        }
 
-       while (num / 1024 >= 1000LL && **(suffix + 2)) {
+       while ((num / 1024 >= 1000LL || num / 1024 <= -1024LL) && **(suffix + 2)) {
                num /= 1024;
                suffix++;
        }