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
This commit is contained in:
8
pager.c
8
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user