[git commit master] diff: correct handling of labels. -10 bytes

Denys Vlasenko vda.linux at googlemail.com
Wed Jan 20 01:46:39 UTC 2010


commit: http://git.busybox.net/busybox/commit/?id=4de4cb6b9ba294b47ffbaa8646f7ebe4cb8db3c9
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

>>From 05eeb173f0431b4fbed7684d7a9cea42f747f63e Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux at googlemail.com>
Date: Wed, 20 Jan 2010 02:46:39 +0100
Subject: [PATCH] diff: correct handling of labels

This fixes an issue where diff would apply labels to files in the
inverse order, when using -L or --label.
This fixes it in order to be compatible with gnu diff.
It also makes it not an error to specify more than one label.
The behavior for such cases is that they override the label for the new
file.

Signed-off-by: Matheus Izvekov <mizvekov at gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 editors/diff.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/editors/diff.c b/editors/diff.c
index 9d0373f..7429b41 100644
--- a/editors/diff.c
+++ b/editors/diff.c
@@ -915,13 +915,8 @@ int diff_main(int argc UNUSED_PARAM, char **argv)
 	getopt32(argv, "abdiL:NqrsS:tTU:wupBE",
 			&L_arg, &s_start, &opt_U_context);
 	argv += optind;
-	while (L_arg) {
-		if (label[0] && label[1])
-			bb_show_usage();
-		if (label[0]) /* then label[1] is NULL */
-			label[1] = label[0];
-		label[0] = llist_pop(&L_arg);
-	}
+	while (L_arg)
+		label[!!label[0]] = llist_pop(&L_arg);
 	xfunc_error_retval = 2;
 	for (int i = 0; i < 2; i++) {
 		file[i] = argv[i];
-- 
1.6.3.3



More information about the busybox-cvs mailing list