Skip to content

Commit

Permalink
Merge pull request #1786 from McStasMcXtrace/COPY_warn_EXTEND
Browse files Browse the repository at this point in the history
Print warning when overwriting COPY EXTEND %{%} block from instance
  • Loading branch information
willend authored Dec 4, 2024
2 parents 90bcf92 + dea2966 commit 7d9766a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion mcstas/src/instrument.y
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,29 @@ component: removable cpuonly split "COMPONENT" instname '=' instref
}
}
}
if ($13->linenum) comp->extend= $13; /* EXTEND block*/
if ($13->linenum) {
if (comp->extend->linenum>0) {
fprintf(stderr, "\n-----------------------------------------------------------\n");
fprintf(stderr, "WARNING: Existing (COPY) EXTEND block in COMPONENT %s:\n", comp->name);
List_handle liter = list_iterate(comp->extend->lines);
List_handle liter2 = list_iterate($13->lines);
char *line, *line2;
fprintf(stderr, " EXTEND %%{\n");
while((line = list_next(liter))) {
fprintf(stderr, " %s",line);
}
list_iterate_end(liter);
fprintf(stderr, " %%}\n");
fprintf(stderr, "\nis overwritten by:\n");
fprintf(stderr, " EXTEND %%{\n");
while((line2 = list_next(liter2))) {
fprintf(stderr, " %s",line2);
}
list_iterate_end(liter2);
fprintf(stderr, " %%}\n-----------------------------------------------------------\n");
}
comp->extend= $13; /* EXTEND block*/
}
if (list_len($14)) comp->jump = $14;

/* one or more metadata statements -- the Component definition *can also* add to this list */
Expand Down

0 comments on commit 7d9766a

Please sign in to comment.