Fossil SCM
Fix --debug diff output for multi-byte UTF-8.
Commit
9191ea9e63d1697dab52eb79efd79f4b452f7c14985f78e0315f7f75bd626f34
Parent
4b8f203f5dece0e…
1 file changed
+18
-6
+18
-6
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -727,13 +727,15 @@ | ||
| 727 | 727 | int i, j, k; /* Loop counters */ |
| 728 | 728 | int lenBest = 0; /* Match length to beat */ |
| 729 | 729 | |
| 730 | 730 | for(i=0; i<nA-lenBest; i++){ |
| 731 | 731 | unsigned char cA = zA[i]; |
| 732 | + if( (cA&0xc0)==0x80 ) continue; | |
| 732 | 733 | for(j=0; j<nB-lenBest; j++ ){ |
| 733 | 734 | if( zB[j]==cA ){ |
| 734 | 735 | for(k=1; j+k<nB && i+k<nA && zB[j+k]==zA[i+k]; k++){} |
| 736 | + while( (zB[j+k]&0xc0)==0x80 ){ k--; } | |
| 735 | 737 | if( k>lenBest ){ |
| 736 | 738 | lenBest = k; |
| 737 | 739 | aLCS[0] = i; |
| 738 | 740 | aLCS[1] = i+k; |
| 739 | 741 | aLCS[2] = j; |
| @@ -1671,25 +1673,35 @@ | ||
| 1671 | 1673 | oneLineChange(pX, pY, &span); |
| 1672 | 1674 | for(i=x=0; i<span.n; i++){ |
| 1673 | 1675 | int ofst = span.a[i].iStart1; |
| 1674 | 1676 | int len = span.a[i].iLen1; |
| 1675 | 1677 | if( len ){ |
| 1676 | - blob_appendf(p->pOut, "%*s", ofst+25 - x, ""); | |
| 1677 | - for(j=0; j<len; j++) blob_append_char(p->pOut, '^'); | |
| 1678 | - x = ofst+len+25; | |
| 1678 | + if( x==0 ){ blob_appendf(p->pOut, "%*s", 25, ""); } | |
| 1679 | + while( ofst > x ){ | |
| 1680 | + if( (pX->z[x]&0xc0)!=0x80 ) blob_append_char(p->pOut, ' '); | |
| 1681 | + x++; | |
| 1682 | + } | |
| 1683 | + for(j=0; j<len; j++, x++){ | |
| 1684 | + if( (pX->z[x]&0xc0)!=0x80 ) blob_append_char(p->pOut, '^'); | |
| 1685 | + } | |
| 1679 | 1686 | } |
| 1680 | 1687 | } |
| 1681 | 1688 | if( x ) blob_append_char(p->pOut, '\n'); |
| 1682 | 1689 | blob_appendf(p->pOut, " %8u %.*s\n", |
| 1683 | 1690 | p->lnRight, (int)pY->n, pY->z); |
| 1684 | 1691 | for(i=x=0; i<span.n; i++){ |
| 1685 | 1692 | int ofst = span.a[i].iStart2; |
| 1686 | 1693 | int len = span.a[i].iLen2; |
| 1687 | 1694 | if( len ){ |
| 1688 | - blob_appendf(p->pOut, "%*s", ofst+25 - x, ""); | |
| 1689 | - for(j=0; j<len; j++) blob_append_char(p->pOut, '^'); | |
| 1690 | - x = ofst+len+25; | |
| 1695 | + if( x==0 ){ blob_appendf(p->pOut, "%*s", 25, ""); } | |
| 1696 | + while( ofst > x ){ | |
| 1697 | + if( (pY->z[x]&0xc0)!=0x80 ) blob_append_char(p->pOut, ' '); | |
| 1698 | + x++; | |
| 1699 | + } | |
| 1700 | + for(j=0; j<len; j++, x++){ | |
| 1701 | + if( (pY->z[x]&0xc0)!=0x80 ) blob_append_char(p->pOut, '^'); | |
| 1702 | + } | |
| 1691 | 1703 | } |
| 1692 | 1704 | } |
| 1693 | 1705 | if( x ) blob_append_char(p->pOut, '\n'); |
| 1694 | 1706 | } |
| 1695 | 1707 | static void dfdebugEnd(DiffBuilder *p){ |
| 1696 | 1708 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -727,13 +727,15 @@ | |
| 727 | int i, j, k; /* Loop counters */ |
| 728 | int lenBest = 0; /* Match length to beat */ |
| 729 | |
| 730 | for(i=0; i<nA-lenBest; i++){ |
| 731 | unsigned char cA = zA[i]; |
| 732 | for(j=0; j<nB-lenBest; j++ ){ |
| 733 | if( zB[j]==cA ){ |
| 734 | for(k=1; j+k<nB && i+k<nA && zB[j+k]==zA[i+k]; k++){} |
| 735 | if( k>lenBest ){ |
| 736 | lenBest = k; |
| 737 | aLCS[0] = i; |
| 738 | aLCS[1] = i+k; |
| 739 | aLCS[2] = j; |
| @@ -1671,25 +1673,35 @@ | |
| 1671 | oneLineChange(pX, pY, &span); |
| 1672 | for(i=x=0; i<span.n; i++){ |
| 1673 | int ofst = span.a[i].iStart1; |
| 1674 | int len = span.a[i].iLen1; |
| 1675 | if( len ){ |
| 1676 | blob_appendf(p->pOut, "%*s", ofst+25 - x, ""); |
| 1677 | for(j=0; j<len; j++) blob_append_char(p->pOut, '^'); |
| 1678 | x = ofst+len+25; |
| 1679 | } |
| 1680 | } |
| 1681 | if( x ) blob_append_char(p->pOut, '\n'); |
| 1682 | blob_appendf(p->pOut, " %8u %.*s\n", |
| 1683 | p->lnRight, (int)pY->n, pY->z); |
| 1684 | for(i=x=0; i<span.n; i++){ |
| 1685 | int ofst = span.a[i].iStart2; |
| 1686 | int len = span.a[i].iLen2; |
| 1687 | if( len ){ |
| 1688 | blob_appendf(p->pOut, "%*s", ofst+25 - x, ""); |
| 1689 | for(j=0; j<len; j++) blob_append_char(p->pOut, '^'); |
| 1690 | x = ofst+len+25; |
| 1691 | } |
| 1692 | } |
| 1693 | if( x ) blob_append_char(p->pOut, '\n'); |
| 1694 | } |
| 1695 | static void dfdebugEnd(DiffBuilder *p){ |
| 1696 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -727,13 +727,15 @@ | |
| 727 | int i, j, k; /* Loop counters */ |
| 728 | int lenBest = 0; /* Match length to beat */ |
| 729 | |
| 730 | for(i=0; i<nA-lenBest; i++){ |
| 731 | unsigned char cA = zA[i]; |
| 732 | if( (cA&0xc0)==0x80 ) continue; |
| 733 | for(j=0; j<nB-lenBest; j++ ){ |
| 734 | if( zB[j]==cA ){ |
| 735 | for(k=1; j+k<nB && i+k<nA && zB[j+k]==zA[i+k]; k++){} |
| 736 | while( (zB[j+k]&0xc0)==0x80 ){ k--; } |
| 737 | if( k>lenBest ){ |
| 738 | lenBest = k; |
| 739 | aLCS[0] = i; |
| 740 | aLCS[1] = i+k; |
| 741 | aLCS[2] = j; |
| @@ -1671,25 +1673,35 @@ | |
| 1673 | oneLineChange(pX, pY, &span); |
| 1674 | for(i=x=0; i<span.n; i++){ |
| 1675 | int ofst = span.a[i].iStart1; |
| 1676 | int len = span.a[i].iLen1; |
| 1677 | if( len ){ |
| 1678 | if( x==0 ){ blob_appendf(p->pOut, "%*s", 25, ""); } |
| 1679 | while( ofst > x ){ |
| 1680 | if( (pX->z[x]&0xc0)!=0x80 ) blob_append_char(p->pOut, ' '); |
| 1681 | x++; |
| 1682 | } |
| 1683 | for(j=0; j<len; j++, x++){ |
| 1684 | if( (pX->z[x]&0xc0)!=0x80 ) blob_append_char(p->pOut, '^'); |
| 1685 | } |
| 1686 | } |
| 1687 | } |
| 1688 | if( x ) blob_append_char(p->pOut, '\n'); |
| 1689 | blob_appendf(p->pOut, " %8u %.*s\n", |
| 1690 | p->lnRight, (int)pY->n, pY->z); |
| 1691 | for(i=x=0; i<span.n; i++){ |
| 1692 | int ofst = span.a[i].iStart2; |
| 1693 | int len = span.a[i].iLen2; |
| 1694 | if( len ){ |
| 1695 | if( x==0 ){ blob_appendf(p->pOut, "%*s", 25, ""); } |
| 1696 | while( ofst > x ){ |
| 1697 | if( (pY->z[x]&0xc0)!=0x80 ) blob_append_char(p->pOut, ' '); |
| 1698 | x++; |
| 1699 | } |
| 1700 | for(j=0; j<len; j++, x++){ |
| 1701 | if( (pY->z[x]&0xc0)!=0x80 ) blob_append_char(p->pOut, '^'); |
| 1702 | } |
| 1703 | } |
| 1704 | } |
| 1705 | if( x ) blob_append_char(p->pOut, '\n'); |
| 1706 | } |
| 1707 | static void dfdebugEnd(DiffBuilder *p){ |
| 1708 |