mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-05 06:14:25 +03:00
printf core: replace if(0) blocks around switch cases with explicit gotos
this is purely a readability change, not a functional one. all of the integer format cases use a common tail for handling precision logic after the string representation of the number has been generated. the code as I originally wrote it was overly clever in the aim of making a point that the flow could be done without goto, and jumped over intervening cases by wrapping them in if (0) { }, with the case labels for each inside the conditional block scope. this has been a perpetual source of complaints about the readability and comprehensibility of the file, so I am now changing it to explicitly jump to the tail logic with goto statements.
This commit is contained in:
parent
06a9647093
commit
ee18e584bf
@ -557,11 +557,11 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
|
||||
case 'x': case 'X':
|
||||
a = fmt_x(arg.i, z, t&32);
|
||||
if (arg.i && (fl & ALT_FORM)) prefix+=(t>>4), pl=2;
|
||||
if (0) {
|
||||
goto ifmt_tail;
|
||||
case 'o':
|
||||
a = fmt_o(arg.i, z);
|
||||
if ((fl&ALT_FORM) && p<z-a+1) p=z-a+1;
|
||||
} if (0) {
|
||||
goto ifmt_tail;
|
||||
case 'd': case 'i':
|
||||
pl=1;
|
||||
if (arg.i>INTMAX_MAX) {
|
||||
@ -573,7 +573,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
|
||||
} else pl=0;
|
||||
case 'u':
|
||||
a = fmt_u(arg.i, z);
|
||||
}
|
||||
ifmt_tail:
|
||||
if (xp && p<0) goto overflow;
|
||||
if (xp) fl &= ~ZERO_PAD;
|
||||
if (!arg.i && !p) {
|
||||
|
Loading…
Reference in New Issue
Block a user