summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-11-29 16:57:55 -0500
committerJune McEnroe <june@causal.agency>2020-11-29 16:57:55 -0500
commit08c8ff154fbcfa24ed89df7dfdedd5f4e0deab77 (patch)
tree7b6c505c304f02e73bf46daac92acc929fdc5db2
parentRearrange archive.h (diff)
downloadbubger-08c8ff154fbcfa24ed89df7dfdedd5f4e0deab77.tar.gz
bubger-08c8ff154fbcfa24ed89df7dfdedd5f4e0deab77.zip
Factor out uint32_t stringify
-rw-r--r--archive.h9
-rw-r--r--concat.c4
-rw-r--r--export.c4
3 files changed, 11 insertions, 6 deletions
diff --git a/archive.h b/archive.h
index 3605a4b..0b8b6d8 100644
--- a/archive.h
+++ b/archive.h
@@ -25,6 +25,7 @@
  * covered work.
  */
 
+#include <inttypes.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -54,6 +55,14 @@ extern const char *baseTitle;
 extern const char *baseMailto;
 extern const char *baseSubscribe;
 
+static inline struct U32 {
+	char s[sizeof("4294967295")];
+} u32(uint32_t u) {
+	struct U32 buf;
+	snprintf(buf.s, sizeof(buf.s), "%" PRIu32, u);
+	return buf;
+}
+
 static inline struct ISO8601 {
 	char s[sizeof("0000-00-00T00:00:00Z")];
 } iso8601(time_t time) {
diff --git a/concat.c b/concat.c
index c59a828..bd41913 100644
--- a/concat.c
+++ b/concat.c
@@ -82,10 +82,8 @@ void concatData(
 }
 
 static char *uidPath(uint32_t uid, const char *type) {
-	char str[32];
-	snprintf(str, sizeof(str), "%" PRIu32, uid);
 	struct Variable vars[] = {
-		{ "uid", str },
+		{ "uid", u32(uid).s },
 		{ "type", type },
 		{0},
 	};
diff --git a/export.c b/export.c
index 2b579c3..d4039e2 100644
--- a/export.c
+++ b/export.c
@@ -40,10 +40,8 @@
 #include "imap.h"
 
 static char *exportPath(uint32_t uid, const char *type) {
-	char str[32];
-	snprintf(str, sizeof(str), "%" PRIu32, uid);
 	struct Variable vars[] = {
-		{ "uid", str },
+		{ "uid", u32(uid).s },
 		{ "type", type },
 		{0},
 	};
le='2018-09-24 18:11:21 -0400'>2018-09-24Add psfed, a PSF2 font editorJune McEnroe 2018-09-21Add scheme -i to swap white and blackJune McEnroe 2018-09-21Map caps lock to escape on Linux consoleJune McEnroe 2018-09-19Fix README mandoc lintsJune McEnroe 2018-09-19Un-NOT trans.alpha values in pngoJune McEnroe 2018-09-18Refactor reads in pngo and clear palette between filesJune McEnroe 2018-09-17Add tRNS support to pngoJune McEnroe 2018-09-11Move gfx man pages to gfx/manJune McEnroe 2018-09-11Move bin man pages to bin/manJune McEnroe 2018-09-11Rewrite gfx.7 and render plaintext READMEJune McEnroe 2018-09-11Remove GAMES from BINSJune McEnroe 2018-09-11Rewrite bin.7 and render to plaintext READMEJune McEnroe 2018-09-11Add "blank" lines to man pagesJune McEnroe 2018-09-10Add mdoc syntax fileJune McEnroe 2018-09-08Fix Nm usage in multi-name man pagesJune McEnroe 2018-09-08Put real dates on man pagesJune McEnroe 2018-09-08Replace gfx README with REAMDE.7June McEnroe 2018-09-08Link gfx man pages in ~/.localJune McEnroe