[asterisk-commits] murf: branch 1.6.1 r144484 - in /branches/1.6.1: ./ pbx/pbx_lua.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 25 12:58:03 CDT 2008


Author: murf
Date: Thu Sep 25 12:58:02 2008
New Revision: 144484

URL: http://svn.digium.com/view/asterisk?view=rev&rev=144484
Log:
Merged revisions 144482 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r144482 | murf | 2008-09-25 11:51:11 -0600 (Thu, 25 Sep 2008) | 14 lines

(closes issue #13558)
Reported by: mnicholson

Considering that the example extensions.lua used nothing but ["12345"] notation,
and that the resulting error message: 

[Sep 24 17:01:16] ERROR[12393]: pbx_lua.c:1204 exec: Error executing lua extension: attempt to call a nil value

is not very informative as to the nature of the problem, I think this bug
fix is a big win!




........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/pbx/pbx_lua.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/pbx/pbx_lua.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/pbx/pbx_lua.c?view=diff&rev=144484&r1=144483&r2=144484
==============================================================================
--- branches/1.6.1/pbx/pbx_lua.c (original)
+++ branches/1.6.1/pbx/pbx_lua.c Thu Sep 25 12:58:02 2008
@@ -1193,22 +1193,25 @@
 	
 	/* step through the extensions looking for a match */
 	for (i = 1; i < lua_objlen(L, context_order_table) + 1; i++) {
-		int e_index, isnumber, match = 0;
+		int e_index, e_index_copy, match = 0;
 		const char *e;
 
 		lua_pushinteger(L, i);
 		lua_gettable(L, context_order_table);
 		e_index = lua_gettop(L);
-		isnumber = lua_isnumber(L, e_index);
-
-		if (!(e = lua_tostring(L, e_index))) {
-			lua_pop(L, 1);
+
+		/* copy the key at the top of the stack for use later */
+		lua_pushvalue(L, -1);
+		e_index_copy = lua_gettop(L);
+
+		if (!(e = lua_tostring(L, e_index_copy))) {
+			lua_pop(L, 2);
 			continue;
 		}
 
 		/* make sure this is not the 'include' extension */
 		if (!strcasecmp(e, "include")) {
-			lua_pop(L, 1);
+			lua_pop(L, 2);
 			continue;
 		}
 
@@ -1223,34 +1226,28 @@
 		 * match, 2 on earlymatch */
 
 		if (!match) {
-			lua_pop(L, 1);
+			/* pop the copy and the extension */
+			lua_pop(L, 2);
 			continue;	/* keep trying */
 		}
 
 		if (func == &matchmore && match == 2) {
 			/* We match an extension ending in '!'. The decision in
 			 * this case is final and counts as no match. */
-			lua_pop(L, 3);
+			lua_pop(L, 4);
 			return 0;
 		}
 
-		/* remove the context table, the context order table, and the
-		 * extension (or replace the extension with the corisponding
-		 * function) */
+		/* remove the context table, the context order table, the
+		 * extension, and the extension copy (or replace the extension
+		 * with the corresponding function) */
 		if (push_func) {
-			/* here we must convert the exten back to an integer
-			 * because lua_tostring will change the value on the
-			 * stack to a string */
-			if (isnumber) {
-				int e_int = lua_tointeger(L, e_index);
-				lua_pop(L, 1);  /* the exten should be the top of the stack */
-				lua_pushinteger(L, e_int);
-			}
+			lua_pop(L, 1);  /* pop the copy */
 			lua_gettable(L, context_table);
 			lua_insert(L, -3);
 			lua_pop(L, 2);
 		} else {
-			lua_pop(L, 3);
+			lua_pop(L, 4);
 		}
 
 		return 1;




More information about the asterisk-commits mailing list