aboutsummaryrefslogtreecommitdiff
path: root/src/format.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-11-18 19:49:51 +0100
committerFederico Angelilli <code@fedang.net>2024-11-18 19:49:51 +0100
commitad0577c0a50013b5cb8105380cba1be06f50df50 (patch)
treef360a2cb7214154fac0fd673afc4787eabf87c6e /src/format.c
parent9df5b01201498081e20bf85a3b80d85f88a0161f (diff)
Add postfix/prefix pairs
Diffstat (limited to 'src/format.c')
-rw-r--r--src/format.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/format.c b/src/format.c
index 2678536..47426ec 100644
--- a/src/format.c
+++ b/src/format.c
@@ -93,8 +93,14 @@ bool format_remark(format_t *format, const char *label, const format_pair_t *pai
// Skip regular strings
if (!format->marks[i]) continue;
+ size_t l = strlen(format->parts[i]);
for (size_t j = 0; pairs[j].key != NULL; j++) {
- if (!strcmp(pairs[j].key, format->parts[i])) {
+ size_t kl = strlen(pairs[j].key);
+
+ if ((pairs[j].prefix && !strncmp(pairs[j].key, format->parts[i], kl)) ||
+ (pairs[j].postfix && l > kl && !strncmp(pairs[j].key, format->parts[i] + (l - kl), kl)) ||
+ !strcmp(pairs[j].key, format->parts[i]))
+ {
format->marks[i] = pairs[j].mark;
goto next;
}