diff options
| -rw-r--r-- | src/format.c | 8 | ||||
| -rw-r--r-- | src/format.h | 2 |
2 files changed, 9 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; } diff --git a/src/format.h b/src/format.h index 69d9fa8..93391ec 100644 --- a/src/format.h +++ b/src/format.h @@ -13,6 +13,8 @@ typedef struct { typedef struct { const char *key; uint8_t mark; + bool prefix; + bool postfix; } format_pair_t; bool format_init(format_t *format, const char *string, char delim); |
