From d046315e8b4eb5d55ac92dd0835b96d6062e97f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 2 Aug 2014 11:44:15 +0200 Subject: [PATCH] api: fix function string_format_size on 32-bit systems --- ChangeLog.asciidoc | 1 + src/core/wee-string.c | 8 ++++---- tests/unit/core/test-string.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index e2731059d..f89f70fe2 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -100,6 +100,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * core: display a warning in case of inconsistency between the options weechat.look.save_{config|layout}_on_exit * tests: add unit tests using CppUTest +* api: fix function string_format_size on 32-bit systems * api: add argument "flags" in function hdata_new_list * api: change type of arguments displayed/highlight in hook_print callback from string to integer (in scripts) diff --git a/src/core/wee-string.c b/src/core/wee-string.c index de4443773..dd4b799eb 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -2300,13 +2300,13 @@ string_format_size (unsigned long long size) str_size[0] = '\0'; - if (size < 10UL * 1000UL) + if (size < 10ULL * 1000ULL) num_unit = 0; - else if (size < 1000UL * 1000UL) + else if (size < 1000ULL * 1000ULL) num_unit = 1; - else if (size < 1000UL * 1000UL * 1000UL) + else if (size < 1000ULL * 1000ULL * 1000ULL) num_unit = 2; - else if (size < 1000UL * 1000UL * 1000UL * 1000UL) + else if (size < 1000ULL * 1000ULL * 1000ULL * 1000ULL) num_unit = 3; else num_unit = 4; diff --git a/tests/unit/core/test-string.cpp b/tests/unit/core/test-string.cpp index 85bbcc8a0..4ffe28761 100644 --- a/tests/unit/core/test-string.cpp +++ b/tests/unit/core/test-string.cpp @@ -29,10 +29,10 @@ extern "C" #include "../src/core/wee-string.h" } -#define ONE_KB 1000UL -#define ONE_MB (ONE_KB * 1000UL) -#define ONE_GB (ONE_MB * 1000UL) -#define ONE_TB (ONE_GB * 1000UL) +#define ONE_KB 1000ULL +#define ONE_MB (ONE_KB * 1000ULL) +#define ONE_GB (ONE_MB * 1000ULL) +#define ONE_TB (ONE_GB * 1000ULL) #define WEE_HAS_HL_STR(__result, __str, __words) \ LONGS_EQUAL(__result, string_has_highlight (__str, __words));