summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2012-08-17 21:40:24 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2012-08-17 21:40:24 -0700
commitaf5b3279ace5f811c8813a346450fe3780278bca (patch)
tree76291f74c7563e7b4d3f8358fa99786f2264460d /tools
parentbd3d5268db0f13af2ac35f6dbaf256f918bbae1a (diff)
parente7b61c65bba6f33d4cc543bc12fa06c9176f41b7 (diff)
downloadmruby-af5b3279ace5f811c8813a346450fe3780278bca.tar.gz
mruby-af5b3279ace5f811c8813a346450fe3780278bca.zip
Merge pull request #434 from joequery/exit_in_string
Improve handling of "exit" and "quit" in mirb.
Diffstat (limited to 'tools')
-rw-r--r--tools/mirb/mirb.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c
index 54588d57e..c9198917e 100644
--- a/tools/mirb/mirb.c
+++ b/tools/mirb/mirb.c
@@ -181,23 +181,20 @@ 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 */
+ if ((strcmp(last_code_line, "quit") == 0) || (strcmp(last_code_line, "exit") == 0)) {
+ 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 {