- if (fmt_expr->kind == EXPR_WIDE_STRING_LITERAL) {
- vchar.string = &fmt_expr->wide_string.value;
- vchar.size = fmt_expr->wide_string.value.size;
- vchar.first = wstring_first;
- vchar.next = wstring_next;
- vchar.is_digit = wstring_isdigit;
- } else if (fmt_expr->kind == EXPR_STRING_LITERAL) {
- vchar.string = &fmt_expr->string.value;
- vchar.size = fmt_expr->string.value.size;
- vchar.first = string_first;
- vchar.next = string_next;
- vchar.is_digit = string_isdigit;
- } else {
- return;
+ switch (fmt_expr->kind) {
+ case EXPR_STRING_LITERAL:
+ vchar.string = &fmt_expr->string.value;
+ vchar.size = fmt_expr->string.value.size;
+ vchar.first = string_first;
+ vchar.next = string_next;
+ vchar.is_digit = string_isdigit;
+ break;
+
+ case EXPR_WIDE_STRING_LITERAL:
+ vchar.string = &fmt_expr->wide_string.value;
+ vchar.size = fmt_expr->wide_string.value.size;
+ vchar.first = wstring_first;
+ vchar.next = wstring_next;
+ vchar.is_digit = wstring_isdigit;
+ break;
+
+ case EXPR_CONDITIONAL: {
+ conditional_expression_t const *const c = &fmt_expr->conditional;
+ expression_t const * t = c->true_expression;
+ if (t == NULL)
+ t = c->condition;
+ int const nt = internal_check_printf_format(t, arg, spec);
+ int const nf = internal_check_printf_format(c->false_expression, arg, spec);
+ return nt > nf ? nt : nf;
+ }
+
+ default:
+ return -1;