extra state validation is needed

This commit is contained in:
rusefi 2021-07-09 01:11:20 -04:00
parent 1abf933213
commit 9fcca87332
6 changed files with 18 additions and 4 deletions

View File

@ -3520,7 +3520,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
commandButton = "TLE8888 test bench", cmd_set_engine_type_8888_test@@if_show_test_presets commandButton = "TLE8888 test bench", cmd_set_engine_type_8888_test@@if_show_test_presets
commandButton = "Reset firmware settings", cmd_set_engine_type_default commandButton = "Reset firmware settings", cmd_set_engine_type_default
; Board->ECU stimulator ; Board->ECU stimulator
dialog = ecuStimulator, "ECU stimulator" dialog = ecuStimulator, "ECU stimulator"
field = "Trigger Simulator", triggerSimulatorFrequency field = "Trigger Simulator", triggerSimulatorFrequency

Binary file not shown.

View File

@ -582,6 +582,10 @@ public class ConfigDefinition {
int v = Integer.parseInt(line); int v = Integer.parseInt(line);
registry.register(name, v); registry.register(name, v);
} else { } else {
if (line.contains(" ") && !VariableRegistry.isQuoted(line, '\"') && !VariableRegistry.isQuoted(line, '\'')) {
throw new IllegalStateException("Unexpected space in unquoted " + line);
}
registry.register(name, line); registry.register(name, line);
} }
} }

View File

@ -19,7 +19,7 @@ import static com.rusefi.ConfigField.BOOLEAN_T;
*/ */
public class ReaderState { public class ReaderState {
public static final String BIT = "bit"; public static final String BIT = "bit";
protected static final String DEFINE = "#define"; public static final String DEFINE = "#define";
private static final String CUSTOM = "custom"; private static final String CUSTOM = "custom";
private static final String END_STRUCT = "end_struct"; private static final String END_STRUCT = "end_struct";
private static final String STRUCT_NO_PREFIX = "struct_no_prefix "; private static final String STRUCT_NO_PREFIX = "struct_no_prefix ";

View File

@ -171,7 +171,7 @@ public class VariableRegistry {
} }
} }
private static boolean isQuoted(String value, char quote) { public static boolean isQuoted(String value, char quote) {
if (value == null) if (value == null)
return false; return false;
value = value.trim(); value = value.trim();

View File

@ -81,6 +81,17 @@ public class ConfigFieldParserTest {
new ReaderState().readBufferedReader(reader, Collections.emptyList()); new ReaderState().readBufferedReader(reader, Collections.emptyList());
} }
@Test(expected = IllegalStateException.class)
public void invalidDefine() throws IOException {
String test = "struct pid_s\n" +
ReaderState.DEFINE + " show show_Hellen121vag_presets true\n" +
"end_struct\n" +
"";
VariableRegistry.INSTANCE.clear();
BufferedReader reader = new BufferedReader(new StringReader(test));
new ReaderState().readBufferedReader(reader, Collections.emptyList());
}
@Test @Test
public void multiplicationInDefine() throws IOException { public void multiplicationInDefine() throws IOException {
String test = "struct pid_s\n" + String test = "struct pid_s\n" +