Fossil SCM
Change the built-in "diff" so that it no longer ignores whitespace at the end of lines, as doing so confuses the "patch" command. Ticket [a9f7b23c2e376af5b0]
Commit
7f788bdb045c8e149fec1ab7f36b9a3faee8e3f8
Parent
32c9c47c93ea16a…
1 file changed
+4
-2
+4
-2
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -65,11 +65,13 @@ | ||
| 65 | 65 | /* |
| 66 | 66 | ** Return an array of DLine objects containing a pointer to the |
| 67 | 67 | ** start of each line and a hash of that line. The lower |
| 68 | 68 | ** bits of the hash store the length of each line. |
| 69 | 69 | ** |
| 70 | -** Trailing whitespace is removed from each line. | |
| 70 | +** Trailing whitespace is removed from each line. 2010-08-20: Not any | |
| 71 | +** more. If trailing whitespace is ignored, the "patch" command gets | |
| 72 | +** confused by the diff output. Ticket [a9f7b23c2e376af5b0e5b] | |
| 71 | 73 | ** |
| 72 | 74 | ** Return 0 if the file is binary or contains a line that is |
| 73 | 75 | ** too long. |
| 74 | 76 | */ |
| 75 | 77 | static DLine *break_into_lines(const char *z, int n, int *pnLine){ |
| @@ -102,11 +104,11 @@ | ||
| 102 | 104 | |
| 103 | 105 | /* Fill in the array */ |
| 104 | 106 | for(i=0; i<nLine; i++){ |
| 105 | 107 | a[i].z = z; |
| 106 | 108 | for(j=0; z[j] && z[j]!='\n'; j++){} |
| 107 | - for(k=j; k>0 && isspace(z[k-1]); k--){} | |
| 109 | + for(k=j; k>0 && isspace(z[k-1]); k--){break;} | |
| 108 | 110 | for(h=0, x=0; x<k; x++){ |
| 109 | 111 | h = h ^ (h<<2) ^ z[x]; |
| 110 | 112 | } |
| 111 | 113 | a[i].h = h = (h<<LENGTH_MASK_SZ) | k;; |
| 112 | 114 | h2 = h % nLine; |
| 113 | 115 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -65,11 +65,13 @@ | |
| 65 | /* |
| 66 | ** Return an array of DLine objects containing a pointer to the |
| 67 | ** start of each line and a hash of that line. The lower |
| 68 | ** bits of the hash store the length of each line. |
| 69 | ** |
| 70 | ** Trailing whitespace is removed from each line. |
| 71 | ** |
| 72 | ** Return 0 if the file is binary or contains a line that is |
| 73 | ** too long. |
| 74 | */ |
| 75 | static DLine *break_into_lines(const char *z, int n, int *pnLine){ |
| @@ -102,11 +104,11 @@ | |
| 102 | |
| 103 | /* Fill in the array */ |
| 104 | for(i=0; i<nLine; i++){ |
| 105 | a[i].z = z; |
| 106 | for(j=0; z[j] && z[j]!='\n'; j++){} |
| 107 | for(k=j; k>0 && isspace(z[k-1]); k--){} |
| 108 | for(h=0, x=0; x<k; x++){ |
| 109 | h = h ^ (h<<2) ^ z[x]; |
| 110 | } |
| 111 | a[i].h = h = (h<<LENGTH_MASK_SZ) | k;; |
| 112 | h2 = h % nLine; |
| 113 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -65,11 +65,13 @@ | |
| 65 | /* |
| 66 | ** Return an array of DLine objects containing a pointer to the |
| 67 | ** start of each line and a hash of that line. The lower |
| 68 | ** bits of the hash store the length of each line. |
| 69 | ** |
| 70 | ** Trailing whitespace is removed from each line. 2010-08-20: Not any |
| 71 | ** more. If trailing whitespace is ignored, the "patch" command gets |
| 72 | ** confused by the diff output. Ticket [a9f7b23c2e376af5b0e5b] |
| 73 | ** |
| 74 | ** Return 0 if the file is binary or contains a line that is |
| 75 | ** too long. |
| 76 | */ |
| 77 | static DLine *break_into_lines(const char *z, int n, int *pnLine){ |
| @@ -102,11 +104,11 @@ | |
| 104 | |
| 105 | /* Fill in the array */ |
| 106 | for(i=0; i<nLine; i++){ |
| 107 | a[i].z = z; |
| 108 | for(j=0; z[j] && z[j]!='\n'; j++){} |
| 109 | for(k=j; k>0 && isspace(z[k-1]); k--){break;} |
| 110 | for(h=0, x=0; x<k; x++){ |
| 111 | h = h ^ (h<<2) ^ z[x]; |
| 112 | } |
| 113 | a[i].h = h = (h<<LENGTH_MASK_SZ) | k;; |
| 114 | h2 = h % nLine; |
| 115 |