From a42569382c4a8043a0f6bf0b1ec4f56976009470 Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 24 Jul 2021 12:53:57 -0400 Subject: [PATCH] https://github.com/rusefi/rusefi/issues/3053 --- .../src/com/rusefi/VariableRegistry.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java_tools/configuration_definition/src/com/rusefi/VariableRegistry.java b/java_tools/configuration_definition/src/com/rusefi/VariableRegistry.java index c69854cde2..9949a31d31 100644 --- a/java_tools/configuration_definition/src/com/rusefi/VariableRegistry.java +++ b/java_tools/configuration_definition/src/com/rusefi/VariableRegistry.java @@ -24,6 +24,8 @@ public class VariableRegistry { private final TreeMap data = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); public static final VariableRegistry INSTANCE = new VariableRegistry(); + // todo: smarter regex! See TsWriter.VAR which is a bit better but still not perfect + // todo: https://github.com/rusefi/rusefi/issues/3053 ? private final Pattern VAR = Pattern.compile("(@@(.*?)@@)"); public Map intValues = new HashMap<>(); @@ -86,9 +88,11 @@ public class VariableRegistry { return null; Matcher m; while ((m = VAR.matcher(line)).find()) { + if (m.groupCount() < 2) + throw new IllegalStateException("Something broken in: [" + line + "]"); String key = m.group(2); if (!data.containsKey(key)) - throw new IllegalStateException("No such variable: " + key); + throw new IllegalStateException("No such variable: [" + key + "]"); String s = data.get(key); line = m.replaceFirst(s); }