[BusyBox-cvs] svn commit: trunk/busybox/coreutils

vapier at busybox.net vapier at busybox.net
Thu May 12 22:50:13 UTC 2005


Author: vapier
Date: 2005-05-12 16:50:12 -0600 (Thu, 12 May 2005)
New Revision: 10317

Log:
use a bunch of if statements since it is a few bytes smaller than a switch; also use bb_xfopen() instead of fopen() so comm doesnt segfault when given non-existant files :(

Modified:
   trunk/busybox/coreutils/comm.c


Changeset:
Modified: trunk/busybox/coreutils/comm.c
===================================================================
--- trunk/busybox/coreutils/comm.c	2005-05-12 22:41:13 UTC (rev 10316)
+++ trunk/busybox/coreutils/comm.c	2005-05-12 22:50:12 UTC (rev 10317)
@@ -40,26 +40,22 @@
 /* writeline outputs the input given, appropriately aligned according to class */
 static void writeline(char *line, int class)
 {
-	switch (class) {
-		case 1:
-			if (!only_file_1)
-				return;
-			break;
-		case 2:
-			if (!only_file_2)
-				return;
-			if (only_file_1)
-				putchar('\t');
-			break;
-		case 3:
-			if (!both)
-				return;
-			if (only_file_1)
-				putchar('\t');
-			if (only_file_2)
-				putchar('\t');
-			break;
+	if (class == 1 && !only_file_1)
+		return;
+	else if (class == 2) {
+		if (!only_file_2)
+			return;
+		if (only_file_1)
+			putchar('\t');
 	}
+	else if (class == 3) {
+		if (!both)
+			return;
+		if (only_file_1)
+			putchar('\t');
+		if (only_file_2)
+			putchar('\t');
+	}
 	fputs(line, stdout);
 }
 
@@ -71,7 +67,7 @@
 	int i = 0;
 
 	for (i = 0; i < 2; i++) {
-		streams[i] = (strcmp(infiles[i], "=") == 0 ? stdin : fopen(infiles[i], "r"));
+		streams[i] = (strcmp(infiles[i], "=") == 0 ? stdin : bb_xfopen(infiles[i], "r"));
 		fgets(thisline[i], 100, streams[i]);
 	}
 




More information about the busybox-cvs mailing list