Fossil SCM

Fixes to the --tk diff option to support unified diff on Windows.

mistachkin 2012-09-27 01:38 trunk
Commit 1048bccf14a3da71326b9f7b9fe18def643834de
2 files changed +9 -1 +1 -1
+9 -1
--- src/diff.c
+++ src/diff.c
@@ -174,19 +174,24 @@
174174
Blob *pOut, /* Where to write the line of output */
175175
char cPrefix, /* One of " ", "+", or "-" */
176176
DLine *pLine, /* The line to be output */
177177
int html /* True if generating HTML. False for plain text */
178178
){
179
+ int i;
179180
blob_append(pOut, &cPrefix, 1);
180181
if( html ){
181182
char *zHtml;
182183
if( cPrefix=='+' ){
183184
blob_append(pOut, "<span class=\"diffadd\">", -1);
184185
}else if( cPrefix=='-' ){
185186
blob_append(pOut, "<span class=\"diffrm\">", -1);
186187
}
187188
zHtml = htmlize(pLine->z, (pLine->h & LENGTH_MASK));
189
+ for(i=0; i<strlen(zHtml); i++){
190
+ char c = zHtml[i];
191
+ if( c=='\t' || c=='\r' || c=='\f' ) zHtml[i] = ' ';
192
+ }
188193
blob_append(pOut, zHtml, -1);
189194
fossil_free(zHtml);
190195
if( cPrefix!=' ' ){
191196
blob_append(pOut, "</span>", -1);
192197
}
@@ -429,10 +434,13 @@
429434
memcpy(&z[j], "&amp;", 5);
430435
j += 5;
431436
}else if( c=='>' && p->escHtml ){
432437
memcpy(&z[j], "&gt;", 4);
433438
j += 4;
439
+ }else if( c=='"' && p->escHtml ){
440
+ memcpy(&z[j], "&quot;", 6);
441
+ j += 6;
434442
}else{
435443
z[j++] = c;
436444
if( (c&0xc0)==0x80 ) k--;
437445
}
438446
}
@@ -448,11 +456,11 @@
448456
}
449457
p->n += j;
450458
}
451459
452460
/*
453
-** Append a string to an SbSLine with coding, interpretation, or padding.
461
+** Append a string to an SbSLine without coding, interpretation, or padding.
454462
*/
455463
static void sbsWrite(SbsLine *p, const char *zIn, int nIn){
456464
memcpy(p->zLine+p->n, zIn, nIn);
457465
p->n += nIn;
458466
}
459467
--- src/diff.c
+++ src/diff.c
@@ -174,19 +174,24 @@
174 Blob *pOut, /* Where to write the line of output */
175 char cPrefix, /* One of " ", "+", or "-" */
176 DLine *pLine, /* The line to be output */
177 int html /* True if generating HTML. False for plain text */
178 ){
 
179 blob_append(pOut, &cPrefix, 1);
180 if( html ){
181 char *zHtml;
182 if( cPrefix=='+' ){
183 blob_append(pOut, "<span class=\"diffadd\">", -1);
184 }else if( cPrefix=='-' ){
185 blob_append(pOut, "<span class=\"diffrm\">", -1);
186 }
187 zHtml = htmlize(pLine->z, (pLine->h & LENGTH_MASK));
 
 
 
 
188 blob_append(pOut, zHtml, -1);
189 fossil_free(zHtml);
190 if( cPrefix!=' ' ){
191 blob_append(pOut, "</span>", -1);
192 }
@@ -429,10 +434,13 @@
429 memcpy(&z[j], "&amp;", 5);
430 j += 5;
431 }else if( c=='>' && p->escHtml ){
432 memcpy(&z[j], "&gt;", 4);
433 j += 4;
 
 
 
434 }else{
435 z[j++] = c;
436 if( (c&0xc0)==0x80 ) k--;
437 }
438 }
@@ -448,11 +456,11 @@
448 }
449 p->n += j;
450 }
451
452 /*
453 ** Append a string to an SbSLine with coding, interpretation, or padding.
454 */
455 static void sbsWrite(SbsLine *p, const char *zIn, int nIn){
456 memcpy(p->zLine+p->n, zIn, nIn);
457 p->n += nIn;
458 }
459
--- src/diff.c
+++ src/diff.c
@@ -174,19 +174,24 @@
174 Blob *pOut, /* Where to write the line of output */
175 char cPrefix, /* One of " ", "+", or "-" */
176 DLine *pLine, /* The line to be output */
177 int html /* True if generating HTML. False for plain text */
178 ){
179 int i;
180 blob_append(pOut, &cPrefix, 1);
181 if( html ){
182 char *zHtml;
183 if( cPrefix=='+' ){
184 blob_append(pOut, "<span class=\"diffadd\">", -1);
185 }else if( cPrefix=='-' ){
186 blob_append(pOut, "<span class=\"diffrm\">", -1);
187 }
188 zHtml = htmlize(pLine->z, (pLine->h & LENGTH_MASK));
189 for(i=0; i<strlen(zHtml); i++){
190 char c = zHtml[i];
191 if( c=='\t' || c=='\r' || c=='\f' ) zHtml[i] = ' ';
192 }
193 blob_append(pOut, zHtml, -1);
194 fossil_free(zHtml);
195 if( cPrefix!=' ' ){
196 blob_append(pOut, "</span>", -1);
197 }
@@ -429,10 +434,13 @@
434 memcpy(&z[j], "&amp;", 5);
435 j += 5;
436 }else if( c=='>' && p->escHtml ){
437 memcpy(&z[j], "&gt;", 4);
438 j += 4;
439 }else if( c=='"' && p->escHtml ){
440 memcpy(&z[j], "&quot;", 6);
441 j += 6;
442 }else{
443 z[j++] = c;
444 if( (c&0xc0)==0x80 ) k--;
445 }
446 }
@@ -448,11 +456,11 @@
456 }
457 p->n += j;
458 }
459
460 /*
461 ** Append a string to an SbSLine without coding, interpretation, or padding.
462 */
463 static void sbsWrite(SbsLine *p, const char *zIn, int nIn){
464 memcpy(p->zLine+p->n, zIn, nIn);
465 p->n += nIn;
466 }
467
+1 -1
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -510,11 +510,11 @@
510510
@ set line $tail
511511
@ }
512512
@ .t insert end [dehtml $line]\n {}
513513
@ }
514514
@ close $in
515
-@ if {$mx>250} {set mx 250} ;# Limit window width to 200 lines
515
+@ if {$mx>250} {set mx 250} ;# Limit window width to 200 characters
516516
@ if {$nLine>55} {set nLine 55} ;# Limit window height to 55 lines
517517
@ .t config -height $nLine -width $mx
518518
@ pack .t -side left -fill both -expand 1
519519
@ scrollbar .sb -command {.t yview} -orient vertical
520520
@ pack .sb -side left -fill y
521521
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -510,11 +510,11 @@
510 @ set line $tail
511 @ }
512 @ .t insert end [dehtml $line]\n {}
513 @ }
514 @ close $in
515 @ if {$mx>250} {set mx 250} ;# Limit window width to 200 lines
516 @ if {$nLine>55} {set nLine 55} ;# Limit window height to 55 lines
517 @ .t config -height $nLine -width $mx
518 @ pack .t -side left -fill both -expand 1
519 @ scrollbar .sb -command {.t yview} -orient vertical
520 @ pack .sb -side left -fill y
521
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -510,11 +510,11 @@
510 @ set line $tail
511 @ }
512 @ .t insert end [dehtml $line]\n {}
513 @ }
514 @ close $in
515 @ if {$mx>250} {set mx 250} ;# Limit window width to 200 characters
516 @ if {$nLine>55} {set nLine 55} ;# Limit window height to 55 lines
517 @ .t config -height $nLine -width $mx
518 @ pack .t -side left -fill both -expand 1
519 @ scrollbar .sb -command {.t yview} -orient vertical
520 @ pack .sb -side left -fill y
521

Keyboard Shortcuts

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