From bd34cbd350dc1ca0a539b71fd18ed3d8b98152c8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 26 Jun 2012 05:17:11 -0700 Subject: [PATCH] lua 5.1 and lua 5.2 side-by-side --- src/util/console.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/console.c b/src/util/console.c index 0ce3704a8..b850678c5 100644 --- a/src/util/console.c +++ b/src/util/console.c @@ -23,13 +23,17 @@ #define LUA_MAXINPUT 512 #endif +#if LUA_VERSION_NUM >= 502 +#define lua_strlen(L, idx) lua_rawlen(L, idx) +#endif + #if defined(LUA_USE_READLINE) #include #include #include #define default_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) #define lua_saveline(L,idx) \ - if (lua_rawlen(L,idx) > 0) /* non-empty line? */ \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ add_history(lua_tostring(L, idx)); /* add it to history */ #define lua_freeline(L,b) ((void)L, free(b)) #else @@ -194,7 +198,7 @@ static int loadline(lua_State * L) if (!pushline(L, 1)) return -1; /* no input */ for (;;) { /* repeat until gets a complete line */ - status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_rawlen(L, 1), "=stdin"); + status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin"); if (!incomplete(L, status)) break; /* cannot try to add lines? */ if (!pushline(L, 0)) /* no more input? */