Fossil SCM
Fixes to the --tk diff option to support unified diff on Windows.
Commit
1048bccf14a3da71326b9f7b9fe18def643834de
Parent
5be507df71828bf…
2 files changed
+9
-1
+1
-1
+9
-1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -174,19 +174,24 @@ | ||
| 174 | 174 | Blob *pOut, /* Where to write the line of output */ |
| 175 | 175 | char cPrefix, /* One of " ", "+", or "-" */ |
| 176 | 176 | DLine *pLine, /* The line to be output */ |
| 177 | 177 | int html /* True if generating HTML. False for plain text */ |
| 178 | 178 | ){ |
| 179 | + int i; | |
| 179 | 180 | blob_append(pOut, &cPrefix, 1); |
| 180 | 181 | if( html ){ |
| 181 | 182 | char *zHtml; |
| 182 | 183 | if( cPrefix=='+' ){ |
| 183 | 184 | blob_append(pOut, "<span class=\"diffadd\">", -1); |
| 184 | 185 | }else if( cPrefix=='-' ){ |
| 185 | 186 | blob_append(pOut, "<span class=\"diffrm\">", -1); |
| 186 | 187 | } |
| 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 | + } | |
| 188 | 193 | blob_append(pOut, zHtml, -1); |
| 189 | 194 | fossil_free(zHtml); |
| 190 | 195 | if( cPrefix!=' ' ){ |
| 191 | 196 | blob_append(pOut, "</span>", -1); |
| 192 | 197 | } |
| @@ -429,10 +434,13 @@ | ||
| 429 | 434 | memcpy(&z[j], "&", 5); |
| 430 | 435 | j += 5; |
| 431 | 436 | }else if( c=='>' && p->escHtml ){ |
| 432 | 437 | memcpy(&z[j], ">", 4); |
| 433 | 438 | j += 4; |
| 439 | + }else if( c=='"' && p->escHtml ){ | |
| 440 | + memcpy(&z[j], """, 6); | |
| 441 | + j += 6; | |
| 434 | 442 | }else{ |
| 435 | 443 | z[j++] = c; |
| 436 | 444 | if( (c&0xc0)==0x80 ) k--; |
| 437 | 445 | } |
| 438 | 446 | } |
| @@ -448,11 +456,11 @@ | ||
| 448 | 456 | } |
| 449 | 457 | p->n += j; |
| 450 | 458 | } |
| 451 | 459 | |
| 452 | 460 | /* |
| 453 | -** Append a string to an SbSLine with coding, interpretation, or padding. | |
| 461 | +** Append a string to an SbSLine without coding, interpretation, or padding. | |
| 454 | 462 | */ |
| 455 | 463 | static void sbsWrite(SbsLine *p, const char *zIn, int nIn){ |
| 456 | 464 | memcpy(p->zLine+p->n, zIn, nIn); |
| 457 | 465 | p->n += nIn; |
| 458 | 466 | } |
| 459 | 467 |
| --- 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], "&", 5); |
| 430 | j += 5; |
| 431 | }else if( c=='>' && p->escHtml ){ |
| 432 | memcpy(&z[j], ">", 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], "&", 5); |
| 435 | j += 5; |
| 436 | }else if( c=='>' && p->escHtml ){ |
| 437 | memcpy(&z[j], ">", 4); |
| 438 | j += 4; |
| 439 | }else if( c=='"' && p->escHtml ){ |
| 440 | memcpy(&z[j], """, 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 @@ | ||
| 510 | 510 | @ set line $tail |
| 511 | 511 | @ } |
| 512 | 512 | @ .t insert end [dehtml $line]\n {} |
| 513 | 513 | @ } |
| 514 | 514 | @ 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 | |
| 516 | 516 | @ if {$nLine>55} {set nLine 55} ;# Limit window height to 55 lines |
| 517 | 517 | @ .t config -height $nLine -width $mx |
| 518 | 518 | @ pack .t -side left -fill both -expand 1 |
| 519 | 519 | @ scrollbar .sb -command {.t yview} -orient vertical |
| 520 | 520 | @ pack .sb -side left -fill y |
| 521 | 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 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 |