summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--handle.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/handle.c b/handle.c
index b4601e4..cf0e853 100644
--- a/handle.c
+++ b/handle.c
@@ -406,34 +406,25 @@ static const char *colorMentions(size_t id, struct Message *msg) {
 	}
 
 	static char buf[1024];
-	size_t len = 0;
+	FILE *str = fmemopen(buf, sizeof(buf), "w");
+	if (!str) err(EX_OSERR, "fmemopen");
+
 	while (*mention) {
 		size_t skip = strspn(mention, ", ");
-		int n = snprintf(
-			&buf[len], sizeof(buf) - len,
-			"%.*s", (int)skip, mention
-		);
-		assert(n >= 0 && len + n < sizeof(buf));
-		len += n;
+		fwrite(mention, skip, 1, str);
 		mention += skip;
 
-		size_t word = strcspn(mention, ", ");
-		char punct = mention[word];
-		mention[word] = '\0';
-
-		n = snprintf(
-			&buf[len], sizeof(buf) - len,
-			"\3%02d%s\3", completeColor(id, mention), mention
-		);
-		assert(n > 0 && len + n < sizeof(buf));
-		len += n;
-
-		mention[word] = punct;
-		mention += word;
+		size_t len = strcspn(mention, ", ");
+		char punct = mention[len];
+		mention[len] = '\0';
+		fprintf(str, "\3%02d%s\3", completeColor(id, mention), mention);
+		mention[len] = punct;
+		mention += len;
 	}
-	assert(len + 1 < sizeof(buf));
-	buf[len++] = final;
-	buf[len] = '\0';
+	fputc(final, str);
+
+	fclose(str);
+	buf[sizeof(buf) - 1] = '\0';
 	return buf;
 }
 
itle='2006-12-16 01:14:01 +0100'>2006-12-16Add head comment to shared.cLars Hjemli 2006-12-16Add head comment to ui-commit.cLars Hjemli 2006-12-16gitweb ripoff: set tr:hover to highligt current rowLars Hjemli 2006-12-16Make repo header a link to summary pageLars Hjemli 2006-12-16Move cgit_print_date into ui-shared, reuse in ui-summaryLars Hjemli 2006-12-16Add ui-commit.c + misc ui cleanupsLars Hjemli 2006-12-15Add a common commit parserLars Hjemli 2006-12-14Add simple pager to log pageLars Hjemli 2006-12-13Add separate makefile-rule to clear current cacheLars Hjemli 2006-12-13Remove implementation details from READMELars Hjemli 2006-12-13Small layout adjustments to summary and blob viewLars Hjemli 2006-12-13Add display of tree content w/ui-tree.cLars Hjemli 2006-12-12cache_lock: do xstrdup/free on lockfileLars Hjemli 2006-12-11Don't truncate valid cachefilesLars Hjemli 2006-12-11Move global variables + callback functions into shared.cLars Hjemli 2006-12-11Move functions for generic object output into ui-view.cLars Hjemli 2006-12-11Move log-functions into ui-log.cLars Hjemli 2006-12-11Move repo summary functions into ui-summary.cLars Hjemli 2006-12-11Move functions for repolist output into ui-repolist.cLars Hjemli 2006-12-11Move common output-functions into ui-shared.cLars Hjemli 2006-12-11Rename config.c to parsing.c + move cgit_parse_query from cgit.c to parsing.cLars Hjemli 2006-12-11Avoid infinite loops in caching layerLars Hjemli 2006-12-11Let 'make install' clear all cachefilesLars Hjemli 2006-12-11Fix cache algorithm loopholeLars Hjemli 2006-12-10Add version identifier in generated filesLars Hjemli 2006-12-10Add license file and copyright noticesLars Hjemli 2006-12-10Add caching infrastructureLars Hjemli