From afb399a1f08feb5ae6bd66c5593e746919aabf6d Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.com”> Date: Tue, 14 Jan 2025 11:14:20 +0000 Subject: [PATCH] Fix Bug #733 - "Pre-master-45 hangs forever on a circuit that works on older versions." That was an infinite loop when parsing a line with just "*#", introduced by commit fb63573b6b. Also add some comments. --- src/frontend/inp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 4712f221f..47ed8a8fe 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -738,7 +738,11 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) } /* end if (comfile) */ else { /* must be regular deck . . . . */ - /* loop through deck and handle control cards */ + /* Loop through deck and handle control cards. + * Pointer ld refers to the last card processed that has not + * been deleted. + */ + for (dd = deck->nextcard; dd; dd = ld->nextcard) { /* Ignore comment lines, but not lines begining with '*#', but remove them, if they are in a .control ... .endc section */ @@ -781,19 +785,17 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) /* Special control lines outside of .control section? */ - if (prefix("*#", s)) { + if (prefix("*#", s)) s = skip_ws(s + 2); - if (!*s) - continue; - } - - /* assemble all commands starting with pre_ after stripping - * pre_, to be executed before circuit parsing */ if (ciprefix("pre_", s)) { + /* Assemble all commands starting with pre_ after stripping + * pre_, to be executed before circuit parsing. + */ + s = s + 4; pre_controls = wl_cons(copy(s), pre_controls); - } else { + } else if (*s) { /* Assemble all other commands to be executed * after circuit parsing */ @@ -832,10 +834,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) ld->nextcard = dd->nextcard; line_free(dd, FALSE); } else { - ld = dd; + ld = dd; // Keep this card } } else { - ld = dd; + ld = dd; // ... and this. } } } /* end for (dd = deck->nextcard . . . . */