summary refs log tree commit diff
path: root/buffer.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-06-07 00:09:58 -0400
committerJune McEnroe <june@causal.agency>2021-06-09 11:56:35 -0400
commite066a954f5b638103102250d87661d91f3c9f3f0 (patch)
treeac6694692bcea35ca8b0a29318cbbfcf5a849428 /buffer.c
parentAdd seprintf (diff)
downloadcatgirl-e066a954f5b638103102250d87661d91f3c9f3f0.tar.gz
catgirl-e066a954f5b638103102250d87661d91f3c9f3f0.zip
Replace catf with seprintf
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/buffer.c b/buffer.c
index 47d0955..b87816e 100644
--- a/buffer.c
+++ b/buffer.c
@@ -82,17 +82,18 @@ const struct Line *bufferHard(const struct Buffer *buffer, size_t i) {
 }
 
 enum { StyleCap = 10 };
-static void styleCat(struct Cat *cat, struct Style style) {
-	catf(
-		cat, "%s%s%s%s",
+static char *styleCopy(char *ptr, char *end, struct Style style) {
+	ptr = seprintf(
+		ptr, end, "%s%s%s%s",
 		(style.attr & Bold ? (const char []) { B, '\0' } : ""),
 		(style.attr & Reverse ? (const char []) { R, '\0' } : ""),
 		(style.attr & Italic ? (const char []) { I, '\0' } : ""),
 		(style.attr & Underline ? (const char []) { U, '\0' } : "")
 	);
 	if (style.fg != Default || style.bg != Default) {
-		catf(cat, "\3%02d,%02d", style.fg, style.bg);
+		ptr = seprintf(ptr, end, "\3%02d,%02d", style.fg, style.bg);
 	}
+	return ptr;
 }
 
 static const wchar_t ZWS = L'\u200B';
@@ -186,12 +187,11 @@ static int flow(struct Lines *hard, int cols, const struct Line *soft) {
 		line->str = malloc(cap);
 		if (!line->str) err(EX_OSERR, "malloc");
 
-		struct Cat cat = { line->str, cap, 0 };
-		catf(&cat, "%*s", (width = align), "");
-		styleCat(&cat, wrapStyle);
-		str = &line->str[cat.len];
+		char *end = &line->str[cap];
+		str = seprintf(line->str, end, "%*s", (width = align), "");
+		str = styleCopy(str, end, wrapStyle);
 		style = wrapStyle;
-		catf(&cat, "%s", &wrap[n]);
+		seprintf(str, end, "%s", &wrap[n]);
 
 		*wrap = '\0';
 		wrap = NULL;