mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-16 17:01:53 +00:00
[gamecode] Use a flag for format width
This ensures caller specified width always gets through to libc's printf, even if the caller specifies 0. More importantly, * works correctly.
This commit is contained in:
parent
0df16fb210
commit
2119688b48
1 changed files with 4 additions and 1 deletions
|
@ -51,6 +51,7 @@
|
|||
#define FMT_ADDBLANK (1<<4)
|
||||
#define FMT_HEX (1<<5)
|
||||
#define FMT_LONG (1<<6)
|
||||
#define FMT_WIDTH (1<<7)
|
||||
|
||||
typedef struct fmt_item_s {
|
||||
byte type;
|
||||
|
@ -748,7 +749,7 @@ I_DoPrint (dstring_t *tmp, dstring_t *result, fmt_item_t *formatting)
|
|||
qboolean doPrecision, doWidth;
|
||||
|
||||
doPrecision = -1 != current->precision;
|
||||
doWidth = 0 != current->minFieldWidth;
|
||||
doWidth = 0 != (current->flags & FMT_WIDTH);
|
||||
|
||||
dsprintf (tmp, "%%%s%s%s%s%s%s%s",
|
||||
(current->flags & FMT_ALTFORM) ? "#" : "", // hash
|
||||
|
@ -956,6 +957,7 @@ fmt_state_flags (fmt_state_t *state)
|
|||
static void
|
||||
fmt_state_var_field_width (fmt_state_t *state)
|
||||
{
|
||||
(*state->fi)->flags |= FMT_WIDTH;
|
||||
(*state->fi)->minFieldWidth = P_INT (pr, state->fmt_count);
|
||||
state->fmt_count++;
|
||||
if (*++state->c == '.') {
|
||||
|
@ -968,6 +970,7 @@ fmt_state_var_field_width (fmt_state_t *state)
|
|||
static void
|
||||
fmt_state_field_width (fmt_state_t *state)
|
||||
{
|
||||
(*state->fi)->flags |= FMT_WIDTH;
|
||||
while (isdigit ((byte )*state->c)) {
|
||||
(*state->fi)->minFieldWidth *= 10;
|
||||
(*state->fi)->minFieldWidth += *state->c++ - '0';
|
||||
|
|
Loading…
Reference in a new issue