summaryrefslogtreecommitdiff
path: root/core/src/xmake/readline/readline.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/xmake/readline/readline.c')
-rw-r--r--core/src/xmake/readline/readline.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/core/src/xmake/readline/readline.c b/core/src/xmake/readline/readline.c
index 1e1fdc240..fa3e631cc 100644
--- a/core/src/xmake/readline/readline.c
+++ b/core/src/xmake/readline/readline.c
@@ -22,8 +22,8 @@
/* //////////////////////////////////////////////////////////////////////////////////////
* trace
*/
-#define TB_TRACE_MODULE_NAME "readline"
-#define TB_TRACE_MODULE_DEBUG (0)
+#define TB_TRACE_MODULE_NAME "readline"
+#define TB_TRACE_MODULE_DEBUG (0)
/* //////////////////////////////////////////////////////////////////////////////////////
* includes
@@ -37,27 +37,24 @@
*/
// readline wrapper
-tb_int_t xm_readline_readline(lua_State* lua)
-{
- // check
+tb_int_t xm_readline_readline(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get the prompt
- tb_char_t const* prompt = luaL_optstring(lua, 1, tb_null);
+ tb_char_t const *prompt = luaL_optstring(lua, 1, tb_null);
// call readline
- tb_char_t* line = readline(prompt);
- if (line)
- {
+ tb_char_t *line = readline(prompt);
+ if (line) {
// return line
lua_pushstring(lua, line);
// free it
tb_free(line);
+ } else {
+ lua_pushnil(lua);
}
- else lua_pushnil(lua);
- // ok
return 1;
}