From cc3e2244796a54a394d534e19149bc53fe2b3b71 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 13 Jan 2014 22:18:32 +0100 Subject: Debugging improvements --- src/sc_interp.c | 5 +++++ src/sc_parse.c | 29 ++++++++++++++++------------- src/sc_parse.h | 1 + 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/sc_interp.c b/src/sc_interp.c index 0aae963..4b74fef 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -258,6 +258,11 @@ int sc_interp_add_blocks(SCInterpreter *scin, const SCBlock *bl) } /* else go away and sulk about it */ #endif + } else { + + fprintf(stderr, "Don't know what to do with this:\n"); + show_sc_block(bl, ""); + } bl = sc_block_next(bl); diff --git a/src/sc_parse.c b/src/sc_parse.c index 328e397..b94f548 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -135,22 +135,25 @@ void sc_block_free(SCBlock *bl) static void recursive_show_sc_blocks(const char *prefix, const SCBlock *bl) { while ( bl != NULL ) { + show_sc_block(bl, prefix); + bl = bl->next; + } +} - printf("%s", prefix); - if ( bl->name != NULL ) printf("\\%s ", bl->name); - if ( bl->options != NULL ) printf("[%s] ", bl->options); - if ( bl->contents != NULL ) printf("{%s}", bl->contents); - printf("\n"); - - if ( bl->child != NULL ) { - char new_prefix[strlen(prefix)+3]; - strcpy(new_prefix, " "); - strcat(new_prefix, prefix); - recursive_show_sc_blocks(new_prefix, bl->child); - } - bl = bl->next; +void show_sc_block(const SCBlock *bl, const char *prefix) +{ + printf("%s", prefix); + if ( bl->name != NULL ) printf("\\%s ", bl->name); + if ( bl->options != NULL ) printf("[%s] ", bl->options); + if ( bl->contents != NULL ) printf("{%s}", bl->contents); + printf("\n"); + if ( bl->child != NULL ) { + char new_prefix[strlen(prefix)+3]; + strcpy(new_prefix, " "); + strcat(new_prefix, prefix); + recursive_show_sc_blocks(new_prefix, bl->child); } } diff --git a/src/sc_parse.h b/src/sc_parse.h index 7640970..fd3e221 100644 --- a/src/sc_parse.h +++ b/src/sc_parse.h @@ -40,5 +40,6 @@ extern const char *sc_block_options(const SCBlock *bl); extern const char *sc_block_contents(const SCBlock *bl); extern void show_sc_blocks(const SCBlock *bl); +extern void show_sc_block(const SCBlock *bl, const char *prefix); #endif /* SC_PARSE_H */ -- cgit v1.2.3