[asterisk-commits] murf: branch murf/bug7804 r41134 - in /team/murf/bug7804: pbx/ pbx/ael/ael-te...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Aug 25 12:31:18 MST 2006


Author: murf
Date: Fri Aug 25 14:31:18 2006
New Revision: 41134

URL: http://svn.digium.com/view/asterisk?rev=41134&view=rev
Log:
Fixed the probs outlined in bug 7804. All 3 cause a crash,
so this bug fixes 3 separate crashes. One's new, caused by
the update module loader code.
The pbx makefile is updated because of typos in the -D
for the ael tests.


Added:
    team/murf/bug7804/pbx/ael/ael-test/ael-test14/
    team/murf/bug7804/pbx/ael/ael-test/ael-test14/extensions.ael   (with props)
    team/murf/bug7804/pbx/ael/ael-test/ref.ael-test14   (with props)
Modified:
    team/murf/bug7804/pbx/pbx_ael.c
    team/murf/bug7804/utils/Makefile
    team/murf/bug7804/utils/ael_main.c

Added: team/murf/bug7804/pbx/ael/ael-test/ael-test14/extensions.ael
URL: http://svn.digium.com/view/asterisk/team/murf/bug7804/pbx/ael/ael-test/ael-test14/extensions.ael?rev=41134&view=auto
==============================================================================
--- team/murf/bug7804/pbx/ael/ael-test/ael-test14/extensions.ael (added)
+++ team/murf/bug7804/pbx/ael/ael-test/ael-test14/extensions.ael Fri Aug 25 14:31:18 2006
@@ -1,0 +1,20 @@
+context test1
+{
+	10 => {
+		// nothing but a comment!
+	}
+
+	11 => {
+		switch(${somevar})
+		{
+		case somecase:
+			// nothing but a comment!
+			break;
+		case somecase:
+			// nothing but a comment!
+			continue;
+		}
+		break;
+	}
+
+}

Propchange: team/murf/bug7804/pbx/ael/ael-test/ael-test14/extensions.ael
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/murf/bug7804/pbx/ael/ael-test/ael-test14/extensions.ael
------------------------------------------------------------------------------
    svn:keywords = Author Id Date Revision

Propchange: team/murf/bug7804/pbx/ael/ael-test/ael-test14/extensions.ael
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/murf/bug7804/pbx/ael/ael-test/ref.ael-test14
URL: http://svn.digium.com/view/asterisk/team/murf/bug7804/pbx/ael/ael-test/ref.ael-test14?rev=41134&view=auto
==============================================================================
--- team/murf/bug7804/pbx/ael/ael-test/ref.ael-test14 (added)
+++ team/murf/bug7804/pbx/ael/ael-test/ref.ael-test14 Fri Aug 25 14:31:18 2006
@@ -1,0 +1,11 @@
+
+(If you find progress and other non-error messages irritating, you can use -q to suppress them)
+
+(You can use the -w option to dump extensions.conf format to extensions.conf.aeldump)
+LOG: lev:2 file:../pbx/pbx_ael.c  line:3801 func: pbx_load_module  Starting AEL load process.
+LOG: lev:2 file:../pbx/pbx_ael.c  line:3808 func: pbx_load_module  AEL load process: calculated config file name './extensions.ael'.
+LOG: lev:2 file:../pbx/pbx_ael.c  line:3811 func: pbx_load_module  AEL load process: parsed config file name './extensions.ael'.
+LOG: lev:4 file:../pbx/pbx_ael.c  line:1045 func: check_continue  Error: file ./extensions.ael, line 15-15: 'continue' not in 'for' or 'while' statement!
+LOG: lev:4 file:../pbx/pbx_ael.c  line:1026 func: check_break  Error: file ./extensions.ael, line 17-17: 'break' not in switch, for, or while statement!
+LOG: lev:4 file:../pbx/pbx_ael.c  line:3824 func: pbx_load_module  Sorry, but 0 syntax errors and 2 semantic errors were detected. It doesn't make sense to compile.
+LOG: lev:4 file:ael2_parse  line:479 func: main  0 contexts, 0 extensions, 0 priorities

Propchange: team/murf/bug7804/pbx/ael/ael-test/ref.ael-test14
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/murf/bug7804/pbx/ael/ael-test/ref.ael-test14
------------------------------------------------------------------------------
    svn:keywords = Author Id Date Revision

