From 08ebf8fabc860fb66d586aade838483dda86b5b0 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 13 Dec 2025 15:58:34 +0100 Subject: Fix parsing of escaped characters in macros (#1126) * refactor: Better printing for KeyValue in tests * Fix parsing of escaped characters in macros The parsing code was bugged with custom macros like `symbol:\abc` and `symbol:\\abc`.--- srcs/juloo.keyboard2/KeyValueParser.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'srcs/juloo.keyboard2/KeyValueParser.java') diff --git a/srcs/juloo.keyboard2/KeyValueParser.java b/srcs/juloo.keyboard2/KeyValueParser.java index 08558ad..a8c1fe7 100644 --- a/srcs/juloo.keyboard2/KeyValueParser.java +++ b/srcs/juloo.keyboard2/KeyValueParser.java @@ -60,7 +60,7 @@ public final class KeyValueParser if (KEYDEF_TOKEN != null) return; KEYDEF_TOKEN = Pattern.compile("'|,|keyevent:|(?:[^\\\\',]+|\\\\.)+"); - QUOTED_PAT = Pattern.compile("((?:[^'\\\\]+|\\\\')*)'"); + QUOTED_PAT = Pattern.compile("((?:[^'\\\\]+|\\\\.)*)'"); WORD_PAT = Pattern.compile("[a-zA-Z0-9_]+|."); } @@ -119,16 +119,17 @@ public final class KeyValueParser { if (!s.contains("\\")) return s; - StringBuilder out = new StringBuilder(s.length()); final int len = s.length(); + StringBuilder out = new StringBuilder(len); int prev = 0, i = 0; for (; i < len; i++) if (s.charAt(i) == '\\') { out.append(s, prev, i); prev = i + 1; + i++; } - out.append(s, prev, i); + out.append(s, prev, len); return out.toString(); } -- cgit v1.2.3