summaryrefslogtreecommitdiff
path: root/pager.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-02-18 19:45:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-02-18 19:45:02 (GMT)
commitca00db08da414b3f6bd9481a51fdbb4b6836719c (patch)
tree52f110cfd65111f55e667bccc2652ea57c7c2e91 /pager.c
parentde15bdb0583a1a65bf1bab47b7bec9bdc03f727a (diff)
parentd306f3d3513c62342fec4e31457766f2473f9e9a (diff)
downloadgit-ca00db08da414b3f6bd9481a51fdbb4b6836719c.zip
git-ca00db08da414b3f6bd9481a51fdbb4b6836719c.tar.gz
git-ca00db08da414b3f6bd9481a51fdbb4b6836719c.tar.bz2
Merge branch 'jk/decimal-width-for-uintmax'
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 f6e8c33..98b2682 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;
}