summaryrefslogtreecommitdiff
path: root/pager.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2015-03-05 13:12:59 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-03-05 13:12:59 -0800
commit3bef3c12d6c0f5be0e95eb143fdd32583bae7a74 (patch)
treeb0e85bc4ca5747690f50e3aa1a62a07b3fc7e7c1 /pager.c
parentMerge branch 'jc/push-cert' into maint (diff)
parentdecimal_width: avoid integer overflow (diff)
downloadtgif-3bef3c12d6c0f5be0e95eb143fdd32583bae7a74.tar.xz
Merge branch 'jk/decimal-width-for-uintmax' into maint
We didn't format an integer that wouldn't fit in "int" but in "uintmax_t" correctly. * jk/decimal-width-for-uintmax: decimal_width: avoid integer overflow
Diffstat (limited to 'pager.c')
-rw-r--r--pager.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/pager.c b/pager.c
index f6e8c33192..98b26823c9 100644
--- a/pager.c
+++ b/pager.c
@@ -133,12 +133,12 @@ int term_columns(void)
/*
* How many columns do we need to show this number in decimal?
*/
-int decimal_width(int number)
+int decimal_width(uintmax_t number)
{
- int i, width;
+ int width;
- for (width = 1, i = 10; i <= number; width++)
- i *= 10;
+ for (width = 1; number >= 10; width++)
+ number /= 10;
return width;
}