bug-diffutils
[Top][All Lists]
Advanced

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

[bug-diffutils] diff -p finds wrong function name


From: Tim Chase
Subject: [bug-diffutils] diff -p finds wrong function name
Date: Tue, 21 Aug 2012 13:13:16 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16

According to the man/info pages for diff, "-p" should "Show which C
function each change is in."  However, if the function definition is
within the output context, it searches for the *previous* function.
 Reproducible with the following:

===============================
$ cat > one.c <<EOF
int call_me(int maybe)
{
  return maybe;
}

int main()
{
  return 0;
}
EOF
$ sed s/0/1/ one.c > two.c
$ diff -pu one.c two.c
--- one.c       2012-08-21 12:56:14.446205916 -0500
+++ two.c       2012-08-21 13:06:16.454205832 -0500
@@ -5,5 +5,5 @@ int call_me(int maybe)

 int main()
 {
-  return 0;
+  return 1;
 }
$ # how does adding "-p" change the output?
$ diff <(diff -u one.c two) <(diff -pu one.c two.c)
3c3
< @@ -5,5 +5,4 @@
---
> @@ -5,5 +5,4 @@ int call_me(int maybe)
$ diff --version | head -1 # in Debian Stable
diff (GNU diffutils) 3.0
===============================

The edit was made in main(), but diff finds/shows call_me() as the
containing function name.  FWIW, the same happens with context
rather than unified diffs.

-tkc








reply via email to

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