Changeset

4781:51ed468662a1

Merge with Zash
author Matthew Wild <mwild1@gmail.com>
date Sat, 28 Apr 2012 16:22:17 +0100
parents 4780:4b8f2b91826c (diff) 4779:9f2639b3d9b1 (current diff)
children 4782:28e7664924bd
files
diffstat 2 files changed, 18 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_adhoc.lua	Sat Apr 28 17:18:03 2012 +0200
+++ b/plugins/mod_admin_adhoc.lua	Sat Apr 28 16:22:17 2012 +0100
@@ -24,7 +24,7 @@
 local array = require "util.array";
 local modulemanager = require "modulemanager";
 
-module:depends"adhoc";
+module:depends("adhoc");
 local adhoc_new = module:require "adhoc".new;
 
 function add_user_command_handler(self, data, state)
--- a/util/debug.lua	Sat Apr 28 17:18:03 2012 +0200
+++ b/util/debug.lua	Sat Apr 28 16:22:17 2012 +0100
@@ -97,7 +97,7 @@
 		levels[(level-start_level)+1] = {
 			level = level;
 			info = info;
-			locals = get_locals_table(level);
+			locals = get_locals_table(level+1);
 			upvalues = get_upvalues_table(info.func);
 		};
 	end	
@@ -119,21 +119,26 @@
 
 function _traceback(thread, message, level)
 
-	if type(thread) ~= "thread" then
+	-- Lua manual says: debug.traceback ([thread,] [message [, level]])
+	-- I fathom this to mean one of:
+	-- ()
+	-- (thread)
+	-- (message, level)
+	-- (thread, message, level)
+
+	if thread == nil then -- Defaults
+		thread, message, level = coroutine.running(), message, level;
+	elseif type(thread) == "string" then
 		thread, message, level = coroutine.running(), thread, message;
+	elseif type(thread) ~= "thread" then
+		return nil; -- debug.traceback() does this
 	end
-	if level and type(message) ~= "string" then
-		return nil, "invalid message";
-	elseif not level then
-		if type(message) == "number" then
-			level, message = message, nil;
-		else
-			level = 1;
-		end
-	end
-	
+
+	level = level or 1;
+
 	message = message and (message.."\n") or "";
 	
+	-- +3 counts for this function, and the pcall() and wrapper above us
 	local levels = get_traceback_table(thread, level+3);
 	
 	local last_source_desc;