Propchange: team/murf/bug7804/pbx/ael/ael-test/ref.ael-test14
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/murf/bug7804/pbx/pbx_ael.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug7804/pbx/pbx_ael.c?rev=41134&r1=41133&r2=41134&view=diff
==============================================================================
--- team/murf/bug7804/pbx/pbx_ael.c (original)
+++ team/murf/bug7804/pbx/pbx_ael.c Fri Aug 25 14:31:18 2006
@@ -58,10 +58,11 @@
 
 static char *config = "extensions.ael";
 static char *registrar = "pbx_ael";
+static int pbx_load_module(void);
 
 static int errs, warns;
+static int notes;
 #ifndef STANDALONE_AEL
-static int notes;
 #endif
 
 #ifndef AAL_ARGCHECK
@@ -1009,6 +1010,46 @@
 		e = s;
 }
 
+static int check_break(pval *item)
+{
+	pval *p = item;
+	
+	while( p && p->type != PV_MACRO && p->type != PV_CONTEXT ) /* early cutout, sort of */ {
+		/* a break is allowed in WHILE, FOR, CASE, DEFAULT, PATTERN; otherwise, it don't make
+		   no sense */
+		if( p->type == PV_CASE || p->type == PV_DEFAULT || p->type == PV_PATTERN 
+			|| p->type == PV_WHILE || p->type == PV_FOR   ) {
+			return 1;
+		}
+		p = p->dad;
+	}
+	ast_log(LOG_ERROR,"Error: file %s, line %d-%d: 'break' not in switch, for, or while statement!\n",
+			item->filename, item->startline, item->endline);
+	errs++;
+	
+	return 0;
+}
+
+static int check_continue(pval *item)
+{
+	pval *p = item;
+	
+	while( p && p->type != PV_MACRO && p->type != PV_CONTEXT ) /* early cutout, sort of */ {
+		/* a break is allowed in WHILE, FOR, CASE, DEFAULT, PATTERN; otherwise, it don't make
+		   no sense */
+		if( p->type == PV_WHILE || p->type == PV_FOR   ) {
+			return 1;
+		}
+		p = p->dad;
+	}
+	ast_log(LOG_ERROR,"Error: file %s, line %d-%d: 'continue' not in 'for' or 'while' statement!\n",
+			item->filename, item->startline, item->endline);
+	errs++;
+	
+	return 0;
+}
+
+
 /* general purpose goto finder */
 
 static void check_label(pval *item)
@@ -2092,7 +2133,6 @@
 #endif
 }
 
-#ifndef STANDALONE_AEL
 static void check_context_names(void)
 {
 	pval *i,*j;
@@ -2111,6 +2151,7 @@
 		}
 	}
 }
+#ifndef STANDALONE_AEL
 #endif
 
 static void check_abstract_reference(pval *abstract_context)
@@ -2438,6 +2479,7 @@
 	case PV_BREAK:
 		/* fields: none
 		*/
+		check_break(item);
 		break;
 			
 	case PV_RETURN:
@@ -2448,6 +2490,7 @@
 	case PV_CONTINUE:
 		/* fields: none
 		*/
+		check_continue(item);
 		break;
 			
 	case PV_RANDOM:
@@ -2576,7 +2619,6 @@
 	}
 }
 
-#ifndef STANDALONE_AEL
 static void ael2_semantic_check(pval *item, int *arg_errs, int *arg_warns, int *arg_notes)
 {
 	
@@ -2607,7 +2649,6 @@
 	*arg_warns = warns;
 	*arg_notes = notes;
 }
-#endif
 
 /* =============================================================================================== */
 /* "CODE" GENERATOR -- Convert the AEL representation to asterisk extension language */
@@ -3658,7 +3699,13 @@
 						exten-> return_target = np2;
 					}
 					/* is the last priority in the extension a label? Then add a trailing no-op */
-					if ( exten->plist_last->type == AEL_LABEL ) {
+					if( !exten->plist_last )
+					{
+						ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: Empty Extension!\n",
+								p2->filename, p2->startline, p2->endline);
+					}
+					
+					if ( exten->plist_last && exten->plist_last->type == AEL_LABEL ) {
 						struct ael_priority *np2 = new_prio();
 						np2->type = AEL_APPCALL;
 						np2->app = strdup("NoOp");
@@ -3737,10 +3784,12 @@
 	
 }
 
-#ifndef STANDALONE_AEL
+
 static int aeldebug = 0;
 
 /* interface stuff */
+
+/* if all the below are static, who cares if they are present? */
 
 static int pbx_load_module(void)
 {
@@ -3844,12 +3893,25 @@
 	return pbx_load_module();
 }
 
