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
4306fe79
Commit
4306fe79
authored
Jul 18, 2013
by
kyab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save mirb history when readline enabled
parent
958d5b76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
+22
-0
No files found.
mrbgems/mruby-bin-mirb/tools/mirb/mirb.c
View file @
4306fe79
...
...
@@ -15,11 +15,19 @@
#include <mruby/data.h>
#include <mruby/compile.h>
#ifdef ENABLE_READLINE
#include <limits.h>
#include <readline/readline.h>
#include <readline/history.h>
#endif
#include <mruby/string.h>
#ifdef ENABLE_READLINE
static
const
char
*
history_file_name
=
".mirb_history"
;
char
history_path
[
PATH_MAX
];
#endif
static
void
p
(
mrb_state
*
mrb
,
mrb_value
obj
,
int
prompt
)
{
...
...
@@ -268,6 +276,16 @@ main(int argc, char **argv)
if
(
args
.
verbose
)
cxt
->
dump_result
=
1
;
ai
=
mrb_gc_arena_save
(
mrb
);
#ifdef ENABLE_READLINE
using_history
();
strcpy
(
history_path
,
getenv
(
"HOME"
));
strcat
(
history_path
,
"/"
);
strcat
(
history_path
,
history_file_name
);
read_history
(
history_path
);
#endif
while
(
TRUE
)
{
#ifndef ENABLE_READLINE
print_cmdline
(
code_block_open
);
...
...
@@ -361,5 +379,9 @@ main(int argc, char **argv)
mrbc_context_free
(
mrb
,
cxt
);
mrb_close
(
mrb
);
#ifdef ENABLE_READLINE
write_history
(
history_path
);
#endif
return
0
;
}
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