1
0
forked from aniani/vim

patch 9.0.1856: issues with formatting positional arguments

Problem:  issues with formatting positional arguments
Solution: fix them, add tests and documentation

closes: #12140
closes: #12985

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
Tentatively fix message_test. Check NULL ptr.
This commit is contained in:
Christ van Willegen
2023-09-03 17:22:37 +02:00
committed by Christian Brabandt
parent 71ebf3baca
commit aa90d4f031
5 changed files with 59 additions and 35 deletions

View File

@@ -40,6 +40,7 @@ char *fmt_012p = "%012p";
char *fmt_5S = "%5S";
char *fmt_06b = "%06b";
char *fmt_06pb = "%1$0.*2$b";
char *fmt_06pb2 = "%2$0*1$b";
char *fmt_212s = "%2$s %1$s %2$s";
char *fmt_21s = "%2$s %1$s";
@@ -442,6 +443,11 @@ test_vim_snprintf_positional(void)
assert(bsize == 0 || STRNCMP(buf, "deadbeef", bsize_int) == 0);
assert(bsize == 0 || buf[MIN(n, bsize_int)] == '\0');
n = vim_snprintf(buf, bsize, fmt_06pb2, 6, (uvarnumber_T)12);
assert(n == 6);
assert(bsize == 0 || STRNCMP(buf, "001100", bsize_int) == 0);
assert(bsize == 0 || buf[MIN(n, bsize_int)] == '\0');
n = vim_snprintf(buf, bsize, fmt_06pb, (uvarnumber_T)12, 6);
assert(n == 6);
assert(bsize == 0 || STRNCMP(buf, "001100", bsize_int) == 0);