[xiph-commits] r12546 - trunk/ezstream/src

moritz at svn.xiph.org moritz at svn.xiph.org
Sat Feb 24 14:56:20 PST 2007


Author: moritz
Date: 2007-02-24 14:56:18 -0800 (Sat, 24 Feb 2007)
New Revision: 12546

Modified:
   trunk/ezstream/src/configfile.c
Log:
Replace three if-conditionals with one, both in getFormatEncoder() and
getFormatDecoder(), with prettier formatting.


Modified: trunk/ezstream/src/configfile.c
===================================================================
--- trunk/ezstream/src/configfile.c	2007-02-24 22:50:14 UTC (rev 12545)
+++ trunk/ezstream/src/configfile.c	2007-02-24 22:56:18 UTC (rev 12546)
@@ -43,44 +43,42 @@
 	return (&ezConfig);
 }
 
-char*	getFormatEncoder(const char *format)
+char *
+getFormatEncoder(const char *format)
 {
-	int i = 0;
-	for (i=0;i<ezConfig.numEncoderDecoders;i++) {
-		if (ezConfig.encoderDecoders[i]) {
-			if (ezConfig.encoderDecoders[i]->format) {
-				if (!strcmp(ezConfig.encoderDecoders[i]->format, format)) {
-					if (ezConfig.encoderDecoders[i]->encoder) {
-						return ezConfig.encoderDecoders[i]->encoder;
-					}
-					else {
-						return blankString;
-					}
-				}
-			}
+	int	i;
+
+	for (i = 0; i < ezConfig.numEncoderDecoders; i++) {
+		if (ezConfig.encoderDecoders[i] != NULL &&
+		    ezConfig.encoderDecoders[i]->format != NULL &&
+		    strcmp(ezConfig.encoderDecoders[i]->format, format) == 0) {
+			if (ezConfig.encoderDecoders[i]->encoder != NULL)
+				return (ezConfig.encoderDecoders[i]->encoder);
+			else
+				return (blankString);
 		}
 	}
-	return blankString;
+
+	return (blankString);
 }
 
-char*	getFormatDecoder(const char *match)
+char*
+getFormatDecoder(const char *match)
 {
-	int i = 0;
-	for (i=0;i<ezConfig.numEncoderDecoders;i++) {
-		if (ezConfig.encoderDecoders[i]) {
-			if (ezConfig.encoderDecoders[i]->match) {
-				if (!strcmp(ezConfig.encoderDecoders[i]->match, match)) {
-					if (ezConfig.encoderDecoders[i]->decoder) {
-						return ezConfig.encoderDecoders[i]->decoder;
-					}
-					else {
-						return blankString;
-					}
-				}
-			}
+	int	i;
+
+	for (i = 0; i < ezConfig.numEncoderDecoders; i++) {
+		if (ezConfig.encoderDecoders[i] != NULL &&
+		    ezConfig.encoderDecoders[i]->match != NULL &&
+		    strcmp(ezConfig.encoderDecoders[i]->match, match) == 0) {
+			if (ezConfig.encoderDecoders[i]->decoder != NULL)
+				return (ezConfig.encoderDecoders[i]->decoder);
+			else
+				return (blankString);
 		}
 	}
-	return blankString;
+
+	return (blankString);
 }
 
 int parseConfig(const char *fileName)



More information about the commits mailing list