[Asterisk-cvs] asterisk pbx.c,1.134,1.135

anthm at lists.digium.com anthm at lists.digium.com
Thu Jul 1 16:56:59 CDT 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv12876

Modified Files:
	pbx.c 
Log Message:
bring justice to gotoif's always true bug

Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- pbx.c	29 Jun 2004 13:52:03 -0000	1.134
+++ pbx.c	1 Jul 2004 20:42:49 -0000	1.135
@@ -4588,19 +4588,7 @@
 
 static int pbx_checkcondition(char *condition) 
 {
-	char *s;
-	int ret;
-	
-	s=strdup(condition);
-	
-	ret=1;
-	
-	if ((strcasecmp(s,"0")) || ast_strlen_zero(s)) {
-		ret=0;
-	}
-	
-	free(s);
-	return(ret);
+	return condition ? atoi(condition) : 0;
 }
 
 static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
@@ -4615,17 +4603,12 @@
 		return 0;
 	}
 	
-	s=strdup(data);
+	s=ast_strdupa(data);
 	stringp=s;
 	condition=strsep(&stringp,"?");
 	branch1=strsep(&stringp,":");
 	branch2=strsep(&stringp,"");
-	
-	if (pbx_checkcondition(condition)) {
-		branch=branch2;
-	} else {
-		branch=branch1;
-	}
+	branch = pbx_checkcondition(condition) ? branch1 : branch2;
 	
 	if ((branch==NULL) || ast_strlen_zero(branch)) {
 		ast_log(LOG_NOTICE, "Not taking any branch\n");
@@ -4633,7 +4616,7 @@
 	}
 	
 	rc=pbx_builtin_goto(chan,branch);
-	free(s);
+
 	return(rc);
 }           
 




More information about the svn-commits mailing list