+#ifdef STANDALONE_AEL
+#define AST_MODULE "ael"
+#endif
+
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk Extension Language Compiler",
 		.load = load_module,
 		.unload = unload_module,
 		.reload = reload,
 	       );
+
+#ifdef STANDALONE_AEL
+int ael_external_load_module(void);
+int ael_external_load_module(void)
+{
+	pbx_load_module();
+	return 1;
+}
 #endif
+
 
 /* DESTROY the PVAL tree ============================================================================ */
 

Modified: team/murf/bug7804/utils/Makefile
URL: http://svn.digium.com/view/asterisk/team/murf/bug7804/utils/Makefile?rev=41134&r1=41133&r2=41134&view=diff
==============================================================================
--- team/murf/bug7804/utils/Makefile (original)
+++ team/murf/bug7804/utils/Makefile Fri Aug 25 14:31:18 2006
@@ -68,12 +68,12 @@
 $(eval $(call ast_make_o_c,ast_expr2.o,../main/ast_expr2.c))
 
 $(eval $(call ast_make_o_c,ast_expr2f.o,../main/ast_expr2f.c))
-ast_expr2f.o: CFLAGS+=-DSTANDALONE
+ast_expr2f.o: CFLAGS+=-DSTANDALONE_AEL
 
 $(eval $(call ast_make_final,check_expr,check_expr.c ast_expr2.o ast_expr2f.o))
 
 $(eval $(call ast_make_o_c,aelflex.o,../pbx/ael/ael_lex.c ../include/asterisk/ael_structs.h ../pbx/ael/ael.tab.h))
-aelflex.o: CFLAGS+=-I../pbx -DSTANDALONE
+aelflex.o: CFLAGS+=-I../pbx -DSTANDALONE_AEL
 
 $(eval $(call ast_make_o_c,aelbison.o,../pbx/ael/ael.tab.c ../pbx/ael/ael.tab.h ../include/asterisk/ael_structs.h))
 aelbison.o: CFLAGS+=-I../pbx
@@ -86,8 +86,8 @@
 $(eval $(call ast_make_o_c,ael_main.o,ael_main.c ../include/asterisk/ael_structs.h))
 
 testexpr2s: ../main/ast_expr2f.c ../main/ast_expr2.c ../main/ast_expr2.h
-	$(CC) -g -c -I../include -DSTANDALONE ../main/ast_expr2f.c -o ast_expr2f.o
-	$(CC) -g -c -I../include -DSTANDALONE ../main/ast_expr2.c -o ast_expr2.o
+	$(CC) -g -c -I../include -DSTANDALONE_AEL ../main/ast_expr2f.c -o ast_expr2f.o
+	$(CC) -g -c -I../include -DSTANDALONE_AEL ../main/ast_expr2.c -o ast_expr2.o
 	$(CC) -g -o testexpr2s ast_expr2f.o ast_expr2.o
 	rm ast_expr2.o ast_expr2f.o 
 	./testexpr2s expr2.testinput

Modified: team/murf/bug7804/utils/ael_main.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug7804/utils/ael_main.c?rev=41134&r1=41133&r2=41134&view=diff
==============================================================================
--- team/murf/bug7804/utils/ael_main.c (original)
+++ team/murf/bug7804/utils/ael_main.c Fri Aug 25 14:31:18 2006
@@ -119,6 +119,24 @@
 		printf("Executed ast_add_profile();\n");
 }
 
+int ast_loader_register(int (*updater)(void))
+{
+	return 1;
+}
+
+int ast_loader_unregister(int (*updater)(void))
+{
+	return 1;
+}
+void ast_module_register(const struct ast_module_info *x)
+{
+}
+
+void ast_module_unregister(const struct ast_module_info *x)
+{
+}
+
+
 void ast_cli_register_multiple(void)
 {
 	if(!no_comp)
@@ -406,6 +424,7 @@
 
 
 extern struct module_symbols mod_data;
+extern ael_external_load_module(void);
 
 int main(int argc, char **argv)
 {
@@ -455,7 +474,7 @@
 
 	FIRST_TIME = 1;
 	
-	ast_module_info->load();
+	ael_external_load_module(); /* pbx_load_module(); */ /*  ast_module_info->load(); */
 	
 	ast_log(4, "ael2_parse", __LINE__, "main", "%d contexts, %d extensions, %d priorities\n", conts, extens, priors);
 



More information about the asterisk-commits mailing list