summaryrefslogtreecommitdiff
path: root/strio.h
diff options
context:
space:
mode:
authorwrmr2025-08-25 17:54:43 -0400
committerwrmr2025-08-25 17:54:43 -0400
commit71237ea0c5eb0c7b0d7894e0b3b01dbcf8a43982 (patch)
tree1711cf7c8ca5e39d13b2d175058fd3661d2be304 /strio.h
parentdbd8996f00cd8b30c1be988a97e72040e8b35200 (diff)
str_fmt %S specifier --- don't str_cat if s.n == 0
Diffstat (limited to 'strio.h')
-rw-r--r--strio.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/strio.h b/strio.h
index ab4d2bc..2376514 100644
--- a/strio.h
+++ b/strio.h
@@ -176,9 +176,10 @@ void str_cat_fmtv(Str *out, Arena *arena, const char *fmt, va_list ap) {
case 's':
str_cat(out, str_from_cstr(va_arg(ap, const char *)), arena);
break;
- case 'S':
- str_cat(out, va_arg(ap, Str), arena);
- break;
+ case 'S': {
+ Str s = va_arg(ap, Str);
+ if (s.n > 0) str_cat(out, s, arena);
+ } break;
case 'i':
str_cat_i64(out, va_arg(ap, int32_t), zero_pad?'0':' ', min_width, arena);
break;