aboutsummaryrefslogtreecommitdiff
path: root/src/sc_interp.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2015-08-17 21:45:04 +0200
committerThomas White <taw@bitwiz.org.uk>2015-08-17 21:45:04 +0200
commit7e1bf77fd5d8d0ac9d6624447dfbebb79d9320bb (patch)
tree5df08b7e0efb8bcbb20319a6ebcb2e566f6f765e /src/sc_interp.c
parent8d8eccb93da07559c675f053d5dce3781423b253 (diff)
Increase priority of macros
Diffstat (limited to 'src/sc_interp.c')
-rw-r--r--src/sc_interp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 7edae0c..10fb7ba 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -843,6 +843,8 @@ static int check_macro(const char *name, SCInterpreter *scin)
int i;
struct sc_state *st = &scin->state[scin->j];
+ if ( name == NULL ) return 0;
+
for ( i=0; i<st->n_macros; i++ ) {
if ( strcmp(st->macros[i].name, name) == 0 ) {
return 1;
@@ -895,7 +897,12 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl)
const char *options = sc_block_options(bl);
SCBlock *child = sc_block_child(bl);
- if ((sc_interp_get_frame(scin) != NULL)
+ if ( check_macro(name, scin) ) {
+ sc_interp_save(scin);
+ exec_macro(bl, scin, child);
+ sc_interp_restore(scin);
+
+ } else if ((sc_interp_get_frame(scin) != NULL)
&& check_outputs(bl, scin) ) {
/* Block handled as output thing */
@@ -922,11 +929,6 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl)
set_colour(scin, options);
maybe_recurse_after(scin, child);
- } else if ( check_macro(name, scin) ) {
- sc_interp_save(scin);
- exec_macro(bl, scin, child);
- sc_interp_restore(scin);
-
} else if ( strcmp(name, "contents") == 0 ) {
run_macro_contents(scin);