diff options
| author | Jules Aguillon | 2025-12-13 15:58:34 +0100 |
|---|---|---|
| committer | GitHub | 2025-12-13 15:58:34 +0100 |
| commit | 08ebf8fabc860fb66d586aade838483dda86b5b0 (patch) | |
| tree | 1b13c55dded53ca8f2515ff58779f442d876bf54 /srcs/juloo.keyboard2/KeyValueParser.java | |
| parent | 0ad03c6dea515f577c195304a24fac65bae5d272 (diff) | |
| download | unexpected-keyboard-08ebf8fabc860fb66d586aade838483dda86b5b0.tar.gz unexpected-keyboard-08ebf8fabc860fb66d586aade838483dda86b5b0.zip | |
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`.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyValueParser.java')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyValueParser.java | 7 |
1 files changed, 4 insertions, 3 deletions
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(); } |
