Skip to content

Commit 4e80569

Browse files
committed
Print warning when overwriting COPY EXTEND %{%} block from instance
1 parent 603b57f commit 4e80569

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

mcstas/src/instrument.y

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,29 @@ component: removable cpuonly split "COMPONENT" instname '=' instref
12671267
}
12681268
}
12691269
}
1270-
if ($13->linenum) comp->extend= $13; /* EXTEND block*/
1270+
if ($13->linenum) {
1271+
if (comp->extend->linenum>0) {
1272+
fprintf(stderr, "\n-----------------------------------------------------------\n");
1273+
fprintf(stderr, "WARNING (COMPONENT %s): Existing (COPY) EXTEND block:\n", comp->name);
1274+
List_handle liter = list_iterate(comp->extend->lines);
1275+
List_handle liter2 = list_iterate($13->lines);
1276+
char *line, *line2;
1277+
fprintf(stderr, "\n EXTEND %%{\n");
1278+
while((line = list_next(liter))) {
1279+
fprintf(stderr, " %s",line);
1280+
}
1281+
list_iterate_end(liter);
1282+
fprintf(stderr, "\n %%}\n");
1283+
fprintf(stderr, "\nwill be been overwritten by:\n");
1284+
fprintf(stderr, "\n EXTEND %%{\n");
1285+
while((line2 = list_next(liter2))) {
1286+
fprintf(stderr, " %s",line2);
1287+
}
1288+
list_iterate_end(liter2);
1289+
fprintf(stderr, "\n %%}\n-----------------------------------------------------------\n");
1290+
}
1291+
comp->extend= $13; /* EXTEND block*/
1292+
}
12711293
if (list_len($14)) comp->jump = $14;
12721294

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

0 commit comments

Comments
 (0)