roken: snprintf properly account for char widths

If a char width is specified the number of output buffer bytes
consumed might be greater than one.   Update append_char() to
return the number of bytes consumed and use that value in xyzprintf()
instead of one.
This commit is contained in:
Jeffrey Altman
2023-06-06 09:32:33 -04:00
parent c64d4ce968
commit adde2e5b4b

View File

@@ -309,7 +309,7 @@ append_char(struct snprintf_state *state,
(*state->append_char) (state, ' ');
++len;
}
return 0;
return len;
}
/*
@@ -437,8 +437,7 @@ xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap)
switch (c) {
case 'c' :
append_char(state, va_arg(ap, int), width, flags);
++len;
len += append_char(state, va_arg(ap, int), width, flags);
break;
case 's' :
len += append_string(state,