svn commit: trunk/busybox/editors

vda at busybox.net vda at busybox.net
Mon Mar 24 16:28:48 UTC 2008


Author: vda
Date: 2008-03-24 09:28:47 -0700 (Mon, 24 Mar 2008)
New Revision: 21470

Log:
diff: fix small bug; don't make a copy for "/dev/null" case



Modified:
   trunk/busybox/editors/diff.c


Changeset:
Modified: trunk/busybox/editors/diff.c
===================================================================
--- trunk/busybox/editors/diff.c	2008-03-24 16:19:21 UTC (rev 21469)
+++ trunk/busybox/editors/diff.c	2008-03-24 16:28:47 UTC (rev 21470)
@@ -283,7 +283,7 @@
 	char *name;
 	int fd;
 
-	if (S_ISREG(sb->st_mode))
+	if (S_ISREG(sb->st_mode) || S_ISBLK(sb->st_mode))
 		return NULL;
 	name = xstrdup("/tmp/difXXXXXX");
 	fd = mkstemp(name);
@@ -312,9 +312,15 @@
 {
 	size_t i, j;
 
+	/* Prevent making copies for "/dev/null" (too common) */
+	tempname1 = tempname2 = NULL;
+	if (flags & (D_EMPTY1 | D_EMPTY2)) {
+		return 1;
+	}
+	/* Deal with input from pipes etc */
 	tempname1 = make_temp(f1, &stb1);
 	tempname2 = make_temp(f2, &stb2);
-	if ((flags & (D_EMPTY1 | D_EMPTY2)) || stb1.st_size != stb2.st_size) {
+	if (stb1.st_size != stb2.st_size) {
 		return 1;
 	}
 	while (1) {
@@ -631,8 +637,8 @@
 					J[i] = 0;
 					if (c != '\n' && c != EOF)
 						ctold += skipline(f1);
-// BUG? Should be "if (d != '\n' && d != EOF)" ?
-					if (d != '\n' && c != EOF)
+/* was buggy? "if (d != '\n' && c != EOF)" */
+					if (d != '\n' && d != EOF)
 						ctnew += skipline(f2);
 					break;
 				}




More information about the busybox-cvs mailing list