Skip to content

Commit

Permalink
Fix conversion string in bsnprintf.
Browse files Browse the repository at this point in the history
It makes no sense to use a string "0123456789ABCDEF" when you do
all calculating using a modulo 10 divide which only gives the spread
from 0 to 9. As we don't need the hex letters we can also drop the check
on caps as figures are either upper or lower case.
  • Loading branch information
Marco van Wieringen committed May 5, 2013
1 parent b1cb3f5 commit 195ad08
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/bsnprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ static int32_t fmtfp(char *buffer, int32_t currlen, int32_t maxlen,
#endif

/* Convert integer part */
cvt_str = caps ? "0123456789ABCDEF" : "0123456789abcdef";
cvt_str = "0123456789";
do {
iconvert[iplace++] = cvt_str[(int)(intpart % 10)];
intpart = (intpart / 10);
Expand All @@ -716,7 +716,7 @@ static int32_t fmtfp(char *buffer, int32_t currlen, int32_t maxlen,
iconvert[iplace] = 0;

/* Convert fractional part */
cvt_str = caps ? "0123456789ABCDEF" : "0123456789abcdef";
cvt_str = "0123456789";
fiter = max;
do {
fconvert[fplace++] = cvt_str[fracpart % 10];
Expand Down

0 comments on commit 195ad08

Please sign in to comment.