mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 00:29:31 +00:00
Fixed several bugs
git-svn-id: svn://svn.cc65.org/cc65/trunk@3328 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
e43766ea93
commit
5b851fb621
@ -342,7 +342,7 @@ void SB_VPrintf (StrBuf* S, const char* Format, va_list ap)
|
||||
* an allocation. If not, we have to reallocate and try again.
|
||||
*/
|
||||
va_copy (tmp, ap);
|
||||
SizeNeeded = xvsnprintf (S->Buf, S->Allocated, Format, ap);
|
||||
SizeNeeded = xvsnprintf (S->Buf, S->Allocated, Format, tmp);
|
||||
va_end (tmp);
|
||||
|
||||
/* Check the result, the xvsnprintf function should not fail */
|
||||
|
@ -378,7 +378,7 @@ int xvsnprintf (char* Buf, size_t Size, const char* Format, va_list ap)
|
||||
}
|
||||
/* Optional field width */
|
||||
if (F == '*') {
|
||||
P.Width = va_arg (ap, int);
|
||||
P.Width = va_arg (P.ap, int);
|
||||
/* A negative field width argument is taken as a - flag followed
|
||||
* by a positive field width.
|
||||
*/
|
||||
@ -405,13 +405,14 @@ int xvsnprintf (char* Buf, size_t Size, const char* Format, va_list ap)
|
||||
F = *Format++;
|
||||
P.Flags |= fPrec;
|
||||
if (F == '*') {
|
||||
P.Prec = va_arg (ap, int);
|
||||
P.Prec = va_arg (P.ap, int);
|
||||
/* A negative precision argument is taken as if the precision
|
||||
* were omitted.
|
||||
*/
|
||||
if (P.Prec < 0) {
|
||||
P.Flags &= ~fPrec;
|
||||
}
|
||||
F = *Format++; /* Skip the '*' */
|
||||
} else if (IsDigit (F)) {
|
||||
P.Prec = F - '0';
|
||||
while (1) {
|
||||
@ -425,8 +426,11 @@ int xvsnprintf (char* Buf, size_t Size, const char* Format, va_list ap)
|
||||
/* A negative precision argument is taken as if the precision
|
||||
* were omitted.
|
||||
*/
|
||||
F = *Format++; /* Skip the minus */
|
||||
while (IsDigit (F = *Format++)) ;
|
||||
P.Flags &= ~fPrec;
|
||||
} else {
|
||||
P.Prec = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,7 +490,7 @@ int xvsnprintf (char* Buf, size_t Size, const char* Format, va_list ap)
|
||||
}
|
||||
/* If a precision is specified, the 0 flag is ignored */
|
||||
if (P.Flags & fPrec) {
|
||||
P.Flags &= fZero;
|
||||
P.Flags &= ~fZero;
|
||||
}
|
||||
|
||||
/* Conversion specifier */
|
||||
@ -519,13 +523,13 @@ int xvsnprintf (char* Buf, size_t Size, const char* Format, va_list ap)
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
SBuf[0] = (char) va_arg (ap, int);
|
||||
SBuf[0] = (char) va_arg (P.ap, int);
|
||||
SBuf[1] = '\0';
|
||||
FormatStr (&P, SBuf);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
SPtr = va_arg (ap, const char*);
|
||||
SPtr = va_arg (P.ap, const char*);
|
||||
CHECK (SPtr != 0);
|
||||
FormatStr (&P, SPtr);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user