Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
0651051d
Commit
0651051d
authored
May 15, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow quit/exit to work within mirb; fix #2253 close #2254
also allow spaces around quit/exit.
parent
6f6f50d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+25
-1
No files found.
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
View file @
0651051d
...
...
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#ifdef ENABLE_READLINE
#include <readline/readline.h>
...
...
@@ -250,6 +251,29 @@ print_cmdline(int code_block_open)
void
mrb_codedump_all
(
mrb_state
*
,
struct
RProc
*
);
static
int
check_keyword
(
const
char
*
buf
,
const
char
*
word
)
{
const
char
*
p
=
buf
;
size_t
len
=
strlen
(
word
);
/* skip preceding spaces */
while
(
*
p
&&
isspace
(
*
p
))
{
p
++
;
}
/* check keyword */
if
(
strncmp
(
p
,
word
,
len
)
!=
0
)
{
return
0
;
}
p
+=
len
;
/* skip trailing spaces */
while
(
*
p
)
{
if
(
!
isspace
(
*
p
))
return
0
;
p
++
;
}
return
1
;
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -356,7 +380,7 @@ main(int argc, char **argv)
strcat
(
ruby_code
,
last_code_line
);
}
else
{
if
(
(
strcmp
(
last_code_line
,
"quit"
)
==
0
)
||
(
strcmp
(
last_code_line
,
"exit"
)
==
0
))
{
if
(
check_keyword
(
last_code_line
,
"quit"
)
||
check_keyword
(
last_code_line
,
"exit"
))
{
break
;
}
strcpy
(
ruby_code
,
last_code_line
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment