[Asterisk-cvs] asterisk/funcs func_strings.c,1.10,1.11

russell russell
Mon Oct 17 14:00:33 CDT 2005


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

Modified Files:
	func_strings.c 
Log Message:
clean up function to be more consistent with coding guidelines


Index: func_strings.c
===================================================================
RCS file: /usr/cvsroot/asterisk/funcs/func_strings.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- func_strings.c	14 Oct 2005 00:45:38 -0000	1.10
+++ func_strings.c	17 Oct 2005 17:54:32 -0000	1.11
@@ -140,42 +140,43 @@
 
 static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
-	char *format, *epoch, *timezone;
+	char *format, *epoch, *timezone = NULL;
 	long epochi;
 	struct tm time;
 
-	if (data) {
-		format = ast_strdupa(data);
-		if (format) {
-			epoch = strsep(&format, "|");
-			timezone = strsep(&format, "|");
+	buf[0] = '\0';
 
-			if (epoch && !ast_strlen_zero(epoch) && sscanf(epoch, "%ld", &epochi) == 1) {
-			} else {
-				struct timeval tv = ast_tvnow();
-				epochi = tv.tv_sec;
-			}
+	if (!data) {
+		ast_log(LOG_ERROR, "Asterisk function STRFTIME() requires an argument.\n");
+		return buf;
+	}
+	
+	format = ast_strdupa(data);
+	if (!format) {
+		ast_log(LOG_ERROR, "Out of memory\n");
+		return buf;
+	}
+	
+	epoch = strsep(&format, "|");
+	timezone = strsep(&format, "|");
 
-			ast_localtime(&epochi, &time, timezone);
+	if (!epoch || ast_strlen_zero(epoch) || !sscanf(epoch, "%ld", &epochi)) {
+		struct timeval tv = ast_tvnow();
+		epochi = tv.tv_sec;
+	}
 
-			if (!format) {
-				format = "%c";
-			}
+	ast_localtime(&epochi, &time, timezone);
 
-			buf[0] = '\0';
-			if (! strftime(buf, len, format, &time)) {
-				ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
-			}
-			buf[len - 1] = '\0';
+	if (!format) {
+		format = "%c";
+	}
 
-			return buf;
-		} else {
-			ast_log(LOG_ERROR, "Out of memory\n");
-		}
-	} else {
-		ast_log(LOG_ERROR, "Asterisk function STRFTIME() requires an argument.\n");
+	if (!strftime(buf, len, format, &time)) {
+		ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
 	}
-	return "";
+	buf[len - 1] = '\0';
+
+	return buf;
 }
 
 #ifndef BUILTIN_FUNC




More information about the svn-commits mailing list