From 618f25bfe2932b0296407a5c1d381273852214b5 Mon Sep 17 00:00:00 2001 From: Joseph McCullough Date: Fri, 17 Aug 2012 18:19:06 -0500 Subject: 'exit' and 'quit' cause exit regardless of open block --- tools/mirb/mirb.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'tools') diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c index 54588d57e..073054b46 100644 --- a/tools/mirb/mirb.c +++ b/tools/mirb/mirb.c @@ -181,19 +181,9 @@ main(void) last_code_line[char_index] = '\0'; - if ((strcmp(last_code_line, "quit") == 0) || - (strcmp(last_code_line, "exit") == 0)) { - if (code_block_open) { - /* cancel the current block and reset */ - code_block_open = FALSE; - memset(ruby_code, 0, sizeof(*ruby_code)); - memset(last_code_line, 0, sizeof(*last_code_line)); - continue; - } - else { - /* quit the program */ - break; - } + if ((strcmp(last_code_line, "quit") == 0) || (strcmp(last_code_line, "exit") == 0)) { + /*:quit the program */ + break; } else { if (code_block_open) { -- cgit v1.2.3 From e7b61c65bba6f33d4cc543bc12fa06c9176f41b7 Mon Sep 17 00:00:00 2001 From: Joseph McCullough Date: Fri, 17 Aug 2012 19:51:38 -0500 Subject: Don't exit if 'exit' or 'quit' are in quote blocks --- tools/mirb/mirb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c index 073054b46..c9198917e 100644 --- a/tools/mirb/mirb.c +++ b/tools/mirb/mirb.c @@ -182,12 +182,19 @@ main(void) last_code_line[char_index] = '\0'; if ((strcmp(last_code_line, "quit") == 0) || (strcmp(last_code_line, "exit") == 0)) { - /*:quit the program */ - break; + if (!code_block_open || !parser->sterm){ + break; + } + else{ + /* count the quit/exit commands as strings if in a quote block */ + strcat(ruby_code, "\n"); + strcat(ruby_code, last_code_line); + } } + else { if (code_block_open) { - strcat(ruby_code, "\n"); + strcat(ruby_code, "\n"); strcat(ruby_code, last_code_line); } else { -- cgit v1.2.3