bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

unified diff bug or intended behaviour?


From: Tom Rodriguez
Subject: unified diff bug or intended behaviour?
Date: Wed, 29 Oct 2003 15:08:06 -0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

When running in unified diff mode, if a line reports no difference then the output is taken from files[0] which seems like a reasonable choice since it should be the same as files[1]. However if you are running with -b or -w or any of the other ignore options, the output ends up looking a bit funny because the unchanged lines may actually be different. This may make it appear, for example, that the indentation of the unchanged lines is wrong. Here's an example of what I mean.

smite share/vm/opto % cat old.c
int f(int a, int b) {
  if (a == b) {
    return 4;
  }
}
smite share/vm/opto % cat new.c
int f(int a, int b) {
  if (a + 4 > b) {
    if (a == b) {
      return 4;
    }
    return 5;
  }
  return 0;
}
smite share/vm/opto % gnudiff -bwU 10 old.c new.c
--- old.c       2003-10-29 14:33:57.035417000 -0800
+++ new.c       2003-10-29 14:35:45.085418000 -0800
@@ -1,5 +1,9 @@
 int f(int a, int b) {
+  if (a + 4 > b) {
   if (a == b) {
     return 4;
   }
+    return 5;
+  }
+  return 0;
 }

This would be easy to fix by changing pr_unidiff_hunk to print from files[1] instead of files[0] for the unchanged part. Thanks!

tom








reply via email to

[Prev in Thread] Current Thread [Next in Thread]