mprintf: overhaul and bugfixes

In a test case using lots of snprintf() calls using many commonly used
%-codes per call, this version is around 30% faster than previous
version.

It also fixes the #12561 bug which made it not behave correctly when
given unknown %-sequences. Fixing that flaw required a different take on
the problem, which resulted in the new two-arrays model.

lib557: extended - Verify the #12561 fix and test more printf features

unit1398: fix test: It used a <num>$ only for one argument, which is not
supported.

Fixes #12561
Closes #12563
This commit is contained in:
Daniel Stenberg 2023-12-22 09:51:20 +01:00
parent 2d4d0c1fd3
commit ef2cf58c77
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 653 additions and 587 deletions

View file

@ -92,7 +92,7 @@ fail_unless(rc == 15, "return code should be 15");
fail_unless(!strcmp(output, " 1234 567"), "wrong output");
/* double precision */
rc = curl_msnprintf(output, 24, "%.*1$.99d", 3, 5678);
rc = curl_msnprintf(output, 24, "%2$.*1$.99d", 3, 5678);
fail_unless(rc == 0, "return code should be 0");
UNITTEST_STOP