Skip to contentSkip to conversation

xdiff: Do not consider lines starting by # hunkworthy

PATCH In review Petr Baudis 4 participants 6 messages Aug 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xdiff: Do not consider lines starting by # hunkworthy

This will be probably controversial but in my personal experience, the amount of time this is the right thing to do because of #defines is negligible compared to amount of time it is wrong, especially because of #ifs and #endifs in the middle of functions and also because of comments at the line start when it concerns non-C files.

---

 xdiff/xemit.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
xdiff/xemit.c +1 -2
index 714c563..4f20075 100644
@@ -86,8 +86,7 @@ static void xdl_find_func(xdfile_t *xf, 
 		if (len > 0 &&
 		    (isalpha((unsigned char)*rec) || /* identifier? */
 		     *rec == '_' ||	/* also identifier? */
-		     *rec == '(' ||	/* lisp defun? */
-		     *rec == '#')) {	/* #define? */
+		     *rec == '(')) {	/* #define? */
 			if (len > sz)
 				len = sz;
#1 lore raw
Quoted 17 lines · Petr Baudis

This will be probably controversial but in my personal experience, the amount of time this is the right thing to do because of #defines is negligible compared to amount of time it is wrong, especially because of #ifs and #endifs in the middle of functions and also because of comments at the line start when it concerns non-C files.

---

 xdiff/xemit.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
xdiff/xemit.c +0 -0
index 714c563..4f20075 100644

xdiff/xemit.c static void xdl_find_func(xdfile_t *xf, · line 92

Quoted 9 lines
xdiff/xemit.c +1 -2
@@ -86,8 +86,7 @@ static void xdl_find_func(xdfile_t *xf, 
 		if (len > 0 &&
 		    (isalpha((unsigned char)*rec) || /* identifier? */
 		     *rec == '_' ||	/* also identifier? */
-		     *rec == '(' ||	/* lisp defun? */
-		     *rec == '#')) {	/* #define? */
+		     *rec == '(')) {	/* #define? */
 			if (len > sz)
 				len = sz;
 			if (len && rec[len - 1] == '\n')

I'd either omit the opening parenthesis or fix the comment ;-).

More seriously, I'd rather just match default GNU diff behaviour to use isalpha, underscore or '$'. I do not particularly like to have '$' but I feel it is the easiest to match a prior art in cases like this because I do not have to defend my position when somebody says "Why do you include '#'??? It makes no sense!". Since I do not care too much about it, being able to just say "Well we match what GNU diff does by default." is a good thing.

#2 lore raw

PATCH 1/1 xdiff: Match GNU diff behaviour when deciding hunk comment worthiness of lines

This removes the '#' and '(' tests and adds a '$' test instead although I have no idea what it is actually good for - but hey, if that's what GNU diff does...

Pasky only went and did as Junio sayeth.

---

 xdiff/xemit.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
xdiff/xemit.c +1 -2
index 714c563..4139d55 100644
@@ -86,8 +86,7 @@ static void xdl_find_func(xdfile_t *xf, 
 		if (len > 0 &&
 		    (isalpha((unsigned char)*rec) || /* identifier? */
 		     *rec == '_' ||	/* also identifier? */
-		     *rec == '(' ||	/* lisp defun? */
-		     *rec == '#')) {	/* #define? */
+		     *rec == '$')) {	/* mysterious GNU diff's invention */
 			if (len > sz)
 				len = sz;
#3 lore raw

Re: [PATCH] xdiff: Match GNU diff behaviour when deciding hunk comment worthiness of lines

Quoted 3 lines · Petr Baudis

This removes the '#' and '(' tests and adds a '$' test instead although I have no idea what it is actually good for - but hey, if that's what GNU diff does...

$ starts a shell (or Perl) variable...
Quoted 1 line

Pasky only went and did as Junio sayeth.

Horst adds a guesse...

Signature · 3 lines
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                    Fono: +56 32 2654431
Universidad Tecnica Federico Santa Maria             +56 32 2654239
#4 lore raw

Re: [PATCH] xdiff: Match GNU diff behaviour when deciding hunk comment worthiness of lines

Quoted 10 lines · Horst H. von Brand
Quoted 3 lines · Petr Baudis

This removes the '#' and '(' tests and adds a '$' test instead although I have no idea what it is actually good for - but hey, if that's what GNU diff does...

$ starts a shell (or Perl) variable...
Quoted 1 line

Pasky only went and did as Junio sayeth.

Horst adds a guesse...

If I have to guess, I think that is from VMS.

#5 lore raw
In reply to Petr Baudis
Quoted 4 lines · Petr Baudis

-                    *rec == '(' ||     /* lisp defun? */ -                    *rec == '#')) {    /* #define? */ +                    *rec == '(')) {    /* #define? */ if (len > sz)

Shouldn't it be:

+ *rec == '(')) { /* lisp defun? */

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git