From 71e65b75b06842e23713805088356761689a37e4 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 21 Jul 2020 00:05:06 +0200 Subject: [PATCH] =?UTF-8?q?Syntax=20check:=20If=20the=20first=20character?= =?UTF-8?q?=20in=20a=20netlist=20or=20.control=20line=20is=20one=20of=20?= =?UTF-8?q?=3D[]=3F()&%$=C2=A7\"!:,=20then=20ngspice=20replaces=20it=20by?= =?UTF-8?q?=20'*'=20and=20issues=20a=20warning.=20'set=20strict=5Ferrorhan?= =?UTF-8?q?dling'=20will=20force=20ngspice=20existing.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/inpcom.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 2b057bda7..b8c855509 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -8261,7 +8261,7 @@ static void ltspice_compat_a(struct card *oldcard) static void inp_check_syntax(struct card *deck) { struct card *card; - int check_control = 0, check_subs = 0, check_if = 0; + int check_control = 0, check_subs = 0, check_if = 0, check_ch = 0; /* will lead to crash in inp.c, fcn inp_spsource */ if (ciprefix(".param", deck->line) || ciprefix(".meas", deck->line)) { @@ -8273,6 +8273,21 @@ static void inp_check_syntax(struct card *deck) char *cut_line = card->line; if (*cut_line == '*' || *cut_line == '\0') continue; + // check for unusable leading characters and change them to '*' + if (strchr("=[]?()&%$§\"!:,", *cut_line)) { + if (ft_stricterror) { + fprintf(stderr, "Error: '%c' is not allowed as first character in line %s.\n", *cut_line, cut_line); + controlled_exit(EXIT_BAD); + } + else { + if (!check_ch) { + fprintf(stderr, "Warning: Unusal leading characters like '%c' or others out of '= [] ? () & %$§\"!:,'\n", *cut_line); + fprintf(stderr, " in netlist or included files, will be replaced with '*'\n"); + check_ch = 1; /* just one warning */ + } + *cut_line = '*'; + } + } // check for .control ... .endc if (ciprefix(".control", cut_line)) { if (check_control > 0) {