Fossil SCM

Add chunk number fragment marks to HTML diff output.

drh 2012-02-07 04:15 trunk
Commit b1530c29ab659a56f488e4386f242eb758858f22
1 file changed +8 -1
+8 -1
--- src/diff.c
+++ src/diff.c
@@ -237,10 +237,11 @@
237237
int mxr; /* Maximum value for r */
238238
int na, nb; /* Number of lines shown from A and B */
239239
int i, j; /* Loop counters */
240240
int m; /* Number of lines to output */
241241
int skip; /* Number of lines to skip */
242
+ int nChunk = 0; /* Number of diff chunks seen so far */
242243
243244
A = p->aFrom;
244245
B = p->aTo;
245246
R = p->aEdit;
246247
mxr = p->nEdit;
@@ -278,15 +279,17 @@
278279
279280
/* Show the header for this block, or if we are doing a modified
280281
** context diff that contains line numbers, show the separate from
281282
** the previous block.
282283
*/
284
+ nChunk++;
283285
if( showLn ){
284286
if( r==0 ){
285287
/* Do not show a top divider */
286288
}else if( html ){
287289
blob_appendf(pOut, "<span class=\"diffhr\">%.80c</span>\n", '.');
290
+ blob_appendf(pOut, "<a name=\"chunk%d\"></a>\n", nChunk);
288291
}else{
289292
blob_appendf(pOut, "%.80c\n", '.');
290293
}
291294
}else{
292295
if( html ) blob_appendf(pOut, "<span class=\"diffln\">");
@@ -471,11 +474,10 @@
471474
){
472475
int nLeft; /* Length of left line in bytes */
473476
int nRight; /* Length of right line in bytes */
474477
int nPrefix; /* Length of common prefix */
475478
int nSuffix; /* Length of common suffix */
476
- int width; /* Total column width */
477479
const char *zLeft; /* Text of the left line */
478480
const char *zRight; /* Text of the right line */
479481
480482
nLeft = pLeft->h & LENGTH_MASK;
481483
zLeft = pLeft->z;
@@ -697,10 +699,11 @@
697699
int mxr; /* Maximum value for r */
698700
int na, nb; /* Number of lines shown from A and B */
699701
int i, j; /* Loop counters */
700702
int m, ma, mb;/* Number of lines to output */
701703
int skip; /* Number of lines to skip */
704
+ int nChunk = 0; /* Number of chunks of diff output seen so far */
702705
SbsLine s; /* Output line buffer */
703706
704707
s.zLine = fossil_malloc( 10*width + 100 );
705708
if( s.zLine==0 ) return;
706709
s.width = width;
@@ -750,10 +753,14 @@
750753
width*2+16, '.');
751754
}else{
752755
blob_appendf(pOut, "%.*c\n", width*2+16, '.');
753756
}
754757
}
758
+ nChunk++;
759
+ if( escHtml ){
760
+ blob_appendf(pOut, "<a name=\"chunk%d\"></a>\n", nChunk);
761
+ }
755762
756763
/* Show the initial common area */
757764
a += skip;
758765
b += skip;
759766
m = R[r] - skip;
760767
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button