From: cuz Date: Thu, 16 Dec 2004 20:26:46 +0000 (+0000) Subject: Fixed another bug X-Git-Tag: V2.12.0~507 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0ce95ffe6ac9cb0ab59cce5d9f22a1c9dd630144;p=cc65 Fixed another bug git-svn-id: svn://svn.cc65.org/cc65/trunk@3329 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/common/xsprintf.c b/src/common/xsprintf.c index 8ab92eccf..0242542f7 100644 --- a/src/common/xsprintf.c +++ b/src/common/xsprintf.c @@ -211,6 +211,15 @@ static void FormatInt (PrintfCtrl* P, unsigned long Val) /* Convert the value into a (reversed string). */ ToStr (P, Val); + /* The default precision for all integer conversions is one. This means + * that the fPrec flag is always set and does not need to be checked + * later on. + */ + if ((P->Flags & fPrec) == 0) { + P->Flags |= fPrec; + P->Prec = 1; + } + /* Determine the leaders for alternative forms */ if ((P->Flags & fHash) != 0) { if (P->Base == 16) { @@ -219,14 +228,14 @@ static void FormatInt (PrintfCtrl* P, unsigned long Val) Lead[LeadCount++] = (P->Flags & fUpcase)? 'X' : 'x'; } else if (P->Base == 8) { /* Alternative form for 'o': always add a leading zero. */ - if ((P->Flags & fPrec) == 0 || P->Prec <= P->ArgLen) { + if (P->Prec <= P->ArgLen) { Lead[LeadCount++] = '0'; } } } /* Determine the amount of precision padding needed */ - if ((P->Flags & fPrec) != 0 && P->ArgLen < P->Prec) { + if (P->ArgLen < P->Prec) { PrecPadding = P->Prec - P->ArgLen; } else { PrecPadding = 0;