diff options
author | 2012-06-04 14:20:01 -0700 | |
---|---|---|
committer | 2012-06-04 14:20:01 -0700 | |
commit | 69446be1ee063771f2e0b498a50f9b0787ea70c7 (patch) | |
tree | be5ecf3a473052475218df605d350a204666c750 /parser.cpp | |
parent | cc90f9cf803bc4aba928b2a80be451d9b717c5f0 (diff) |
Signal handling cleanup and improved safety
Fixes issue where you couldn't control-C out of a loop (https://github.com/ridiculousfish/fishfish/issues/13)
Also stops doing memory allocation in the signal handler (oops) https://github.com/ridiculousfish/fishfish/issues/27
Diffstat (limited to 'parser.cpp')
-rw-r--r-- | parser.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -371,14 +371,35 @@ parser_t::parser_t(enum parser_type_t type, bool errors) : } +/* A pointer to the principal parser (which is a static local) */ +static parser_t *s_principal_parser = NULL; + parser_t &parser_t::principal_parser(void) { ASSERT_IS_NOT_FORKED_CHILD(); ASSERT_IS_MAIN_THREAD(); static parser_t parser(PARSER_TYPE_GENERAL, true); + if (! s_principal_parser) + { + s_principal_parser = &parser; + } return parser; } +void parser_t::skip_all_blocks(void) +{ + /* Tell all blocks to skip */ + if (s_principal_parser) + { + block_t *c = s_principal_parser->current_block; + while( c ) + { + c->skip = true; + c = c->outer; + } + } +} + /** Return the current number of block nestings */ |