| 537 | */ |
| 538 | |
| 539 | size_t my_vsnprintf_ex(const CHARSET_INFO *cs, char *to, size_t n, |
| 540 | const char* fmt, va_list ap) |
| 541 | { |
| 542 | char *start=to, *end=to+n-1; |
| 543 | size_t length, width; |
| 544 | uint print_type, have_longlong; |
| 545 | |
| 546 | for (; *fmt ; fmt++) |
| 547 | { |
| 548 | if (*fmt != '%') |
| 549 | { |
| 550 | if (to == end) /* End of buffer */ |
| 551 | break; |
| 552 | *to++= *fmt; /* Copy ordinary char */ |
| 553 | continue; |
| 554 | } |
| 555 | fmt++; /* skip '%' */ |
| 556 | |
| 557 | length= width= 0; |
| 558 | print_type= 0; |
| 559 | |
| 560 | /* Read max fill size (only used with %d and %u) */ |
| 561 | if (my_isdigit(&my_charset_latin1, *fmt)) |
| 562 | { |
| 563 | fmt= get_length(fmt, &length, &print_type); |
| 564 | if (*fmt == '$') |
| 565 | { |
| 566 | to= process_args(cs, to, end, (fmt+1), length, ap); |
| 567 | return (size_t) (to - start); |
| 568 | } |
| 569 | } |
| 570 | else |
| 571 | { |
| 572 | if (*fmt == '`') |
| 573 | { |
| 574 | print_type|= ESCAPED_ARG; |
| 575 | fmt++; |
| 576 | } |
| 577 | if (*fmt == '-') |
| 578 | fmt++; |
| 579 | if (*fmt == '*') |
| 580 | { |
| 581 | fmt++; |
| 582 | length= va_arg(ap, int); |
| 583 | } |
| 584 | else |
| 585 | fmt= get_length(fmt, &length, &print_type); |
| 586 | } |
| 587 | |
| 588 | if (*fmt == '.') |
| 589 | { |
| 590 | fmt++; |
| 591 | if (*fmt == '*') |
| 592 | { |
| 593 | fmt++; |
| 594 | width= va_arg(ap, int); |
| 595 | } |
| 596 | else |
no test coverage detected