aboutsummaryrefslogtreecommitdiff
path: root/libi3/format_placeholders.c
diff options
context:
space:
mode:
Diffstat (limited to 'libi3/format_placeholders.c')
-rw-r--r--libi3/format_placeholders.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libi3/format_placeholders.c b/libi3/format_placeholders.c
index 71870a7b..adcb6555 100644
--- a/libi3/format_placeholders.c
+++ b/libi3/format_placeholders.c
@@ -19,16 +19,18 @@
*
*/
char *format_placeholders(char *format, placeholder_t *placeholders, int num) {
- if (format == NULL)
+ if (format == NULL) {
return NULL;
+ }
/* We have to first iterate over the string to see how much buffer space
* we need to allocate. */
int buffer_len = strlen(format) + 1;
for (char *walk = format; *walk != '\0'; walk++) {
for (int i = 0; i < num; i++) {
- if (!CS_STARTS_WITH(walk, placeholders[i].name))
+ if (!CS_STARTS_WITH(walk, placeholders[i].name)) {
continue;
+ }
buffer_len = buffer_len - strlen(placeholders[i].name) + strlen(placeholders[i].value);
walk += strlen(placeholders[i].name) - 1;
@@ -57,8 +59,9 @@ char *format_placeholders(char *format, placeholder_t *placeholders, int num) {
break;
}
- if (!matched)
+ if (!matched) {
*(outwalk++) = *walk;
+ }
}
*outwalk = '\0';