From 63a55dd06cb98e8b00a232ad8ae7b4ac133c4d6e Mon Sep 17 00:00:00 2001 From: Chad Voegele Date: Tue, 14 Jul 2015 10:47:49 -0700 Subject: [PATCH 1/2] Keep percent signs if not followed by {} block. The before code would skip a percent sign even if it was not followed by a {} block. The after code checks the same condition but only advances p if a {} block is found and otherwise passes it through as text. --- lemonbar.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lemonbar.c b/lemonbar.c index 794d815..ec00e6d 100644 --- a/lemonbar.c +++ b/lemonbar.c @@ -485,7 +485,8 @@ parse (char *text) if (*p == '\0' || *p == '\n') return; - if (*p == '%' && p++ && *p == '{' && (block_end = strchr(p++, '}'))) { + if (*p == '%' && *(p+1) == '{' && (block_end = strchr(p++, '}'))) { + p++; while (p < block_end) { while (isspace(*p)) p++; From 71ed0d3375a4ed317b427478d0a96db9db71d2a9 Mon Sep 17 00:00:00 2001 From: chad Date: Sun, 27 Sep 2015 15:21:49 -0500 Subject: [PATCH 2/2] Rewrite *p, *(p+1) as p[0], p[1] for readability. --- lemonbar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lemonbar.c b/lemonbar.c index ec00e6d..065ecd6 100644 --- a/lemonbar.c +++ b/lemonbar.c @@ -485,7 +485,7 @@ parse (char *text) if (*p == '\0' || *p == '\n') return; - if (*p == '%' && *(p+1) == '{' && (block_end = strchr(p++, '}'))) { + if (p[0] == '%' && p[1] == '{' && (block_end = strchr(p++, '}'))) { p++; while (p < block_end) { while (isspace(*p))