aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/args.lua6
-rw-r--r--core/events.lua6
-rw-r--r--core/keys.lua5
-rw-r--r--modules/lua/init.lua2
-rw-r--r--modules/textadept/bookmarks.lua2
-rw-r--r--modules/textadept/command_entry.lua7
-rw-r--r--modules/textadept/find.lua10
-rw-r--r--modules/textadept/keys.lua2
-rw-r--r--modules/textadept/menu.lua2
-rw-r--r--modules/textadept/snippets.lua5
-rw-r--r--src/Makefile21
-rw-r--r--src/lua.sym45
-rw-r--r--src/textadept.c62
13 files changed, 100 insertions, 75 deletions
diff --git a/core/args.lua b/core/args.lua
index ea1c9093..6a65bde5 100644
--- a/core/args.lua
+++ b/core/args.lua
@@ -41,10 +41,10 @@ function process()
while i <= #arg do
local switch = switches[arg[i]]
if switch then
- local f, n = unpack(switch)
+ local f, n = table.unpack(switch)
local args = {}
for j = i + 1, i + n do args[#args + 1] = arg[j] end
- f(unpack(args))
+ f(table.unpack(args))
i = i + n
else
io.open_file(arg[i])
@@ -59,7 +59,7 @@ end
local function show_help()
print('Usage: textadept [args] [filenames]')
local line = " %s [%d args]: %s"
- for k, v in pairs(switches) do print(line:format(k, unpack(v, 2))) end
+ for k, v in pairs(switches) do print(line:format(k, table.unpack(v, 2))) end
os.exit()
end
register('-h', '--help', 0, show_help, 'Displays this')
diff --git a/core/events.lua b/core/events.lua
index 2145bee4..d6a7b270 100644
--- a/core/events.lua
+++ b/core/events.lua
@@ -226,9 +226,9 @@ function emit(event, ...)
if not event then error(L('Undefined event name')) end
local h = handlers[event]
if not h then return end
- local pcall, unpack, type = pcall, unpack, type
+ local pcall, table_unpack, type = pcall, table.unpack, type
for i = 1, #h do
- local ok, result = pcall(h[i], unpack{...})
+ local ok, result = pcall(h[i], table_unpack{...})
if not ok then
if not error_emitted then
error_emitted = true
@@ -276,7 +276,7 @@ connect('SCN', function(n)
if not f then return end
local args = {}
for i = 2, #f do args[i - 1] = n[f[i]] end
- return emit(f[1], unpack(args))
+ return emit(f[1], table.unpack(args))
end)
-- Set event constants.
diff --git a/core/keys.lua b/core/keys.lua
index 4d1ccf48..61d8ba55 100644
--- a/core/keys.lua
+++ b/core/keys.lua
@@ -107,7 +107,8 @@ LANGUAGE_MODULE_PREFIX = (not OSX and CTRL or META)..'l'
local OSX = OSX
local string = string
local string_byte, string_char = string.byte, string.char
-local xpcall, next, type, unpack = xpcall, next, type, unpack
+local table_unpack = table.unpack
+local xpcall, next, type = xpcall, next, type
local no_args = {}
local getmetatable = getmetatable
local error = function(e) events.emit(events.ERROR, e) end
@@ -164,7 +165,7 @@ local function run_command(command, command_type)
end
end
end
- local _, result = xpcall(function() return f(unpack(args, 2)) end, error)
+ local _, result = xpcall(f, error, table_unpack(args, 2))
return result
end
_M.run_command = run_command -- export for menu.lua without creating LuaDoc
diff --git a/modules/lua/init.lua b/modules/lua/init.lua
index 8a7fb860..ea4b7874 100644
--- a/modules/lua/init.lua
+++ b/modules/lua/init.lua
@@ -156,7 +156,7 @@ events.connect(events.FILE_AFTER_SAVE, function()
local buffer = buffer
buffer:annotation_clear_all()
local text = buffer:get_text():gsub('^#![^\n]+', '') -- ignore shebang line
- local f, err = loadstring(text)
+ local f, err = load(text)
if f then return end
local line, msg = err:match('^.-:(%d+):%s*(.+)$')
if line then
diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua
index 0e6ab017..254b38a1 100644
--- a/modules/textadept/bookmarks.lua
+++ b/modules/textadept/bookmarks.lua
@@ -72,7 +72,7 @@ end
---
-- Goes to selected bookmark from a filtered list.
-function goto()
+function goto_bookmark()
local buffer = buffer
local markers, line = {}, buffer:marker_next(0, 2^MARK_BOOKMARK)
if line == -1 then return end
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index b574f9dd..3590c2cb 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -27,10 +27,10 @@ local env = setmetatable({}, {
-- Execute a Lua command.
events.connect(events.COMMAND_ENTRY_COMMAND, function(command)
- local f, err = loadstring(command)
+ local f, err = load(command, nil, 'bt', env)
if err then error(err) end
gui.command_entry.focus() -- toggle focus to hide
- setfenv(f, env)()
+ f()
events.emit(events.UPDATE_UI)
end)
@@ -41,8 +41,7 @@ events.connect(events.COMMAND_ENTRY_KEYPRESS, function(code)
elseif keys.KEYSYMS[code] == '\t' then
local substring = gui.command_entry.entry_text:match('[%w_.:]+$') or ''
local path, o, prefix = substring:match('^([%w_.:]-)([.:]?)([%w_]*)$')
- local f, err = loadstring('return ('..path..')')
- if type(f) == "function" then setfenv(f, env) end
+ local f, err = load('return ('..path..')', nil, 'bt', env)
local ok, tbl = pcall(f)
local cmpls = {}
prefix = '^'..prefix
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index d1d75321..be54e3ae 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -42,7 +42,7 @@ function find.find_in_files(utf8_dir)
local text = find.find_entry_text
if not find.lua then text = text:gsub('([().*+?^$%%[%]-])', '%%%1') end
if not find.match_case then text = text:lower() end
- if find.whole_word then text = '[^%W_]'..text..'[^%W_]' end
+ if find.whole_word then text = '%f[%w_]'..text..'%f[^%w_]' end
local match_case, whole_word = find.match_case, find.whole_word
local matches = { 'Find: '..text }
function search_file(file)
@@ -50,7 +50,6 @@ function find.find_in_files(utf8_dir)
for line in io.lines(file) do
local optimized_line = line
if not match_case then optimized_line = line:lower() end
- if whole_word then optimized_line = ' '..line..' ' end
if optimized_line:find(text) then
file = file:iconv('UTF-8', _CHARSET)
matches[#matches + 1] = ('%s:%s:%s'):format(file, line_num, line)
@@ -127,7 +126,7 @@ local function find_(text, next, flags, nowrap, wrapped)
local results = { buffer_text:find(text, buffer.anchor + increment + 1) }
if #results > 0 then
result = results[1]
- find.captures = { unpack(results, 3) }
+ find.captures = { table.unpack(results, 3) }
buffer:set_sel(results[2], result - 1)
else
result = -1
@@ -200,14 +199,13 @@ events.connect(events.COMMAND_ENTRY_COMMAND, function(text)
end, 1) -- place before command_entry.lua's handler (if necessary)
-- Optimize for speed.
-local loadstring = loadstring
-local pcall = pcall
+local load, pcall = load, pcall
-- Runs the given code.
-- This function is passed to `string.gsub()` in the `replace()` function.
-- @param code The code to run.
local function run(code)
- local ok, val = pcall(loadstring('return '..code))
+ local ok, val = pcall(load('return '..code))
if not ok then
gui.dialog('ok-msgbox',
'--title', L('Error'),
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index f10b153c..275a5616 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -225,7 +225,7 @@ keys[not OSX and 'cf2' or 'mf2'] = m_textadept.bookmarks.toggle
keys[not OSX and 'csf2' or 'msf2'] = m_textadept.bookmarks.clear
keys.f2 = m_textadept.bookmarks.goto_next
keys.sf2 = m_textadept.bookmarks.goto_prev
-keys.af2 = m_textadept.bookmarks.goto
+keys.af2 = m_textadept.bookmarks.goto_bookmark
-- Snapopen.
keys[not OSX and 'cu' or 'mu'] = { m_textadept.snapopen.open, _USERHOME }
-- TODO: { m_textadept.snapopen.open, _HOME }
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index bbc632d5..0ba21390 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -131,7 +131,7 @@ menubar = {
{ L('Clear Bookmarks'), m_textadept.bookmarks.clear },
{ L('Next Bookmark'), m_textadept.bookmarks.goto_next },
{ L('Previous Bookmark'), m_textadept.bookmarks.goto_prev },
- { L('Goto Bookmark...'), m_textadept.bookmarks.goto },
+ { L('Goto Bookmark...'), m_textadept.bookmarks.goto_bookmark },
},
{ title = L('Snapopen'),
{ L('Snapopen User Home'), { m_textadept.snapopen.open, _USERHOME } },
diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua
index 3763ab7c..8e849ece 100644
--- a/modules/textadept/snippets.lua
+++ b/modules/textadept/snippets.lua
@@ -307,8 +307,9 @@ _snippet_mt = {
escaped_text = escaped_text:gsub('%%'..index..'<([^>]*)>', function(code)
local env = setmetatable({ selected_text = snippet.original_sel_text },
{ __index = _G })
- local f, result = loadstring('return '..snippet.unescape_text(code, true))
- if f then f, result = pcall(setfenv(f, env)) end
+ local f, result = load('return '..snippet.unescape_text(code, true), nil,
+ 'bt', env)
+ if f then f, result = pcall(f) end
return result or ''
end)
-- Shell code.
diff --git a/src/Makefile b/src/Makefile
index b326db63..333fb838 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -13,9 +13,7 @@ else
PLAT_FLAGS = -DGTK -D__BSD__
endif
SCI_THREAD_FLAG =
-#LUA_CFLAGS = -DLUA_USE_LINUX
-#Lua Coco needs the following flags because GCC is stupid.
-LUA_CFLAGS = -DLUA_USE_LINUX -fomit-frame-pointer -maccumulate-outgoing-args
+LUA_CFLAGS = -DLUA_USE_LINUX
TEXTADEPT = textadept
TEXTADEPT_RC =
EXPORTLUASYMS = -rdynamic -Wl,--retain-symbols-file -Wl,lua.sym
@@ -30,8 +28,7 @@ PKG_CONFIG = pkg-config --define-variable=prefix=win32gtk
PKG_CONFIG_PATH = $(shell pwd)/win32gtk/lib/pkgconfig
PLAT_FLAGS = -DGTK -D__WIN32__
SCI_THREAD_FLAG = -DG_THREADS_IMPL_NONE
-#LUA_CFLAGS = -D_WIN32 -DWIN32
-LUA_CFLAGS = -D_WIN32 -DWIN32 -fomit-frame-pointer -maccumulate-outgoing-args
+LUA_CFLAGS = -D_WIN32 -DWIN32
TEXTADEPT = textadept.exe
TEXTADEPT_RC = textadept_rc.o
EXPORTLUASYMS = -Wl,--retain-symbols-file -Wl,lua.sym
@@ -62,7 +59,7 @@ DEBUG_FLAG = -DNDEBUG
else
DEBUG_FLAG = -DDEBUG -DTRACE -g
endif
-INCLUDEDIRS = -Iscintilla/include -Ilua/include -Igcocoadialog
+INCLUDEDIRS = -Iscintilla/include -Ilua/src -Igcocoadialog
ifdef GTK3
GTKVERSION = gtk+-3.0
@@ -86,12 +83,12 @@ GTKLIBS += -framework Carbon -framework Cocoa -ligemacintegration
endif
TEXTADEPT_OBJS = textadept.o
-LUA_OBJS = lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
- lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o \
- lvm.o lzio.o \
- lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o ltablib.o lstrlib.o \
- loadlib.o loslib.o linit.o \
- lpeg.o lfs.o lcoco.o
+LUA_OBJS = lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o \
+ linit.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o \
+ ltable.o ltm.o lundump.o lvm.o lzio.o \
+ lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o lmathlib.o \
+ loadlib.o loslib.o ltablib.o lstrlib.o \
+ lpeg.o lfs.o
GCOCOADIALOG = gcocoadialog.o
# Scintilla
diff --git a/src/lua.sym b/src/lua.sym
index 18ab3d6c..a2ce7548 100644
--- a/src/lua.sym
+++ b/src/lua.sym
@@ -3,6 +3,7 @@ luaL_addstring
luaL_addvalue
luaL_argerror
luaL_buffinit
+luaL_buffinitsize
luaL_callmeta
luaL_checkany
luaL_checkinteger
@@ -12,39 +13,55 @@ luaL_checkoption
luaL_checkstack
luaL_checktype
luaL_checkudata
+luaL_checkunsigned
+luaL_checkversion
luaL_error
+luaL_execresult
+luaL_fileresult
luaL_findtable
luaL_getmetafield
+luaL_getsubtable
luaL_gsub
+luaL_len
luaL_loadbuffer
luaL_loadfile
luaL_loadstring
+luaL_newlibtable
luaL_newmetatable
luaL_newstate
luaL_openlibs
luaL_optinteger
luaL_optlstring
luaL_optnumber
+luaL_optunsigned
luaL_prepbuffer
+luaL_prepbuffersize
luaL_pushresult
+luaL_pushresultsize
luaL_ref
-luaL_register
-luaL_typerror
+luaL_requiref
+luaL_setfuncs
+luaL_setmetatable
+luaL_testudata
+luaL_tostring
+luaL_traceback
luaL_unref
luaL_where
+lua_absindex
+lua_arith
lua_atpanic
lua_call
+lua_callk
lua_checkstack
lua_close
lua_concat
-lua_cpcall
+lua_copy
lua_createtable
lua_dump
-lua_equal
lua_error
lua_gc
lua_getallocf
-lua_getfenv
+lua_getctx
lua_getfield
lua_gethook
lua_gethookcount
@@ -56,20 +73,21 @@ lua_getstack
lua_gettable
lua_gettop
lua_getupvalue
+lua_getuservalue
lua_ident
lua_insert
lua_iscfunction
lua_isnumber
lua_isstring
lua_isuserdata
-lua_lessthan
+lua_len
lua_load
lua_newstate
lua_newthread
lua_newuserdata
lua_next
-lua_objlen
lua_pcall
+lua_pcallk
lua_pushboolean
lua_pushcclosure
lua_pushfstring
@@ -85,13 +103,13 @@ lua_pushvfstring
lua_rawequal
lua_rawget
lua_rawgeti
+lua_rawlen
lua_rawset
lua_rawseti
lua_remove
lua_replace
lua_resume
lua_setallocf
-lua_setfenv
lua_setfield
lua_sethook
lua_setlevel
@@ -100,20 +118,31 @@ lua_setmetatable
lua_settable
lua_settop
lua_setupvalue
+lua_setuservalue
lua_status
lua_toboolean
lua_tocfunction
lua_tointeger
+lua_tointegerx
lua_tolstring
lua_tonumber
+lua_tonumberx
lua_topointer
lua_tothread
+lua_tounsigned
+lua_tounsignedx
lua_touserdata
+lua_upvalueid
+lua_upvaluejoin
lua_type
lua_typename
+lua_version
lua_xmove
lua_yield
+lua_yieldk
luaopen_base
+luaopen_bitlib
+luaopen_coroutine
luaopen_debug
luaopen_io
luaopen_math
diff --git a/src/textadept.c b/src/textadept.c
index 2f95339f..f828e8ae 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -164,7 +164,7 @@ int main(int argc, char **argv) {
char *last_slash = strrchr(textadept_home, G_DIR_SEPARATOR);
if (last_slash) *last_slash = '\0';
gtk_init(&argc, &argv);
- if (lua = lua_open(), !lL_init(lua, argc, argv, FALSE)) return 1;
+ if (lua = luaL_newstate(), !lL_init(lua, argc, argv, FALSE)) return 1;
new_window();
lL_dofile(lua, "init.lua");
gtk_main();
@@ -732,7 +732,7 @@ static gboolean c_keypress(GtkWidget*_, GdkEventKey *event, gpointer __) {
/******************************************************************************/
#define lL_openlib(l, n, f) \
- (lua_pushcfunction(l, f), lua_pushstring(l, n), lua_call(l, 1, 0))
+ (luaL_requiref(l, n, f, 1), lua_pop(l, 1))
#define l_setcfunction(l, n, k, f) \
(lua_pushcfunction(l, f), lua_setfield(l, (n > 0) ? n : n - 1, k))
#define l_setmetatable(l, n, k, i, ni) { \
@@ -765,7 +765,7 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) {
lua_getglobal(L, "package"), lua_getfield(L, -1, "loaded");
lL_cleartable(L, lua_gettop(L));
lua_pop(L, 2); // package and package.loaded
- lL_cleartable(L, LUA_GLOBALSINDEX);
+ lL_cleartable(L, LUA_RIDX_GLOBALS);
}
luaL_openlibs(L);
lL_openlib(L, "lpeg", luaopen_lpeg);
@@ -840,7 +840,7 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) {
*/
static int lL_dofile(lua_State *L, const char *filename) {
char *file = g_strconcat(textadept_home, "/", filename, NULL);
- int ok = (luaL_dofile(L, file) == 0);
+ int ok = (luaL_dofile(L, file) == LUA_OK);
if (!ok) {
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
@@ -883,8 +883,8 @@ static void lL_addview(lua_State *L, GtkWidget *view) {
l_setmetatable(L, -2, "ta_view", lview__index, lview__newindex);
// vs[userdata] = v, vs[#vs + 1] = v, vs[v] = #vs
lua_pushvalue(L, -2), lua_settable(L, -4);
- lua_pushvalue(L, -1), lua_rawseti(L, -3, lua_objlen(L, -3) + 1);
- lua_pushinteger(L, lua_objlen(L, -2)), lua_settable(L, -3);
+ lua_pushvalue(L, -1), lua_rawseti(L, -3, lua_rawlen(L, -3) + 1);
+ lua_pushinteger(L, lua_rawlen(L, -2)), lua_settable(L, -3);
lua_pop(L, 1); // views
}
@@ -903,9 +903,9 @@ static void lL_removeview(lua_State *L, GtkWidget *view) {
if (lua_isnumber(L, -2) && view != l_toview(L, -1)) {
lua_getfield(L, -1, "widget_pointer");
// vs[userdata] = v, vs[#vs + 1] = v, vs[v] = #vs
- lua_pushvalue(L, -2), lua_rawseti(L, -6, lua_objlen(L, -6) + 1);
+ lua_pushvalue(L, -2), lua_rawseti(L, -6, lua_rawlen(L, -6) + 1);
lua_pushvalue(L, -2), lua_settable(L, -6);
- lua_pushinteger(L, lua_objlen(L, -4)), lua_settable(L, -5);
+ lua_pushinteger(L, lua_rawlen(L, -4)), lua_settable(L, -5);
} else lua_pop(L, 1); // value
}
lua_pop(L, 1); // views
@@ -942,8 +942,8 @@ static void lL_adddoc(lua_State *L, sptr_t doc) {
l_setmetatable(L, -2, "ta_buffer", lbuf_property, lbuf_property);
// bs[userdata] = b, bs[#bs + 1] = b, bs[b] = #bs
lua_pushvalue(L, -2), lua_settable(L, -4);
- lua_pushvalue(L, -1), lua_rawseti(L, -3, lua_objlen(L, -3) + 1);
- lua_pushinteger(L, lua_objlen(L, -2)), lua_settable(L, -3);
+ lua_pushvalue(L, -1), lua_rawseti(L, -3, lua_rawlen(L, -3) + 1);
+ lua_pushinteger(L, lua_rawlen(L, -2)), lua_settable(L, -3);
lua_pop(L, 1); // buffers
}
@@ -975,9 +975,9 @@ static void lL_removedoc(lua_State *L, sptr_t doc) {
if (lua_isnumber(L, -2) && doc != l_todoc(L, -1)) {
lua_getfield(L, -1, "doc_pointer");
// bs[userdata] = b, bs[#bs + 1] = b, bs[b] = #bs
- lua_pushvalue(L, -2), lua_rawseti(L, -6, lua_objlen(L, -6) + 1);
+ lua_pushvalue(L, -2), lua_rawseti(L, -6, lua_rawlen(L, -6) + 1);
lua_pushvalue(L, -2), lua_settable(L, -6);
- lua_pushinteger(L, lua_objlen(L, -4)), lua_settable(L, -5);
+ lua_pushinteger(L, lua_rawlen(L, -4)), lua_settable(L, -5);
} else lua_pop(L, 1); // value
}
lua_pop(L, 1); // buffers
@@ -1000,15 +1000,15 @@ static void lL_gotodoc(lua_State *L, GtkWidget *view, int n, int relative) {
l_pushdoc(L, SS(view, SCI_GETDOCPOINTER, 0, 0)), lua_gettable(L, -2);
n = lua_tointeger(L, -1) + n;
lua_pop(L, 1); // index
- if (n > lua_objlen(L, -1))
+ if (n > lua_rawlen(L, -1))
n = 1;
else if (n < 1)
- n = lua_objlen(L, -1);
+ n = lua_rawlen(L, -1);
lua_rawgeti(L, -1, n);
} else {
- luaL_argcheck(L, (n > 0 && n <= lua_objlen(L, -1)) || n == -1, 2,
+ luaL_argcheck(L, (n > 0 && n <= lua_rawlen(L, -1)) || n == -1, 2,
"no Buffer exists at that index");
- lua_rawgeti(L, -1, (n > 0) ? n : lua_objlen(L, -1));
+ lua_rawgeti(L, -1, (n > 0) ? n : lua_rawlen(L, -1));
}
sptr_t doc = l_todoc(L, -1);
SS(view, SCI_SETDOCPOINTER, 0, doc);
@@ -1153,7 +1153,7 @@ static long lL_checkscintillaparam(lua_State *L, int *narg, int type) {
static GtkWidget *lL_checkview(lua_State *L, int narg) {
luaL_getmetatable(L, "ta_view");
lua_getmetatable(L, narg);
- luaL_argcheck(L, lua_equal(L, -1, -2), narg, "View expected");
+ luaL_argcheck(L, lua_compare(L, -1, -2, LUA_OPEQ), narg, "View expected");
lua_getfield(L, (narg > 0) ? narg : narg - 2, "widget_pointer");
GtkWidget *view = (GtkWidget *)lua_touserdata(L, -1);
lua_pop(L, 3); // widget_pointer, metatable, metatable
@@ -1170,7 +1170,7 @@ static GtkWidget *lL_checkview(lua_State *L, int narg) {
static void lL_globaldoccheck(lua_State *L, int narg) {
luaL_getmetatable(L, "ta_buffer");
lua_getmetatable(L, (narg > 0) ? narg : narg - 1);
- luaL_argcheck(L, lua_equal(L, -1, -2), narg, "Buffer expected");
+ luaL_argcheck(L, lua_compare(L, -1, -2, LUA_OPEQ), narg, "Buffer expected");
lua_getfield(L, (narg > 0) ? narg : narg - 2, "doc_pointer");
sptr_t doc = (sptr_t)lua_touserdata(L, -1);
luaL_argcheck(L, doc == SS(focused_view, SCI_GETDOCPOINTER, 0, 0), narg,
@@ -1210,7 +1210,7 @@ static void l_pushgtkmenu(lua_State *L, int index, GCallback callback,
gtk_menu_shell_append(GTK_MENU_SHELL(menu),
(GtkWidget *)lua_touserdata(L, -1));
lua_pop(L, 1); // gtkmenu
- } else if (lua_objlen(L, -1) == 2 || lua_objlen(L, -1) == 4) {
+ } else if (lua_rawlen(L, -1) == 2 || lua_rawlen(L, -1) == 4) {
lua_rawgeti(L, -1, 1);
label = lua_tostring(L, -1);
lua_pop(L, 1); // label
@@ -1286,7 +1286,7 @@ static int lL_event(lua_State *L, const char *name, ...) {
type = va_arg(ap, int);
}
va_end(ap);
- if (lua_pcall(L, n, 1, 0) == 0)
+ if (lua_pcall(L, n, 1, 0) == LUA_OK)
ret = lua_toboolean(L, -1);
else
lL_event(L, "error", LUA_TSTRING, lua_tostring(L, -1), -1);
@@ -1386,7 +1386,7 @@ static int l_callscintilla(lua_State *L, int msg, int wtype, int ltype,
// Set wParam and lParam appropriately for Scintilla based on wtype and ltype.
if (wtype == tLENGTH && ltype == tSTRING) {
- wparam = (uptr_t)lua_strlen(L, arg);
+ wparam = (uptr_t)lua_rawlen(L, arg);
lparam = (sptr_t)luaL_checkstring(L, arg);
params_needed = 0;
} else if (ltype == tSTRINGRESULT) {
@@ -1429,7 +1429,7 @@ static int lbuf_property(lua_State *L) {
int newindex = (lua_gettop(L) == 3);
luaL_getmetatable(L, "ta_buffer");
lua_getmetatable(L, 1); // metatable can be either ta_buffer or ta_bufferp
- int is_buffer = lua_equal(L, -1, -2);
+ int is_buffer = lua_compare(L, -1, -2, LUA_OPEQ);
lua_pop(L, 2); // metatable, metatable
// If the key is a Scintilla function, return a callable closure.
@@ -1567,7 +1567,7 @@ static int lgui__newindex(lua_State *L) {
gtk_widget_hide(menubar);
#endif
} else if (strcmp(key, "size") == 0) {
- luaL_argcheck(L, lua_istable(L, 3) && lua_objlen(L, 3) == 2, 3,
+ luaL_argcheck(L, lua_istable(L, 3) && lua_rawlen(L, 3) == 2, 3,
"{ width, height } table expected");
int w = l_rawgetiint(L, 3, 1), h = l_rawgetiint(L, 3, 2);
if (w > 0 && h > 0) gtk_window_resize(GTK_WINDOW(window), w, h);
@@ -1667,7 +1667,7 @@ static int lbuffer_delete(lua_State *L) {
lL_globaldoccheck(L, 1);
sptr_t doc = SS(focused_view, SCI_GETDOCPOINTER, 0, 0);
lua_getfield(L, LUA_REGISTRYINDEX, "ta_buffers");
- if (lua_objlen(L, -1) == 1) new_buffer(0);
+ if (lua_rawlen(L, -1) == 1) new_buffer(0);
lL_gotodoc(L, focused_view, -1, TRUE);
delete_buffer(doc);
lL_event(L, "buffer_deleted", -1),
@@ -1678,7 +1678,7 @@ static int lbuffer_delete(lua_State *L) {
static int lbuffer_new(lua_State *L) {
new_buffer(0);
lua_getfield(L, LUA_REGISTRYINDEX, "ta_buffers");
- lua_rawgeti(L, -1, lua_objlen(L, -1));
+ lua_rawgeti(L, -1, lua_rawlen(L, -1));
return 1;
}
@@ -1757,11 +1757,11 @@ static int lgui_dialog(lua_State *L) {
GCDialogType type = gcocoadialog_type(luaL_checkstring(L, 1));
int i, j, k, n = lua_gettop(L) - 1, argc = n;
for (i = 2; i < n + 2; i++)
- if (lua_istable(L, i)) argc += lua_objlen(L, i) - 1;
+ if (lua_istable(L, i)) argc += lua_rawlen(L, i) - 1;
const char **argv = malloc((argc + 1) * sizeof(const char *));
for (i = 0, j = 2; j < n + 2; j++)
if (lua_istable(L, j)) {
- int len = lua_objlen(L, j);
+ int len = lua_rawlen(L, j);
for (k = 1; k <= len; k++) {
lua_rawgeti(L, j, k);
argv[i++] = luaL_checkstring(L, -1);
@@ -1782,13 +1782,13 @@ static int lgui_goto_view(lua_State *L) {
if (relative) {
l_pushview(L, focused_view), lua_gettable(L, -2);
n = lua_tointeger(L, -1) + n;
- if (n > lua_objlen(L, -2))
+ if (n > lua_rawlen(L, -2))
n = 1;
else if (n < 1)
- n = lua_objlen(L, -2);
+ n = lua_rawlen(L, -2);
lua_rawgeti(L, -2, n);
} else {
- luaL_argcheck(L, n > 0 && n <= lua_objlen(L, -1), 1,
+ luaL_argcheck(L, n > 0 && n <= lua_rawlen(L, -1), 1,
"no View exists at that index");
lua_rawgeti(L, -1, n);
}
@@ -1848,7 +1848,7 @@ static gboolean emit_timeout(gpointer data) {
lua_rawgeti(lua, LUA_REGISTRYINDEX, refs[0]); // function
int nargs = 0, repeat = TRUE;
while (refs[++nargs]) lua_rawgeti(lua, LUA_REGISTRYINDEX, refs[nargs]);
- int ok = (lua_pcall(lua, nargs - 1, 1, 0) == 0);
+ int ok = (lua_pcall(lua, nargs - 1, 1, 0) == LUA_OK);
if (!ok || !lua_toboolean(lua, -1)) {
while (--nargs >= 0) luaL_unref(lua, LUA_REGISTRYINDEX, refs[nargs]);
repeat = FALSE;