<pre class="cpp" name="code"> switch (*fmt) {
case '-':
flags |= LEFT; goto repeat;
case '+':
flags |= PLUS; goto repeat;
case ' ':
flags |= SPACE; goto repeat;
case '#':
flags |= SPECIAL; goto repeat;
case '0':
flags |= ZEROPAD; goto repeat;
}
/* get field width */
field_width = -1;
if (is_digit(*fmt)) {
field_width = skip_atoi(&fmt);
} else if (*fmt == '*') {
/* it's the next argument */
++fmt;
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt)) {
precision = skip_atoi(&fmt);
} else if (*fmt == '*') {
/* it's the next argument */
precision = va_arg(args, int);
}
if (precision < 0) {
precision = 0;
}
}
/* get the conversion qualifier */
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
}