I did a few experiments and it seems to me, that GNU diff's -p option already does what you want. Can you check the following example to see if it does what you require (the entities are in the lines marked with ************** at the end of this mail).
Example: File old.c:
struct this
{
int x;
long y;
short z;
};
union that
{
char a;
unsigned char b;
signed char c;
};
static struct this foo;
int
main (int argc, char **argv)
{
/* A comment */
/* Another comment */
return 0;
}
And File new.c:
struct this
{
int x;
long y;
short z;
char n;
};
union that
{
char a;
unsigned char b;
signed char c;
void *ppp;
};
static struct this foo;
int
main (int argc, char **argv)
{
/* A comment */
/* Another comment */
int xx;
return 0;
}
When compared using diff -p old.c new.c gives:
*** old.c Thu May 17 16:39:13 2018
--- new.c Thu May 17 16:39:34 2018
*************** struct this
*** 3,8 ****
--- 3,10 ----
int x;
long y;
short z;
+
+ char n;
};
*************** union that
*** 11,16 ****
--- 13,19 ----
char a;
unsigned char b;
signed char c;
+ void *ppp;
};
*************** main (int argc, char **argv)
*** 21,25 ****
--- 24,29 ----
{
/* A comment */
/* Another comment */
+ int xx;
return 0;
}
signature.asc
Description: Digital signature
