Repository navigation
Conversation
3 of 8 tasks
Comment on lines
+34
to
+43
| #define DEFINE_WRAPPER(name, vfunc) \ | ||
| static int name(char *buf, size_t n, const char *fmt, ...) \ | ||
| { \ | ||
| va_list ap; \ | ||
| int ret; \ | ||
| \ | ||
| va_start(ap, fmt); \ | ||
| ret = vfunc(buf, n, fmt, ap); \ | ||
| va_end(ap); \ | ||
| return ret; \ |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
Suggested change
| #define DEFINE_WRAPPER(name, vfunc) \ | |
| static int name(char *buf, size_t n, const char *fmt, ...) \ | |
| { \ | |
| va_list ap; \ | |
| int ret; \ | |
| \ | |
| va_start(ap, fmt); \ | |
| ret = vfunc(buf, n, fmt, ap); \ | |
| va_end(ap); \ | |
| return ret; \ | |
| #define DEFINE_WRAPPER(name, vfunc) \ | |
| static int name(char *buf, size_t n, const char *fmt, ...) \ | |
| { \ | |
| va_list ap; \ | |
| int ret; \ | |
| \ | |
| va_start(ap, fmt); \ | |
| ret = vfunc(buf, n, fmt, ap); \ | |
| va_end(ap); \ | |
| return ret; \ |
Comment on lines
+55
to
+68
| #define RUN_CASES(label, fn) \ | ||
| do { \ | ||
| memset(buf, 0, sizeof buf); \ | ||
| fn(buf, sizeof buf, "%2$s %1$s", "a", "b"); \ | ||
| report(label, "%2$s %1$s", buf, "b a"); \ | ||
| memset(buf, 0, sizeof buf); \ | ||
| fn(buf, sizeof buf, "%2$d %1$s", "x", 42); \ | ||
| report(label, "%2$d %1$s", buf, "42 x"); \ | ||
| memset(buf, 0, sizeof buf); \ | ||
| fn(buf, sizeof buf, "%2$lu %1$llu", 5ULL, 7UL); \ | ||
| report(label, "%2$lu %1$llu", buf, "7 5"); \ | ||
| memset(buf, 0, sizeof buf); \ | ||
| fn(buf, sizeof buf, "%2$" PRIu64 " %1$s", "x", (uint64_t)123); \ | ||
| report(label, "%2$" PRIu64 " %1$s", buf, "123 x"); \ |
There was a problem hiding this comment.
[pre-commit] reported by reviewdog 🐶
Suggested change
| #define RUN_CASES(label, fn) \ | |
| do { \ | |
| memset(buf, 0, sizeof buf); \ | |
| fn(buf, sizeof buf, "%2$s %1$s", "a", "b"); \ | |
| report(label, "%2$s %1$s", buf, "b a"); \ | |
| memset(buf, 0, sizeof buf); \ | |
| fn(buf, sizeof buf, "%2$d %1$s", "x", 42); \ | |
| report(label, "%2$d %1$s", buf, "42 x"); \ | |
| memset(buf, 0, sizeof buf); \ | |
| fn(buf, sizeof buf, "%2$lu %1$llu", 5ULL, 7UL); \ | |
| report(label, "%2$lu %1$llu", buf, "7 5"); \ | |
| memset(buf, 0, sizeof buf); \ | |
| fn(buf, sizeof buf, "%2$" PRIu64 " %1$s", "x", (uint64_t)123); \ | |
| report(label, "%2$" PRIu64 " %1$s", buf, "123 x"); \ | |
| #define RUN_CASES(label, fn) \ | |
| do { \ | |
| memset(buf, 0, sizeof buf); \ | |
| fn(buf, sizeof buf, "%2$s %1$s", "a", "b"); \ | |
| report(label, "%2$s %1$s", buf, "b a"); \ | |
| memset(buf, 0, sizeof buf); \ | |
| fn(buf, sizeof buf, "%2$d %1$s", "x", 42); \ | |
| report(label, "%2$d %1$s", buf, "42 x"); \ | |
| memset(buf, 0, sizeof buf); \ | |
| fn(buf, sizeof buf, "%2$lu %1$llu", 5ULL, 7UL); \ | |
| report(label, "%2$lu %1$llu", buf, "7 5"); \ | |
| memset(buf, 0, sizeof buf); \ | |
| fn(buf, sizeof buf, "%2$" PRIu64 " %1$s", "x", (uint64_t)123); \ | |
| report(label, "%2$" PRIu64 " %1$s", buf, "123 x"); \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A reviewer on #720 asked whether C translation strings can use positional placeholders (
%1$s,%2$s) so translators can reorder arguments. GRASS messages go throughG_vasprintf()tovsnprintf, and I don't know whether that supports%N$on Windows.This adds a throwaway workflow that compiles a small C program with MSVC and with MSYS2 MinGW64 (with and without
__USE_MINGW_ANSI_STDIO) and prints PASS/FAIL forsnprintf, avsnprintfwrapper and, on MSVC,_snprintf_p/_vsprintf_p. It does not build GRASS and is not meant to be merged upstream.I used Claude to help write the workflow.