Fossil SCM
Add chunk number fragment marks to HTML diff output.
Commit
b1530c29ab659a56f488e4386f242eb758858f22
Parent
469462b69a56007…
1 file changed
+8
-1
+8
-1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -237,10 +237,11 @@ | ||
| 237 | 237 | int mxr; /* Maximum value for r */ |
| 238 | 238 | int na, nb; /* Number of lines shown from A and B */ |
| 239 | 239 | int i, j; /* Loop counters */ |
| 240 | 240 | int m; /* Number of lines to output */ |
| 241 | 241 | int skip; /* Number of lines to skip */ |
| 242 | + int nChunk = 0; /* Number of diff chunks seen so far */ | |
| 242 | 243 | |
| 243 | 244 | A = p->aFrom; |
| 244 | 245 | B = p->aTo; |
| 245 | 246 | R = p->aEdit; |
| 246 | 247 | mxr = p->nEdit; |
| @@ -278,15 +279,17 @@ | ||
| 278 | 279 | |
| 279 | 280 | /* Show the header for this block, or if we are doing a modified |
| 280 | 281 | ** context diff that contains line numbers, show the separate from |
| 281 | 282 | ** the previous block. |
| 282 | 283 | */ |
| 284 | + nChunk++; | |
| 283 | 285 | if( showLn ){ |
| 284 | 286 | if( r==0 ){ |
| 285 | 287 | /* Do not show a top divider */ |
| 286 | 288 | }else if( html ){ |
| 287 | 289 | blob_appendf(pOut, "<span class=\"diffhr\">%.80c</span>\n", '.'); |
| 290 | + blob_appendf(pOut, "<a name=\"chunk%d\"></a>\n", nChunk); | |
| 288 | 291 | }else{ |
| 289 | 292 | blob_appendf(pOut, "%.80c\n", '.'); |
| 290 | 293 | } |
| 291 | 294 | }else{ |
| 292 | 295 | if( html ) blob_appendf(pOut, "<span class=\"diffln\">"); |
| @@ -471,11 +474,10 @@ | ||
| 471 | 474 | ){ |
| 472 | 475 | int nLeft; /* Length of left line in bytes */ |
| 473 | 476 | int nRight; /* Length of right line in bytes */ |
| 474 | 477 | int nPrefix; /* Length of common prefix */ |
| 475 | 478 | int nSuffix; /* Length of common suffix */ |
| 476 | - int width; /* Total column width */ | |
| 477 | 479 | const char *zLeft; /* Text of the left line */ |
| 478 | 480 | const char *zRight; /* Text of the right line */ |
| 479 | 481 | |
| 480 | 482 | nLeft = pLeft->h & LENGTH_MASK; |
| 481 | 483 | zLeft = pLeft->z; |
| @@ -697,10 +699,11 @@ | ||
| 697 | 699 | int mxr; /* Maximum value for r */ |
| 698 | 700 | int na, nb; /* Number of lines shown from A and B */ |
| 699 | 701 | int i, j; /* Loop counters */ |
| 700 | 702 | int m, ma, mb;/* Number of lines to output */ |
| 701 | 703 | int skip; /* Number of lines to skip */ |
| 704 | + int nChunk = 0; /* Number of chunks of diff output seen so far */ | |
| 702 | 705 | SbsLine s; /* Output line buffer */ |
| 703 | 706 | |
| 704 | 707 | s.zLine = fossil_malloc( 10*width + 100 ); |
| 705 | 708 | if( s.zLine==0 ) return; |
| 706 | 709 | s.width = width; |
| @@ -750,10 +753,14 @@ | ||
| 750 | 753 | width*2+16, '.'); |
| 751 | 754 | }else{ |
| 752 | 755 | blob_appendf(pOut, "%.*c\n", width*2+16, '.'); |
| 753 | 756 | } |
| 754 | 757 | } |
| 758 | + nChunk++; | |
| 759 | + if( escHtml ){ | |
| 760 | + blob_appendf(pOut, "<a name=\"chunk%d\"></a>\n", nChunk); | |
| 761 | + } | |
| 755 | 762 | |
| 756 | 763 | /* Show the initial common area */ |
| 757 | 764 | a += skip; |
| 758 | 765 | b += skip; |
| 759 | 766 | m = R[r] - skip; |
| 760 | 767 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -237,10 +237,11 @@ | |
| 237 | int mxr; /* Maximum value for r */ |
| 238 | int na, nb; /* Number of lines shown from A and B */ |
| 239 | int i, j; /* Loop counters */ |
| 240 | int m; /* Number of lines to output */ |
| 241 | int skip; /* Number of lines to skip */ |
| 242 | |
| 243 | A = p->aFrom; |
| 244 | B = p->aTo; |
| 245 | R = p->aEdit; |
| 246 | mxr = p->nEdit; |
| @@ -278,15 +279,17 @@ | |
| 278 | |
| 279 | /* Show the header for this block, or if we are doing a modified |
| 280 | ** context diff that contains line numbers, show the separate from |
| 281 | ** the previous block. |
| 282 | */ |
| 283 | if( showLn ){ |
| 284 | if( r==0 ){ |
| 285 | /* Do not show a top divider */ |
| 286 | }else if( html ){ |
| 287 | blob_appendf(pOut, "<span class=\"diffhr\">%.80c</span>\n", '.'); |
| 288 | }else{ |
| 289 | blob_appendf(pOut, "%.80c\n", '.'); |
| 290 | } |
| 291 | }else{ |
| 292 | if( html ) blob_appendf(pOut, "<span class=\"diffln\">"); |
| @@ -471,11 +474,10 @@ | |
| 471 | ){ |
| 472 | int nLeft; /* Length of left line in bytes */ |
| 473 | int nRight; /* Length of right line in bytes */ |
| 474 | int nPrefix; /* Length of common prefix */ |
| 475 | int nSuffix; /* Length of common suffix */ |
| 476 | int width; /* Total column width */ |
| 477 | const char *zLeft; /* Text of the left line */ |
| 478 | const char *zRight; /* Text of the right line */ |
| 479 | |
| 480 | nLeft = pLeft->h & LENGTH_MASK; |
| 481 | zLeft = pLeft->z; |
| @@ -697,10 +699,11 @@ | |
| 697 | int mxr; /* Maximum value for r */ |
| 698 | int na, nb; /* Number of lines shown from A and B */ |
| 699 | int i, j; /* Loop counters */ |
| 700 | int m, ma, mb;/* Number of lines to output */ |
| 701 | int skip; /* Number of lines to skip */ |
| 702 | SbsLine s; /* Output line buffer */ |
| 703 | |
| 704 | s.zLine = fossil_malloc( 10*width + 100 ); |
| 705 | if( s.zLine==0 ) return; |
| 706 | s.width = width; |
| @@ -750,10 +753,14 @@ | |
| 750 | width*2+16, '.'); |
| 751 | }else{ |
| 752 | blob_appendf(pOut, "%.*c\n", width*2+16, '.'); |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | /* Show the initial common area */ |
| 757 | a += skip; |
| 758 | b += skip; |
| 759 | m = R[r] - skip; |
| 760 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -237,10 +237,11 @@ | |
| 237 | int mxr; /* Maximum value for r */ |
| 238 | int na, nb; /* Number of lines shown from A and B */ |
| 239 | int i, j; /* Loop counters */ |
| 240 | int m; /* Number of lines to output */ |
| 241 | int skip; /* Number of lines to skip */ |
| 242 | int nChunk = 0; /* Number of diff chunks seen so far */ |
| 243 | |
| 244 | A = p->aFrom; |
| 245 | B = p->aTo; |
| 246 | R = p->aEdit; |
| 247 | mxr = p->nEdit; |
| @@ -278,15 +279,17 @@ | |
| 279 | |
| 280 | /* Show the header for this block, or if we are doing a modified |
| 281 | ** context diff that contains line numbers, show the separate from |
| 282 | ** the previous block. |
| 283 | */ |
| 284 | nChunk++; |
| 285 | if( showLn ){ |
| 286 | if( r==0 ){ |
| 287 | /* Do not show a top divider */ |
| 288 | }else if( html ){ |
| 289 | blob_appendf(pOut, "<span class=\"diffhr\">%.80c</span>\n", '.'); |
| 290 | blob_appendf(pOut, "<a name=\"chunk%d\"></a>\n", nChunk); |
| 291 | }else{ |
| 292 | blob_appendf(pOut, "%.80c\n", '.'); |
| 293 | } |
| 294 | }else{ |
| 295 | if( html ) blob_appendf(pOut, "<span class=\"diffln\">"); |
| @@ -471,11 +474,10 @@ | |
| 474 | ){ |
| 475 | int nLeft; /* Length of left line in bytes */ |
| 476 | int nRight; /* Length of right line in bytes */ |
| 477 | int nPrefix; /* Length of common prefix */ |
| 478 | int nSuffix; /* Length of common suffix */ |
| 479 | const char *zLeft; /* Text of the left line */ |
| 480 | const char *zRight; /* Text of the right line */ |
| 481 | |
| 482 | nLeft = pLeft->h & LENGTH_MASK; |
| 483 | zLeft = pLeft->z; |
| @@ -697,10 +699,11 @@ | |
| 699 | int mxr; /* Maximum value for r */ |
| 700 | int na, nb; /* Number of lines shown from A and B */ |
| 701 | int i, j; /* Loop counters */ |
| 702 | int m, ma, mb;/* Number of lines to output */ |
| 703 | int skip; /* Number of lines to skip */ |
| 704 | int nChunk = 0; /* Number of chunks of diff output seen so far */ |
| 705 | SbsLine s; /* Output line buffer */ |
| 706 | |
| 707 | s.zLine = fossil_malloc( 10*width + 100 ); |
| 708 | if( s.zLine==0 ) return; |
| 709 | s.width = width; |
| @@ -750,10 +753,14 @@ | |
| 753 | width*2+16, '.'); |
| 754 | }else{ |
| 755 | blob_appendf(pOut, "%.*c\n", width*2+16, '.'); |
| 756 | } |
| 757 | } |
| 758 | nChunk++; |
| 759 | if( escHtml ){ |
| 760 | blob_appendf(pOut, "<a name=\"chunk%d\"></a>\n", nChunk); |
| 761 | } |
| 762 | |
| 763 | /* Show the initial common area */ |
| 764 | a += skip; |
| 765 | b += skip; |
| 766 | m = R[r] - skip; |
| 767 |