Fix processing of lines like: "*# pre_some_command ...".

This commit is contained in:
Giles Atkinson 2024-10-13 15:25:01 +01:00 committed by Holger Vogt
parent e819fc40d7
commit a5a393c8b8
1 changed files with 23 additions and 13 deletions

View File

@ -742,6 +742,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
for (dd = deck->nextcard; dd; dd = ld->nextcard) { for (dd = deck->nextcard; dd; dd = ld->nextcard) {
/* Ignore comment lines, but not lines begining with '*#', /* Ignore comment lines, but not lines begining with '*#',
but remove them, if they are in a .control ... .endc section */ but remove them, if they are in a .control ... .endc section */
s = skip_ws(dd->line); s = skip_ws(dd->line);
if ((*s == '*') && ((s != dd->line) || (s[1] != '#'))) { if ((*s == '*') && ((s != dd->line) || (s[1] != '#'))) {
if (commands) { if (commands) {
@ -776,22 +777,31 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
else else
fprintf(cp_err, "Warning: misplaced .endc card\n"); fprintf(cp_err, "Warning: misplaced .endc card\n");
} else if (commands || prefix("*#", dd->line)) { } else if (commands || prefix("*#", dd->line)) {
s = dd->line;
/* Special control lines outside of .control section? */
if (prefix("*#", s)) {
s = skip_ws(s + 2);
if (!*s)
continue;
}
/* assemble all commands starting with pre_ after stripping /* assemble all commands starting with pre_ after stripping
* pre_, to be executed before circuit parsing */ * pre_, to be executed before circuit parsing */
if (ciprefix("pre_", dd->line)) {
s = copy(dd->line + 4); if (ciprefix("pre_", s)) {
pre_controls = wl_cons(s, pre_controls); s = s + 4;
} pre_controls = wl_cons(copy(s), pre_controls);
/* assemble all other commands to be executed after circuit } else {
* parsing */ /* Assemble all other commands to be executed
else { * after circuit parsing */
/* special control lines outside of .control section*/
if (prefix("*#", dd->line)) { if (s == dd->line) {
s = copy(dd->line + 2); dd->line = NULL; /* Going to wl->wl_word. */
/* all commands from within .control section */
} else { } else {
s = dd->line; s = copy(s);
dd->line = NULL; /* SJB - prevent line_free() freeing the string (now pointed at by wl->wl_word) */ *dd->line = '*';
} }
controls = wl_cons(s, controls); controls = wl_cons(s, controls);
} }