From 7e1bf77fd5d8d0ac9d6624447dfbebb79d9320bb Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 17 Aug 2015 21:45:04 +0200 Subject: Increase priority of macros --- src/sc_interp.c | 14 ++++++++------ 1 file 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; in_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); -- cgit v1.2.3