Skip to content

Commit

Permalink
Merge branch 'jk/decimal-width-for-uintmax'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Feb 18, 2015
2 parents de15bdb + d306f3d commit ca00db0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ extern const char *pager_program;
extern int pager_in_use(void);
extern int pager_use_color;
extern int term_columns(void);
extern int decimal_width(int);
extern int decimal_width(uintmax_t);
extern int check_pager_config(const char *cmd);

extern const char *editor_program;
Expand Down
8 changes: 4 additions & 4 deletions pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ca00db0

Please sign in to comment.