Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit57d648e05d9d091a7d8d6f6dbfda2561c47b3a7c (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-07-17 20:08:36 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-07-17 20:08:36 +0300
Filesc99163c78596ef8561b1d7889dc9c5fe0b7912b8
goodwolf-57d648e05d9d091a7d8d6f6dbfda2561c47b3a7c.tar
goodwolf-57d648e05d9d091a7d8d6f6dbfda2561c47b3a7c.tar.gz
goodwolf-57d648e05d9d091a7d8d6f6dbfda2561c47b3a7c.zip
Parent6f5101265679f0753168da9487520b6479fa6fd1 (diff)
fmt: Brought back separator as an option
2 files changed, 8 insertions, 3 deletions
-rw-r--r--fmt.c9
-rw-r--r--fmt.h2
diff --git a/fmt.c b/fmt.c
index f22fcce..0c47e00 100644
--- a/fmt.c
+++ b/fmt.c
@@ -7,11 +7,11 @@
/* flawfinder: ignore. `alpha_digits` is never modified */
static const char alpha_digits[26] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void
-fmt_context_id(uint64_t num, char *out)
+fmt_context_id(uint64_t num, char *out, int withSeparator)
{
/* flawfinder: ignore. bound checks are done */
char buf[BADWOLF_CTX_SIZ] = {0, 0, 0, 0, 0, 0, 0};
- int len = 0;
+ int len = 2;
buf[++len] = alpha_digits[num % 26];
num /= 26;
@@ -25,4 +25,9 @@ fmt_context_id(uint64_t num, char *out)
{
out[i] = buf[len - i];
}
+
+ if (withSeparator) {
+ out[len - 2] = ':';
+ out[len - 1] = ' ';
+ }
}
diff --git a/fmt.h b/fmt.h
index 1ac4a2b..06a13df 100644
--- a/fmt.h
+++ b/fmt.h
@@ -1,4 +1,4 @@
#include <stdint.h> // uint64_t
#define BADWOLF_CTX_SIZ 7
-void fmt_context_id(uint64_t num, char *out);
+void fmt_context_id(uint64_t num, char *out, int withSeparator);