Fossil SCM

Various improvements and bug fixes to the new diff logic.

drh 2021-09-02 14:25 diff-color-enhancements
Commit 10f736f04f60e2247507cd4a2f997991abd8fdb6b5283caab367d1b8f0e0c5b8
+83 -10
--- src/diff.c
+++ src/diff.c
@@ -1061,11 +1061,12 @@
10611061
if( nPrefix<nShort ){
10621062
while( nPrefix>0 && (zLeft[nPrefix]&0xc0)==0x80 ) nPrefix--;
10631063
}
10641064
nSuffix = 0;
10651065
if( nPrefix<nShort ){
1066
- while( nSuffix<nShort && zLeft[nLeft-nSuffix-1]==zRight[nRight-nSuffix-1] ){
1066
+ while( nSuffix<nShort
1067
+ && zLeft[nLeft-nSuffix-1]==zRight[nRight-nSuffix-1] ){
10671068
nSuffix++;
10681069
}
10691070
if( nSuffix<nShort ){
10701071
while( nSuffix>0 && (zLeft[nLeft-nSuffix]&0xc0)==0x80 ) nSuffix--;
10711072
}
@@ -1109,11 +1110,11 @@
11091110
}
11101111
11111112
/* A single chunk of text inserted */
11121113
if( nCommon==nLeft ){
11131114
p->n = 1;
1114
- p->a[0].iStart1 = 0;
1115
+ p->a[0].iStart1 = nPrefix;
11151116
p->a[0].iLen1 = 0;
11161117
p->a[0].iStart2 = nPrefix;
11171118
p->a[0].iLen2 = nRight - nCommon;
11181119
return;
11191120
}
@@ -1121,11 +1122,11 @@
11211122
/* A single chunk of text deleted */
11221123
if( nCommon==nRight ){
11231124
p->n = 1;
11241125
p->a[0].iStart1 = nPrefix;
11251126
p->a[0].iLen1 = nLeft - nCommon;
1126
- p->a[0].iStart2 = 0;
1127
+ p->a[0].iStart2 = nPrefix;
11271128
p->a[0].iLen2 = 0;
11281129
return;
11291130
}
11301131
11311132
/* At this point we know that there is a chunk of text that has
@@ -1632,10 +1633,11 @@
16321633
struct DiffBuilder {
16331634
void (*xSkip)(DiffBuilder*, unsigned int, int);
16341635
void (*xCommon)(DiffBuilder*,const DLine*);
16351636
void (*xInsert)(DiffBuilder*,const DLine*);
16361637
void (*xDelete)(DiffBuilder*,const DLine*);
1638
+ void (*xReplace)(DiffBuilder*,const DLine*, const DLine*);
16371639
void (*xEdit)(DiffBuilder*,const DLine*,const DLine*);
16381640
void (*xEnd)(DiffBuilder*);
16391641
unsigned int lnLeft; /* Lines seen on the left (delete) side */
16401642
unsigned int lnRight; /* Lines seen on the right (insert) side */
16411643
unsigned int nPending; /* Number of pending lines */
@@ -1653,30 +1655,38 @@
16531655
p->lnRight += n;
16541656
}
16551657
static void dfdebugCommon(DiffBuilder *p, const DLine *pLine){
16561658
p->lnLeft++;
16571659
p->lnRight++;
1658
- blob_appendf(p->pOut, "COMMON %8u %8u %.*s\n",
1660
+ blob_appendf(p->pOut, "COMMON %8u %8u %.*s\n",
16591661
p->lnLeft, p->lnRight, (int)pLine->n, pLine->z);
16601662
}
16611663
static void dfdebugInsert(DiffBuilder *p, const DLine *pLine){
16621664
p->lnRight++;
1663
- blob_appendf(p->pOut, "RIGHT %8d %.*s\n",
1665
+ blob_appendf(p->pOut, "INSERT %8d %.*s\n",
16641666
p->lnRight, (int)pLine->n, pLine->z);
16651667
}
16661668
static void dfdebugDelete(DiffBuilder *p, const DLine *pLine){
16671669
p->lnLeft++;
1668
- blob_appendf(p->pOut, "LEFT %8u %.*s\n",
1670
+ blob_appendf(p->pOut, "DELETE %8u %.*s\n",
16691671
p->lnLeft, (int)pLine->n, pLine->z);
1672
+}
1673
+static void dfdebugReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
1674
+ p->lnLeft++;
1675
+ p->lnRight++;
1676
+ blob_appendf(p->pOut, "REPLACE %8u %.*s\n",
1677
+ p->lnLeft, (int)pX->n, pX->z);
1678
+ blob_appendf(p->pOut, " %8u %.*s\n",
1679
+ p->lnRight, (int)pY->n, pY->z);
16701680
}
16711681
static void dfdebugEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
16721682
int i, j;
16731683
int x;
16741684
ChangeSpan span;
16751685
p->lnLeft++;
16761686
p->lnRight++;
1677
- blob_appendf(p->pOut, "EDIT %8u %.*s\n",
1687
+ blob_appendf(p->pOut, "EDIT %8u %.*s\n",
16781688
p->lnLeft, (int)pX->n, pX->z);
16791689
oneLineChange(pX, pY, &span);
16801690
for(i=x=0; i<span.n; i++){
16811691
int ofst = span.a[i].iStart1;
16821692
int len = span.a[i].iLen1;
@@ -1719,10 +1729,11 @@
17191729
DiffBuilder *p = fossil_malloc(sizeof(*p));
17201730
p->xSkip = dfdebugSkip;
17211731
p->xCommon = dfdebugCommon;
17221732
p->xInsert = dfdebugInsert;
17231733
p->xDelete = dfdebugDelete;
1734
+ p->xReplace = dfdebugReplace;
17241735
p->xEdit = dfdebugEdit;
17251736
p->xEnd = dfdebugEnd;
17261737
p->lnLeft = p->lnRight = 0;
17271738
p->pOut = pOut;
17281739
return p;
@@ -1768,10 +1779,17 @@
17681779
}
17691780
static void dftclDelete(DiffBuilder *p, const DLine *pLine){
17701781
blob_append(p->pOut, "DEL ", -1);
17711782
blob_append_tcl_string(p->pOut, pLine->z, pLine->n);
17721783
blob_append_char(p->pOut, '\n');
1784
+}
1785
+static void dftclReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
1786
+ blob_append(p->pOut, "EDIT ", -1);
1787
+ blob_append_tcl_string(p->pOut, pX->z, pX->n);
1788
+ blob_append_char(p->pOut, ' ');
1789
+ blob_append_tcl_string(p->pOut, pY->z, pY->n);
1790
+ blob_append_char(p->pOut, '\n');
17731791
}
17741792
static void dftclEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
17751793
int i, x;
17761794
ChangeSpan span;
17771795
blob_append(p->pOut, "EDIT", 4);
@@ -1799,10 +1817,11 @@
17991817
DiffBuilder *p = fossil_malloc(sizeof(*p));
18001818
p->xSkip = dftclSkip;
18011819
p->xCommon = dftclCommon;
18021820
p->xInsert = dftclInsert;
18031821
p->xDelete = dftclDelete;
1822
+ p->xReplace = dftclReplace;
18041823
p->xEdit = dftclEdit;
18051824
p->xEnd = dftclEnd;
18061825
p->pOut = pOut;
18071826
return p;
18081827
}
@@ -1886,10 +1905,18 @@
18861905
static void dfjsonDelete(DiffBuilder *p, const DLine *pLine){
18871906
int iCol = 0;
18881907
blob_append(p->pOut, "4,\"",3);
18891908
jsonize_to_blob(p->pOut, pLine->z, (int)pLine->n, &iCol);
18901909
blob_append(p->pOut, "\",\n",3);
1910
+}
1911
+static void dfjsonReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
1912
+ int iCol = 0;
1913
+ blob_append(p->pOut, "5,\"",3);
1914
+ jsonize_to_blob(p->pOut, pX->z, (int)pX->n, &iCol);
1915
+ blob_append(p->pOut, "\",\"",3);
1916
+ jsonize_to_blob(p->pOut, pY->z, (int)pY->n, &iCol);
1917
+ blob_append(p->pOut, "\",\n",3);
18911918
}
18921919
static void dfjsonEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
18931920
int i;
18941921
int x;
18951922
int iCol;
@@ -1933,10 +1960,11 @@
19331960
DiffBuilder *p = fossil_malloc(sizeof(*p));
19341961
p->xSkip = dfjsonSkip;
19351962
p->xCommon = dfjsonCommon;
19361963
p->xInsert = dfjsonInsert;
19371964
p->xDelete = dfjsonDelete;
1965
+ p->xReplace = dfjsonReplace;
19381966
p->xEdit = dfjsonEdit;
19391967
p->xEnd = dfjsonEnd;
19401968
p->lnLeft = p->lnRight = 0;
19411969
p->pOut = pOut;
19421970
blob_append_char(pOut, '[');
@@ -2050,10 +2078,36 @@
20502078
blob_append_char(&p->aCol[0],'\n');
20512079
blob_append(&p->aCol[1],"-\n",2);
20522080
blob_append(&p->aCol[2], "<del>", 5);
20532081
jsonize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n, &iCol);
20542082
blob_append(&p->aCol[2], "</del>\n", 7);
2083
+}
2084
+static void dfunifiedReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
2085
+ int iCol;
2086
+ dfunifiedStartRow(p);
2087
+ if( p->eState==0 ){
2088
+ dfunifiedFinishInsert(p);
2089
+ blob_append(p->pOut, "<del>", 5);
2090
+ blob_append(&p->aCol[2], "<del>", 5);
2091
+ p->eState = 1;
2092
+ }
2093
+ p->lnLeft++;
2094
+ p->lnRight++;
2095
+ blob_appendf(p->pOut,"%d\n", p->lnLeft);
2096
+ blob_append_char(&p->aCol[0], '\n');
2097
+ blob_append(&p->aCol[1], "-\n", 2);
2098
+
2099
+ iCol = 0;
2100
+ jsonize_to_blob(&p->aCol[2], pX->z, pX->n, &iCol);
2101
+ blob_append_char(&p->aCol[2], '\n');
2102
+
2103
+ blob_appendf(&p->aCol[3],"%d\n", p->lnRight);
2104
+
2105
+ iCol = 0;
2106
+ jsonize_to_blob(&p->aCol[4], pY->z, pY->n, &iCol);
2107
+ blob_append_char(&p->aCol[4], '\n');
2108
+ p->nPending++;
20552109
}
20562110
static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
20572111
int i;
20582112
int x;
20592113
int iCol;
@@ -2113,10 +2167,11 @@
21132167
DiffBuilder *p = fossil_malloc(sizeof(*p));
21142168
p->xSkip = dfunifiedSkip;
21152169
p->xCommon = dfunifiedCommon;
21162170
p->xInsert = dfunifiedInsert;
21172171
p->xDelete = dfunifiedDelete;
2172
+ p->xReplace = dfunifiedReplace;
21182173
p->xEdit = dfunifiedEdit;
21192174
p->xEnd = dfunifiedEnd;
21202175
p->lnLeft = p->lnRight = 0;
21212176
p->eState = 0;
21222177
p->nPending = 0;
@@ -2234,10 +2289,29 @@
22342289
jsonize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n, &iCol);
22352290
blob_append(&p->aCol[0], "</del>\n", 7);
22362291
blob_append(&p->aCol[1], "&lt;\n", -1);
22372292
blob_append_char(&p->aCol[2],'\n');
22382293
blob_append_char(&p->aCol[3],'\n');
2294
+}
2295
+static void dfsplitReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
2296
+ int iCol;
2297
+ dfsplitStartRow(p);
2298
+ dfsplitChangeState(p, 3);
2299
+ p->lnLeft++;
2300
+ p->lnRight++;
2301
+ blob_appendf(p->pOut,"%d\n", p->lnLeft);
2302
+ iCol = 0;
2303
+ jsonize_to_blob(&p->aCol[0], pX->z, pX->n, &iCol);
2304
+ blob_append_char(&p->aCol[0], '\n');
2305
+
2306
+ blob_append(&p->aCol[1], "|\n", 2);
2307
+
2308
+ blob_appendf(&p->aCol[2],"%d\n", p->lnRight);
2309
+
2310
+ iCol = 0;
2311
+ jsonize_to_blob(&p->aCol[3], pY->z, pY->n, &iCol);
2312
+ blob_append_char(&p->aCol[3], '\n');
22392313
}
22402314
static void dfsplitEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
22412315
int i;
22422316
int x;
22432317
int iCol;
@@ -2290,10 +2364,11 @@
22902364
DiffBuilder *p = fossil_malloc(sizeof(*p));
22912365
p->xSkip = dfsplitSkip;
22922366
p->xCommon = dfsplitCommon;
22932367
p->xInsert = dfsplitInsert;
22942368
p->xDelete = dfsplitDelete;
2369
+ p->xReplace = dfsplitReplace;
22952370
p->xEdit = dfsplitEdit;
22962371
p->xEnd = dfsplitEnd;
22972372
p->lnLeft = p->lnRight = 0;
22982373
p->eState = 0;
22992374
p->pOut = pOut;
@@ -2440,15 +2515,13 @@
24402515
b++;
24412516
break;
24422517
}
24432518
case 4: {
24442519
/* Delete from left then separately insert on the right */
2445
- pBuilder->xDelete(pBuilder, &A[a]);
2520
+ pBuilder->xReplace(pBuilder, &A[a], &B[b]);
24462521
ma--;
24472522
a++;
2448
- pBuilder->xInsert(pBuilder, &B[b]);
2449
- assert( mb>0 );
24502523
mb--;
24512524
b++;
24522525
break;
24532526
}
24542527
}
24552528
--- src/diff.c
+++ src/diff.c
@@ -1061,11 +1061,12 @@
1061 if( nPrefix<nShort ){
1062 while( nPrefix>0 && (zLeft[nPrefix]&0xc0)==0x80 ) nPrefix--;
1063 }
1064 nSuffix = 0;
1065 if( nPrefix<nShort ){
1066 while( nSuffix<nShort && zLeft[nLeft-nSuffix-1]==zRight[nRight-nSuffix-1] ){
 
1067 nSuffix++;
1068 }
1069 if( nSuffix<nShort ){
1070 while( nSuffix>0 && (zLeft[nLeft-nSuffix]&0xc0)==0x80 ) nSuffix--;
1071 }
@@ -1109,11 +1110,11 @@
1109 }
1110
1111 /* A single chunk of text inserted */
1112 if( nCommon==nLeft ){
1113 p->n = 1;
1114 p->a[0].iStart1 = 0;
1115 p->a[0].iLen1 = 0;
1116 p->a[0].iStart2 = nPrefix;
1117 p->a[0].iLen2 = nRight - nCommon;
1118 return;
1119 }
@@ -1121,11 +1122,11 @@
1121 /* A single chunk of text deleted */
1122 if( nCommon==nRight ){
1123 p->n = 1;
1124 p->a[0].iStart1 = nPrefix;
1125 p->a[0].iLen1 = nLeft - nCommon;
1126 p->a[0].iStart2 = 0;
1127 p->a[0].iLen2 = 0;
1128 return;
1129 }
1130
1131 /* At this point we know that there is a chunk of text that has
@@ -1632,10 +1633,11 @@
1632 struct DiffBuilder {
1633 void (*xSkip)(DiffBuilder*, unsigned int, int);
1634 void (*xCommon)(DiffBuilder*,const DLine*);
1635 void (*xInsert)(DiffBuilder*,const DLine*);
1636 void (*xDelete)(DiffBuilder*,const DLine*);
 
1637 void (*xEdit)(DiffBuilder*,const DLine*,const DLine*);
1638 void (*xEnd)(DiffBuilder*);
1639 unsigned int lnLeft; /* Lines seen on the left (delete) side */
1640 unsigned int lnRight; /* Lines seen on the right (insert) side */
1641 unsigned int nPending; /* Number of pending lines */
@@ -1653,30 +1655,38 @@
1653 p->lnRight += n;
1654 }
1655 static void dfdebugCommon(DiffBuilder *p, const DLine *pLine){
1656 p->lnLeft++;
1657 p->lnRight++;
1658 blob_appendf(p->pOut, "COMMON %8u %8u %.*s\n",
1659 p->lnLeft, p->lnRight, (int)pLine->n, pLine->z);
1660 }
1661 static void dfdebugInsert(DiffBuilder *p, const DLine *pLine){
1662 p->lnRight++;
1663 blob_appendf(p->pOut, "RIGHT %8d %.*s\n",
1664 p->lnRight, (int)pLine->n, pLine->z);
1665 }
1666 static void dfdebugDelete(DiffBuilder *p, const DLine *pLine){
1667 p->lnLeft++;
1668 blob_appendf(p->pOut, "LEFT %8u %.*s\n",
1669 p->lnLeft, (int)pLine->n, pLine->z);
 
 
 
 
 
 
 
 
1670 }
1671 static void dfdebugEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
1672 int i, j;
1673 int x;
1674 ChangeSpan span;
1675 p->lnLeft++;
1676 p->lnRight++;
1677 blob_appendf(p->pOut, "EDIT %8u %.*s\n",
1678 p->lnLeft, (int)pX->n, pX->z);
1679 oneLineChange(pX, pY, &span);
1680 for(i=x=0; i<span.n; i++){
1681 int ofst = span.a[i].iStart1;
1682 int len = span.a[i].iLen1;
@@ -1719,10 +1729,11 @@
1719 DiffBuilder *p = fossil_malloc(sizeof(*p));
1720 p->xSkip = dfdebugSkip;
1721 p->xCommon = dfdebugCommon;
1722 p->xInsert = dfdebugInsert;
1723 p->xDelete = dfdebugDelete;
 
1724 p->xEdit = dfdebugEdit;
1725 p->xEnd = dfdebugEnd;
1726 p->lnLeft = p->lnRight = 0;
1727 p->pOut = pOut;
1728 return p;
@@ -1768,10 +1779,17 @@
1768 }
1769 static void dftclDelete(DiffBuilder *p, const DLine *pLine){
1770 blob_append(p->pOut, "DEL ", -1);
1771 blob_append_tcl_string(p->pOut, pLine->z, pLine->n);
1772 blob_append_char(p->pOut, '\n');
 
 
 
 
 
 
 
1773 }
1774 static void dftclEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
1775 int i, x;
1776 ChangeSpan span;
1777 blob_append(p->pOut, "EDIT", 4);
@@ -1799,10 +1817,11 @@
1799 DiffBuilder *p = fossil_malloc(sizeof(*p));
1800 p->xSkip = dftclSkip;
1801 p->xCommon = dftclCommon;
1802 p->xInsert = dftclInsert;
1803 p->xDelete = dftclDelete;
 
1804 p->xEdit = dftclEdit;
1805 p->xEnd = dftclEnd;
1806 p->pOut = pOut;
1807 return p;
1808 }
@@ -1886,10 +1905,18 @@
1886 static void dfjsonDelete(DiffBuilder *p, const DLine *pLine){
1887 int iCol = 0;
1888 blob_append(p->pOut, "4,\"",3);
1889 jsonize_to_blob(p->pOut, pLine->z, (int)pLine->n, &iCol);
1890 blob_append(p->pOut, "\",\n",3);
 
 
 
 
 
 
 
 
1891 }
1892 static void dfjsonEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
1893 int i;
1894 int x;
1895 int iCol;
@@ -1933,10 +1960,11 @@
1933 DiffBuilder *p = fossil_malloc(sizeof(*p));
1934 p->xSkip = dfjsonSkip;
1935 p->xCommon = dfjsonCommon;
1936 p->xInsert = dfjsonInsert;
1937 p->xDelete = dfjsonDelete;
 
1938 p->xEdit = dfjsonEdit;
1939 p->xEnd = dfjsonEnd;
1940 p->lnLeft = p->lnRight = 0;
1941 p->pOut = pOut;
1942 blob_append_char(pOut, '[');
@@ -2050,10 +2078,36 @@
2050 blob_append_char(&p->aCol[0],'\n');
2051 blob_append(&p->aCol[1],"-\n",2);
2052 blob_append(&p->aCol[2], "<del>", 5);
2053 jsonize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n, &iCol);
2054 blob_append(&p->aCol[2], "</del>\n", 7);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2055 }
2056 static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
2057 int i;
2058 int x;
2059 int iCol;
@@ -2113,10 +2167,11 @@
2113 DiffBuilder *p = fossil_malloc(sizeof(*p));
2114 p->xSkip = dfunifiedSkip;
2115 p->xCommon = dfunifiedCommon;
2116 p->xInsert = dfunifiedInsert;
2117 p->xDelete = dfunifiedDelete;
 
2118 p->xEdit = dfunifiedEdit;
2119 p->xEnd = dfunifiedEnd;
2120 p->lnLeft = p->lnRight = 0;
2121 p->eState = 0;
2122 p->nPending = 0;
@@ -2234,10 +2289,29 @@
2234 jsonize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n, &iCol);
2235 blob_append(&p->aCol[0], "</del>\n", 7);
2236 blob_append(&p->aCol[1], "&lt;\n", -1);
2237 blob_append_char(&p->aCol[2],'\n');
2238 blob_append_char(&p->aCol[3],'\n');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2239 }
2240 static void dfsplitEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
2241 int i;
2242 int x;
2243 int iCol;
@@ -2290,10 +2364,11 @@
2290 DiffBuilder *p = fossil_malloc(sizeof(*p));
2291 p->xSkip = dfsplitSkip;
2292 p->xCommon = dfsplitCommon;
2293 p->xInsert = dfsplitInsert;
2294 p->xDelete = dfsplitDelete;
 
2295 p->xEdit = dfsplitEdit;
2296 p->xEnd = dfsplitEnd;
2297 p->lnLeft = p->lnRight = 0;
2298 p->eState = 0;
2299 p->pOut = pOut;
@@ -2440,15 +2515,13 @@
2440 b++;
2441 break;
2442 }
2443 case 4: {
2444 /* Delete from left then separately insert on the right */
2445 pBuilder->xDelete(pBuilder, &A[a]);
2446 ma--;
2447 a++;
2448 pBuilder->xInsert(pBuilder, &B[b]);
2449 assert( mb>0 );
2450 mb--;
2451 b++;
2452 break;
2453 }
2454 }
2455
--- src/diff.c
+++ src/diff.c
@@ -1061,11 +1061,12 @@
1061 if( nPrefix<nShort ){
1062 while( nPrefix>0 && (zLeft[nPrefix]&0xc0)==0x80 ) nPrefix--;
1063 }
1064 nSuffix = 0;
1065 if( nPrefix<nShort ){
1066 while( nSuffix<nShort
1067 && zLeft[nLeft-nSuffix-1]==zRight[nRight-nSuffix-1] ){
1068 nSuffix++;
1069 }
1070 if( nSuffix<nShort ){
1071 while( nSuffix>0 && (zLeft[nLeft-nSuffix]&0xc0)==0x80 ) nSuffix--;
1072 }
@@ -1109,11 +1110,11 @@
1110 }
1111
1112 /* A single chunk of text inserted */
1113 if( nCommon==nLeft ){
1114 p->n = 1;
1115 p->a[0].iStart1 = nPrefix;
1116 p->a[0].iLen1 = 0;
1117 p->a[0].iStart2 = nPrefix;
1118 p->a[0].iLen2 = nRight - nCommon;
1119 return;
1120 }
@@ -1121,11 +1122,11 @@
1122 /* A single chunk of text deleted */
1123 if( nCommon==nRight ){
1124 p->n = 1;
1125 p->a[0].iStart1 = nPrefix;
1126 p->a[0].iLen1 = nLeft - nCommon;
1127 p->a[0].iStart2 = nPrefix;
1128 p->a[0].iLen2 = 0;
1129 return;
1130 }
1131
1132 /* At this point we know that there is a chunk of text that has
@@ -1632,10 +1633,11 @@
1633 struct DiffBuilder {
1634 void (*xSkip)(DiffBuilder*, unsigned int, int);
1635 void (*xCommon)(DiffBuilder*,const DLine*);
1636 void (*xInsert)(DiffBuilder*,const DLine*);
1637 void (*xDelete)(DiffBuilder*,const DLine*);
1638 void (*xReplace)(DiffBuilder*,const DLine*, const DLine*);
1639 void (*xEdit)(DiffBuilder*,const DLine*,const DLine*);
1640 void (*xEnd)(DiffBuilder*);
1641 unsigned int lnLeft; /* Lines seen on the left (delete) side */
1642 unsigned int lnRight; /* Lines seen on the right (insert) side */
1643 unsigned int nPending; /* Number of pending lines */
@@ -1653,30 +1655,38 @@
1655 p->lnRight += n;
1656 }
1657 static void dfdebugCommon(DiffBuilder *p, const DLine *pLine){
1658 p->lnLeft++;
1659 p->lnRight++;
1660 blob_appendf(p->pOut, "COMMON %8u %8u %.*s\n",
1661 p->lnLeft, p->lnRight, (int)pLine->n, pLine->z);
1662 }
1663 static void dfdebugInsert(DiffBuilder *p, const DLine *pLine){
1664 p->lnRight++;
1665 blob_appendf(p->pOut, "INSERT %8d %.*s\n",
1666 p->lnRight, (int)pLine->n, pLine->z);
1667 }
1668 static void dfdebugDelete(DiffBuilder *p, const DLine *pLine){
1669 p->lnLeft++;
1670 blob_appendf(p->pOut, "DELETE %8u %.*s\n",
1671 p->lnLeft, (int)pLine->n, pLine->z);
1672 }
1673 static void dfdebugReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
1674 p->lnLeft++;
1675 p->lnRight++;
1676 blob_appendf(p->pOut, "REPLACE %8u %.*s\n",
1677 p->lnLeft, (int)pX->n, pX->z);
1678 blob_appendf(p->pOut, " %8u %.*s\n",
1679 p->lnRight, (int)pY->n, pY->z);
1680 }
1681 static void dfdebugEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
1682 int i, j;
1683 int x;
1684 ChangeSpan span;
1685 p->lnLeft++;
1686 p->lnRight++;
1687 blob_appendf(p->pOut, "EDIT %8u %.*s\n",
1688 p->lnLeft, (int)pX->n, pX->z);
1689 oneLineChange(pX, pY, &span);
1690 for(i=x=0; i<span.n; i++){
1691 int ofst = span.a[i].iStart1;
1692 int len = span.a[i].iLen1;
@@ -1719,10 +1729,11 @@
1729 DiffBuilder *p = fossil_malloc(sizeof(*p));
1730 p->xSkip = dfdebugSkip;
1731 p->xCommon = dfdebugCommon;
1732 p->xInsert = dfdebugInsert;
1733 p->xDelete = dfdebugDelete;
1734 p->xReplace = dfdebugReplace;
1735 p->xEdit = dfdebugEdit;
1736 p->xEnd = dfdebugEnd;
1737 p->lnLeft = p->lnRight = 0;
1738 p->pOut = pOut;
1739 return p;
@@ -1768,10 +1779,17 @@
1779 }
1780 static void dftclDelete(DiffBuilder *p, const DLine *pLine){
1781 blob_append(p->pOut, "DEL ", -1);
1782 blob_append_tcl_string(p->pOut, pLine->z, pLine->n);
1783 blob_append_char(p->pOut, '\n');
1784 }
1785 static void dftclReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
1786 blob_append(p->pOut, "EDIT ", -1);
1787 blob_append_tcl_string(p->pOut, pX->z, pX->n);
1788 blob_append_char(p->pOut, ' ');
1789 blob_append_tcl_string(p->pOut, pY->z, pY->n);
1790 blob_append_char(p->pOut, '\n');
1791 }
1792 static void dftclEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
1793 int i, x;
1794 ChangeSpan span;
1795 blob_append(p->pOut, "EDIT", 4);
@@ -1799,10 +1817,11 @@
1817 DiffBuilder *p = fossil_malloc(sizeof(*p));
1818 p->xSkip = dftclSkip;
1819 p->xCommon = dftclCommon;
1820 p->xInsert = dftclInsert;
1821 p->xDelete = dftclDelete;
1822 p->xReplace = dftclReplace;
1823 p->xEdit = dftclEdit;
1824 p->xEnd = dftclEnd;
1825 p->pOut = pOut;
1826 return p;
1827 }
@@ -1886,10 +1905,18 @@
1905 static void dfjsonDelete(DiffBuilder *p, const DLine *pLine){
1906 int iCol = 0;
1907 blob_append(p->pOut, "4,\"",3);
1908 jsonize_to_blob(p->pOut, pLine->z, (int)pLine->n, &iCol);
1909 blob_append(p->pOut, "\",\n",3);
1910 }
1911 static void dfjsonReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
1912 int iCol = 0;
1913 blob_append(p->pOut, "5,\"",3);
1914 jsonize_to_blob(p->pOut, pX->z, (int)pX->n, &iCol);
1915 blob_append(p->pOut, "\",\"",3);
1916 jsonize_to_blob(p->pOut, pY->z, (int)pY->n, &iCol);
1917 blob_append(p->pOut, "\",\n",3);
1918 }
1919 static void dfjsonEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
1920 int i;
1921 int x;
1922 int iCol;
@@ -1933,10 +1960,11 @@
1960 DiffBuilder *p = fossil_malloc(sizeof(*p));
1961 p->xSkip = dfjsonSkip;
1962 p->xCommon = dfjsonCommon;
1963 p->xInsert = dfjsonInsert;
1964 p->xDelete = dfjsonDelete;
1965 p->xReplace = dfjsonReplace;
1966 p->xEdit = dfjsonEdit;
1967 p->xEnd = dfjsonEnd;
1968 p->lnLeft = p->lnRight = 0;
1969 p->pOut = pOut;
1970 blob_append_char(pOut, '[');
@@ -2050,10 +2078,36 @@
2078 blob_append_char(&p->aCol[0],'\n');
2079 blob_append(&p->aCol[1],"-\n",2);
2080 blob_append(&p->aCol[2], "<del>", 5);
2081 jsonize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n, &iCol);
2082 blob_append(&p->aCol[2], "</del>\n", 7);
2083 }
2084 static void dfunifiedReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
2085 int iCol;
2086 dfunifiedStartRow(p);
2087 if( p->eState==0 ){
2088 dfunifiedFinishInsert(p);
2089 blob_append(p->pOut, "<del>", 5);
2090 blob_append(&p->aCol[2], "<del>", 5);
2091 p->eState = 1;
2092 }
2093 p->lnLeft++;
2094 p->lnRight++;
2095 blob_appendf(p->pOut,"%d\n", p->lnLeft);
2096 blob_append_char(&p->aCol[0], '\n');
2097 blob_append(&p->aCol[1], "-\n", 2);
2098
2099 iCol = 0;
2100 jsonize_to_blob(&p->aCol[2], pX->z, pX->n, &iCol);
2101 blob_append_char(&p->aCol[2], '\n');
2102
2103 blob_appendf(&p->aCol[3],"%d\n", p->lnRight);
2104
2105 iCol = 0;
2106 jsonize_to_blob(&p->aCol[4], pY->z, pY->n, &iCol);
2107 blob_append_char(&p->aCol[4], '\n');
2108 p->nPending++;
2109 }
2110 static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
2111 int i;
2112 int x;
2113 int iCol;
@@ -2113,10 +2167,11 @@
2167 DiffBuilder *p = fossil_malloc(sizeof(*p));
2168 p->xSkip = dfunifiedSkip;
2169 p->xCommon = dfunifiedCommon;
2170 p->xInsert = dfunifiedInsert;
2171 p->xDelete = dfunifiedDelete;
2172 p->xReplace = dfunifiedReplace;
2173 p->xEdit = dfunifiedEdit;
2174 p->xEnd = dfunifiedEnd;
2175 p->lnLeft = p->lnRight = 0;
2176 p->eState = 0;
2177 p->nPending = 0;
@@ -2234,10 +2289,29 @@
2289 jsonize_to_blob(&p->aCol[0], pLine->z, (int)pLine->n, &iCol);
2290 blob_append(&p->aCol[0], "</del>\n", 7);
2291 blob_append(&p->aCol[1], "&lt;\n", -1);
2292 blob_append_char(&p->aCol[2],'\n');
2293 blob_append_char(&p->aCol[3],'\n');
2294 }
2295 static void dfsplitReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){
2296 int iCol;
2297 dfsplitStartRow(p);
2298 dfsplitChangeState(p, 3);
2299 p->lnLeft++;
2300 p->lnRight++;
2301 blob_appendf(p->pOut,"%d\n", p->lnLeft);
2302 iCol = 0;
2303 jsonize_to_blob(&p->aCol[0], pX->z, pX->n, &iCol);
2304 blob_append_char(&p->aCol[0], '\n');
2305
2306 blob_append(&p->aCol[1], "|\n", 2);
2307
2308 blob_appendf(&p->aCol[2],"%d\n", p->lnRight);
2309
2310 iCol = 0;
2311 jsonize_to_blob(&p->aCol[3], pY->z, pY->n, &iCol);
2312 blob_append_char(&p->aCol[3], '\n');
2313 }
2314 static void dfsplitEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){
2315 int i;
2316 int x;
2317 int iCol;
@@ -2290,10 +2364,11 @@
2364 DiffBuilder *p = fossil_malloc(sizeof(*p));
2365 p->xSkip = dfsplitSkip;
2366 p->xCommon = dfsplitCommon;
2367 p->xInsert = dfsplitInsert;
2368 p->xDelete = dfsplitDelete;
2369 p->xReplace = dfsplitReplace;
2370 p->xEdit = dfsplitEdit;
2371 p->xEnd = dfsplitEnd;
2372 p->lnLeft = p->lnRight = 0;
2373 p->eState = 0;
2374 p->pOut = pOut;
@@ -2440,15 +2515,13 @@
2515 b++;
2516 break;
2517 }
2518 case 4: {
2519 /* Delete from left then separately insert on the right */
2520 pBuilder->xReplace(pBuilder, &A[a], &B[b]);
2521 ma--;
2522 a++;
 
 
2523 mb--;
2524 b++;
2525 break;
2526 }
2527 }
2528
+11 -5
--- src/diff.tcl
+++ src/diff.tcl
@@ -72,20 +72,24 @@
7272
set N [llength $difftxt]
7373
set ii 0
7474
set nDiffs 0
7575
set n1 0
7676
set n2 0
77
- array set widths {txt 0 ln 0 mkr 0}
77
+ array set widths {txt 0 ln 0 mkr 1}
7878
while {[set line [getLine $difftxt $N ii]] != -1} {
79
- incr nDiffs
8079
switch -- [lindex $line 0] {
8180
FILE {
81
+ incr nDiffs
82
+ foreach wx [list [string length $n1] [string length $n2]] {
83
+ if {$wx>$widths(ln)} {set widths(ln) $wx}
84
+ }
8285
.lnA insert end \n fn \n -
83
- .txtA insert end [lindex $line 1] fn \n -
86
+ .txtA insert end [lindex $line 1]\n fn
8487
.mkr insert end \n fn \n -
8588
.lnB insert end \n fn \n -
86
- .txtB insert end [lindex $line 2] fn \n -
89
+ .txtB insert end [lindex $line 2]\n fn
90
+ .wfiles.lb insert end [lindex $line 2]
8791
set n1 0
8892
set n2 0
8993
}
9094
SKIP {
9195
set n [lindex $line 1]
@@ -140,11 +144,13 @@
140144
}
141145
.txtA insert end \n -
142146
.txtB insert end \n -
143147
}
144148
"" {
145
- incr nDiffs -1
149
+ foreach wx [list [string length $n1] [string length $n2]] {
150
+ if {$wx>$widths(ln)} {set widths(ln) $wx}
151
+ }
146152
}
147153
default {
148154
error "bad diff source line: $line"
149155
}
150156
}
151157
--- src/diff.tcl
+++ src/diff.tcl
@@ -72,20 +72,24 @@
72 set N [llength $difftxt]
73 set ii 0
74 set nDiffs 0
75 set n1 0
76 set n2 0
77 array set widths {txt 0 ln 0 mkr 0}
78 while {[set line [getLine $difftxt $N ii]] != -1} {
79 incr nDiffs
80 switch -- [lindex $line 0] {
81 FILE {
 
 
 
 
82 .lnA insert end \n fn \n -
83 .txtA insert end [lindex $line 1] fn \n -
84 .mkr insert end \n fn \n -
85 .lnB insert end \n fn \n -
86 .txtB insert end [lindex $line 2] fn \n -
 
87 set n1 0
88 set n2 0
89 }
90 SKIP {
91 set n [lindex $line 1]
@@ -140,11 +144,13 @@
140 }
141 .txtA insert end \n -
142 .txtB insert end \n -
143 }
144 "" {
145 incr nDiffs -1
 
 
146 }
147 default {
148 error "bad diff source line: $line"
149 }
150 }
151
--- src/diff.tcl
+++ src/diff.tcl
@@ -72,20 +72,24 @@
72 set N [llength $difftxt]
73 set ii 0
74 set nDiffs 0
75 set n1 0
76 set n2 0
77 array set widths {txt 0 ln 0 mkr 1}
78 while {[set line [getLine $difftxt $N ii]] != -1} {
 
79 switch -- [lindex $line 0] {
80 FILE {
81 incr nDiffs
82 foreach wx [list [string length $n1] [string length $n2]] {
83 if {$wx>$widths(ln)} {set widths(ln) $wx}
84 }
85 .lnA insert end \n fn \n -
86 .txtA insert end [lindex $line 1]\n fn
87 .mkr insert end \n fn \n -
88 .lnB insert end \n fn \n -
89 .txtB insert end [lindex $line 2]\n fn
90 .wfiles.lb insert end [lindex $line 2]
91 set n1 0
92 set n2 0
93 }
94 SKIP {
95 set n [lindex $line 1]
@@ -140,11 +144,13 @@
144 }
145 .txtA insert end \n -
146 .txtB insert end \n -
147 }
148 "" {
149 foreach wx [list [string length $n1] [string length $n2]] {
150 if {$wx>$widths(ln)} {set widths(ln) $wx}
151 }
152 }
153 default {
154 error "bad diff source line: $line"
155 }
156 }
157
+3 -3
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -618,12 +618,12 @@
618618
Blob sql;
619619
Stmt q;
620620
int asNewFile; /* Treat non-existant files as empty files */
621621
int isNumStat; /* True for --numstat */
622622
623
- asNewFile = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0;
624
- isNumStat = (diffFlags & DIFF_NUMSTAT)!=0;
623
+ asNewFile = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT|DIFF_HTML))!=0;
624
+ isNumStat = (diffFlags & (DIFF_NUMSTAT|DIFF_TCL|DIFF_HTML))!=0;
625625
vid = db_lget_int("checkout", 0);
626626
vfile_check_signature(vid, CKSIG_ENOTFILE);
627627
blob_zero(&sql);
628628
db_begin_transaction();
629629
if( zFrom ){
@@ -866,11 +866,11 @@
866866
}
867867
}
868868
pFromFile = manifest_file_next(pFrom,0);
869869
}else if( cmp>0 ){
870870
if( file_dir_match(pFileDir, pToFile->zName) ){
871
- if( (diffFlags & (DIFF_NUMSTAT|DIFF_HTML))==0 ){
871
+ if( (diffFlags & (DIFF_NUMSTAT|DIFF_HTML|DIFF_TCL|DIFF_JSON))==0 ){
872872
fossil_print("ADDED %s\n", pToFile->zName);
873873
}
874874
if( asNewFlag ){
875875
diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob,
876876
fIncludeBinary, diffFlags);
877877
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -618,12 +618,12 @@
618 Blob sql;
619 Stmt q;
620 int asNewFile; /* Treat non-existant files as empty files */
621 int isNumStat; /* True for --numstat */
622
623 asNewFile = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT))!=0;
624 isNumStat = (diffFlags & DIFF_NUMSTAT)!=0;
625 vid = db_lget_int("checkout", 0);
626 vfile_check_signature(vid, CKSIG_ENOTFILE);
627 blob_zero(&sql);
628 db_begin_transaction();
629 if( zFrom ){
@@ -866,11 +866,11 @@
866 }
867 }
868 pFromFile = manifest_file_next(pFrom,0);
869 }else if( cmp>0 ){
870 if( file_dir_match(pFileDir, pToFile->zName) ){
871 if( (diffFlags & (DIFF_NUMSTAT|DIFF_HTML))==0 ){
872 fossil_print("ADDED %s\n", pToFile->zName);
873 }
874 if( asNewFlag ){
875 diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob,
876 fIncludeBinary, diffFlags);
877
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -618,12 +618,12 @@
618 Blob sql;
619 Stmt q;
620 int asNewFile; /* Treat non-existant files as empty files */
621 int isNumStat; /* True for --numstat */
622
623 asNewFile = (diffFlags & (DIFF_VERBOSE|DIFF_NUMSTAT|DIFF_HTML))!=0;
624 isNumStat = (diffFlags & (DIFF_NUMSTAT|DIFF_TCL|DIFF_HTML))!=0;
625 vid = db_lget_int("checkout", 0);
626 vfile_check_signature(vid, CKSIG_ENOTFILE);
627 blob_zero(&sql);
628 db_begin_transaction();
629 if( zFrom ){
@@ -866,11 +866,11 @@
866 }
867 }
868 pFromFile = manifest_file_next(pFrom,0);
869 }else if( cmp>0 ){
870 if( file_dir_match(pFileDir, pToFile->zName) ){
871 if( (diffFlags & (DIFF_NUMSTAT|DIFF_HTML|DIFF_TCL|DIFF_JSON))==0 ){
872 fossil_print("ADDED %s\n", pToFile->zName);
873 }
874 if( asNewFlag ){
875 diff_manifest_entry(0, pToFile, zDiffCmd, zBinGlob,
876 fIncludeBinary, diffFlags);
877
+1 -1
--- src/fileedit.c
+++ src/fileedit.c
@@ -1999,11 +1999,11 @@
19991999
** fossil.page.fileedit.js. Potential TODO: move this into the
20002000
** window.fossil bootstrapping so that we don't have to "fulfill"
20012001
** the JS multiple times.
20022002
*/
20032003
ajax_emit_js_preview_modes(1);
2004
- builtin_request_js("sbsdiff.js");
2004
+ builtin_request_js("diff.js");
20052005
builtin_request_js("fossil.page.fileedit.js");
20062006
builtin_fulfill_js_requests();
20072007
{
20082008
/* Dynamically populate the editor, display any error in the err
20092009
** blob, and/or switch to tab #0, where the file selector
20102010
--- src/fileedit.c
+++ src/fileedit.c
@@ -1999,11 +1999,11 @@
1999 ** fossil.page.fileedit.js. Potential TODO: move this into the
2000 ** window.fossil bootstrapping so that we don't have to "fulfill"
2001 ** the JS multiple times.
2002 */
2003 ajax_emit_js_preview_modes(1);
2004 builtin_request_js("sbsdiff.js");
2005 builtin_request_js("fossil.page.fileedit.js");
2006 builtin_fulfill_js_requests();
2007 {
2008 /* Dynamically populate the editor, display any error in the err
2009 ** blob, and/or switch to tab #0, where the file selector
2010
--- src/fileedit.c
+++ src/fileedit.c
@@ -1999,11 +1999,11 @@
1999 ** fossil.page.fileedit.js. Potential TODO: move this into the
2000 ** window.fossil bootstrapping so that we don't have to "fulfill"
2001 ** the JS multiple times.
2002 */
2003 ajax_emit_js_preview_modes(1);
2004 builtin_request_js("diff.js");
2005 builtin_request_js("fossil.page.fileedit.js");
2006 builtin_fulfill_js_requests();
2007 {
2008 /* Dynamically populate the editor, display any error in the err
2009 ** blob, and/or switch to tab #0, where the file selector
2010
+1 -1
--- src/info.c
+++ src/info.c
@@ -441,11 +441,11 @@
441441
/*
442442
** Generate javascript to enhance HTML diffs.
443443
*/
444444
void append_diff_javascript(int sideBySide){
445445
if( !sideBySide ) return;
446
- builtin_request_js("sbsdiff.js");
446
+ builtin_request_js("diff.js");
447447
}
448448
449449
/*
450450
** Construct an appropriate diffFlag for text_diff() based on query
451451
** parameters and the to boolean arguments.
452452
--- src/info.c
+++ src/info.c
@@ -441,11 +441,11 @@
441 /*
442 ** Generate javascript to enhance HTML diffs.
443 */
444 void append_diff_javascript(int sideBySide){
445 if( !sideBySide ) return;
446 builtin_request_js("sbsdiff.js");
447 }
448
449 /*
450 ** Construct an appropriate diffFlag for text_diff() based on query
451 ** parameters and the to boolean arguments.
452
--- src/info.c
+++ src/info.c
@@ -441,11 +441,11 @@
441 /*
442 ** Generate javascript to enhance HTML diffs.
443 */
444 void append_diff_javascript(int sideBySide){
445 if( !sideBySide ) return;
446 builtin_request_js("diff.js");
447 }
448
449 /*
450 ** Construct an appropriate diffFlag for text_diff() based on query
451 ** parameters and the to boolean arguments.
452
--- src/main.mk
+++ src/main.mk
@@ -245,11 +245,10 @@
245245
$(SRCDIR)/hbmenu.js \
246246
$(SRCDIR)/href.js \
247247
$(SRCDIR)/login.js \
248248
$(SRCDIR)/markdown.md \
249249
$(SRCDIR)/menu.js \
250
- $(SRCDIR)/sbsdiff.js \
251250
$(SRCDIR)/scroll.js \
252251
$(SRCDIR)/skin.js \
253252
$(SRCDIR)/sorttable.js \
254253
$(SRCDIR)/sounds/0.wav \
255254
$(SRCDIR)/sounds/1.wav \
256255
257256
DELETED src/sbsdiff.js
--- src/main.mk
+++ src/main.mk
@@ -245,11 +245,10 @@
245 $(SRCDIR)/hbmenu.js \
246 $(SRCDIR)/href.js \
247 $(SRCDIR)/login.js \
248 $(SRCDIR)/markdown.md \
249 $(SRCDIR)/menu.js \
250 $(SRCDIR)/sbsdiff.js \
251 $(SRCDIR)/scroll.js \
252 $(SRCDIR)/skin.js \
253 $(SRCDIR)/sorttable.js \
254 $(SRCDIR)/sounds/0.wav \
255 $(SRCDIR)/sounds/1.wav \
256
257 ELETED src/sbsdiff.js
--- src/main.mk
+++ src/main.mk
@@ -245,11 +245,10 @@
245 $(SRCDIR)/hbmenu.js \
246 $(SRCDIR)/href.js \
247 $(SRCDIR)/login.js \
248 $(SRCDIR)/markdown.md \
249 $(SRCDIR)/menu.js \
 
250 $(SRCDIR)/scroll.js \
251 $(SRCDIR)/skin.js \
252 $(SRCDIR)/sorttable.js \
253 $(SRCDIR)/sounds/0.wav \
254 $(SRCDIR)/sounds/1.wav \
255
256 ELETED src/sbsdiff.js
D src/sbsdiff.js
-63
--- a/src/sbsdiff.js
+++ b/src/sbsdiff.js
@@ -1,63 +0,0 @@
1
-/* The javascript in this file was added by Joel Bruick on 2013-07-06,
2
-** originally as in-line javascript. It keeps the horizontal scrollbars
3
-** in sync on side-by-side diffs.
4
-*/
5
-(function(){
6
- var SCROLL_LEN = 25;
7
- function initSbsDiff(diff){
8
- var txtCols = diff.querySelectorAll('.difftxtcol');
9
- var txtPres = diff.querySelectorAll('.difftxtcol pre');
10
- var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
11
- var i;
12
- for(i=0; i<2; i++){
13
- txtPres[i].style.width = width + 'px';
14
- txtCols[i].onscroll = function(e){
15
- txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
16
- };
17
- }
18
- diff.tabIndex = 0;
19
- diff.onkeydown = function(e){
20
- e = e || event;
21
- var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
22
- if( !len ) return;
23
- txtCols[0].scrollLeft += len;
24
- return false;
25
- };
26
- }
27
- var i, diffs = document.querySelectorAll('.sbsdiffcols')
28
- /* Maintenance reminder: using forEach() here breaks
29
- MSIE<=11, and we need to keep those browsers working on
30
- the /info page. */;
31
- for(i=0; i<diffs.length; i++){
32
- initSbsDiff(diffs[i]);
33
- }
34
- if(window.fossil && fossil.page){
35
- /* Here we can use forEach() because the pages which use
36
- fossil.pages only work in HTML5-compliant browsers. */
37
- fossil.page.tweakSbsDiffs = function(){
38
- document.querySelectorAll('.sbsdiffcols').forEach(initSbsDiff);
39
- };
40
- }
41
- /* This part added by DRH on 2021-08-25 to adjust the width of the
42
- ** diff columns so that they fill the screen. */
43
- var lastWidth = 0;
44
- function checkWidth(){
45
- if( document.body.clientWidth!=lastWidth ){
46
- lastWidth = document.body.clientWidth;
47
- var w = lastWidth*0.5 - 100;
48
- var allCols = document.getElementsByClassName('difftxtcol');
49
- for(let i=0; i<allCols.length; i++){
50
- allCols[i].style.width = w + "px";
51
- allCols[i].style.maxWidth = w + "px";
52
- }
53
- var allDiffs = document.getElementsByClassName('sbsdiffcols');
54
- w = lastWidth;
55
- for(let i=0; i<allDiffs.length; i++){
56
- allDiffs[i].style.width = '98%'; // setting to w causes unsightly horiz. scrollbar
57
- allDiffs[i].style.maxWidth = w + "px";
58
- }
59
- }
60
- setTimeout(checkWidth, 100)
61
- }
62
- checkWidth();
63
-})();
--- a/src/sbsdiff.js
+++ b/src/sbsdiff.js
@@ -1,63 +0,0 @@
1 /* The javascript in this file was added by Joel Bruick on 2013-07-06,
2 ** originally as in-line javascript. It keeps the horizontal scrollbars
3 ** in sync on side-by-side diffs.
4 */
5 (function(){
6 var SCROLL_LEN = 25;
7 function initSbsDiff(diff){
8 var txtCols = diff.querySelectorAll('.difftxtcol');
9 var txtPres = diff.querySelectorAll('.difftxtcol pre');
10 var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
11 var i;
12 for(i=0; i<2; i++){
13 txtPres[i].style.width = width + 'px';
14 txtCols[i].onscroll = function(e){
15 txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
16 };
17 }
18 diff.tabIndex = 0;
19 diff.onkeydown = function(e){
20 e = e || event;
21 var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
22 if( !len ) return;
23 txtCols[0].scrollLeft += len;
24 return false;
25 };
26 }
27 var i, diffs = document.querySelectorAll('.sbsdiffcols')
28 /* Maintenance reminder: using forEach() here breaks
29 MSIE<=11, and we need to keep those browsers working on
30 the /info page. */;
31 for(i=0; i<diffs.length; i++){
32 initSbsDiff(diffs[i]);
33 }
34 if(window.fossil && fossil.page){
35 /* Here we can use forEach() because the pages which use
36 fossil.pages only work in HTML5-compliant browsers. */
37 fossil.page.tweakSbsDiffs = function(){
38 document.querySelectorAll('.sbsdiffcols').forEach(initSbsDiff);
39 };
40 }
41 /* This part added by DRH on 2021-08-25 to adjust the width of the
42 ** diff columns so that they fill the screen. */
43 var lastWidth = 0;
44 function checkWidth(){
45 if( document.body.clientWidth!=lastWidth ){
46 lastWidth = document.body.clientWidth;
47 var w = lastWidth*0.5 - 100;
48 var allCols = document.getElementsByClassName('difftxtcol');
49 for(let i=0; i<allCols.length; i++){
50 allCols[i].style.width = w + "px";
51 allCols[i].style.maxWidth = w + "px";
52 }
53 var allDiffs = document.getElementsByClassName('sbsdiffcols');
54 w = lastWidth;
55 for(let i=0; i<allDiffs.length; i++){
56 allDiffs[i].style.width = '98%'; // setting to w causes unsightly horiz. scrollbar
57 allDiffs[i].style.maxWidth = w + "px";
58 }
59 }
60 setTimeout(checkWidth, 100)
61 }
62 checkWidth();
63 })();
--- a/src/sbsdiff.js
+++ b/src/sbsdiff.js
@@ -1,63 +0,0 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
+1 -1
--- src/wiki.c
+++ src/wiki.c
@@ -1454,11 +1454,11 @@
14541454
CX("</div>"/*#wikiedit-tab-save*/);
14551455
}
14561456
builtin_fossil_js_bundle_or("fetch", "dom", "tabs", "confirmer",
14571457
"storage", "popupwidget", "copybutton",
14581458
"pikchr", NULL);
1459
- builtin_request_js("sbsdiff.js");
1459
+ builtin_request_js("diff.js");
14601460
builtin_request_js("fossil.page.wikiedit.js");
14611461
builtin_fulfill_js_requests();
14621462
/* Dynamically populate the editor... */
14631463
style_script_begin(__FILE__,__LINE__);
14641464
{
14651465
--- src/wiki.c
+++ src/wiki.c
@@ -1454,11 +1454,11 @@
1454 CX("</div>"/*#wikiedit-tab-save*/);
1455 }
1456 builtin_fossil_js_bundle_or("fetch", "dom", "tabs", "confirmer",
1457 "storage", "popupwidget", "copybutton",
1458 "pikchr", NULL);
1459 builtin_request_js("sbsdiff.js");
1460 builtin_request_js("fossil.page.wikiedit.js");
1461 builtin_fulfill_js_requests();
1462 /* Dynamically populate the editor... */
1463 style_script_begin(__FILE__,__LINE__);
1464 {
1465
--- src/wiki.c
+++ src/wiki.c
@@ -1454,11 +1454,11 @@
1454 CX("</div>"/*#wikiedit-tab-save*/);
1455 }
1456 builtin_fossil_js_bundle_or("fetch", "dom", "tabs", "confirmer",
1457 "storage", "popupwidget", "copybutton",
1458 "pikchr", NULL);
1459 builtin_request_js("diff.js");
1460 builtin_request_js("fossil.page.wikiedit.js");
1461 builtin_fulfill_js_requests();
1462 /* Dynamically populate the editor... */
1463 style_script_begin(__FILE__,__LINE__);
1464 {
1465
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -654,11 +654,10 @@
654654
$(SRCDIR)/hbmenu.js \
655655
$(SRCDIR)/href.js \
656656
$(SRCDIR)/login.js \
657657
$(SRCDIR)/markdown.md \
658658
$(SRCDIR)/menu.js \
659
- $(SRCDIR)/sbsdiff.js \
660659
$(SRCDIR)/scroll.js \
661660
$(SRCDIR)/skin.js \
662661
$(SRCDIR)/sorttable.js \
663662
$(SRCDIR)/sounds/0.wav \
664663
$(SRCDIR)/sounds/1.wav \
665664
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -654,11 +654,10 @@
654 $(SRCDIR)/hbmenu.js \
655 $(SRCDIR)/href.js \
656 $(SRCDIR)/login.js \
657 $(SRCDIR)/markdown.md \
658 $(SRCDIR)/menu.js \
659 $(SRCDIR)/sbsdiff.js \
660 $(SRCDIR)/scroll.js \
661 $(SRCDIR)/skin.js \
662 $(SRCDIR)/sorttable.js \
663 $(SRCDIR)/sounds/0.wav \
664 $(SRCDIR)/sounds/1.wav \
665
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -654,11 +654,10 @@
654 $(SRCDIR)/hbmenu.js \
655 $(SRCDIR)/href.js \
656 $(SRCDIR)/login.js \
657 $(SRCDIR)/markdown.md \
658 $(SRCDIR)/menu.js \
 
659 $(SRCDIR)/scroll.js \
660 $(SRCDIR)/skin.js \
661 $(SRCDIR)/sorttable.js \
662 $(SRCDIR)/sounds/0.wav \
663 $(SRCDIR)/sounds/1.wav \
664
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -596,11 +596,10 @@
596596
"$(SRCDIR)\hbmenu.js" \
597597
"$(SRCDIR)\href.js" \
598598
"$(SRCDIR)\login.js" \
599599
"$(SRCDIR)\markdown.md" \
600600
"$(SRCDIR)\menu.js" \
601
- "$(SRCDIR)\sbsdiff.js" \
602601
"$(SRCDIR)\scroll.js" \
603602
"$(SRCDIR)\skin.js" \
604603
"$(SRCDIR)\sorttable.js" \
605604
"$(SRCDIR)\sounds\0.wav" \
606605
"$(SRCDIR)\sounds\1.wav" \
@@ -1205,11 +1204,10 @@
12051204
echo "$(SRCDIR)\hbmenu.js" >> $@
12061205
echo "$(SRCDIR)\href.js" >> $@
12071206
echo "$(SRCDIR)\login.js" >> $@
12081207
echo "$(SRCDIR)\markdown.md" >> $@
12091208
echo "$(SRCDIR)\menu.js" >> $@
1210
- echo "$(SRCDIR)\sbsdiff.js" >> $@
12111209
echo "$(SRCDIR)\scroll.js" >> $@
12121210
echo "$(SRCDIR)\skin.js" >> $@
12131211
echo "$(SRCDIR)\sorttable.js" >> $@
12141212
echo "$(SRCDIR)\sounds/0.wav" >> $@
12151213
echo "$(SRCDIR)\sounds/1.wav" >> $@
12161214
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -596,11 +596,10 @@
596 "$(SRCDIR)\hbmenu.js" \
597 "$(SRCDIR)\href.js" \
598 "$(SRCDIR)\login.js" \
599 "$(SRCDIR)\markdown.md" \
600 "$(SRCDIR)\menu.js" \
601 "$(SRCDIR)\sbsdiff.js" \
602 "$(SRCDIR)\scroll.js" \
603 "$(SRCDIR)\skin.js" \
604 "$(SRCDIR)\sorttable.js" \
605 "$(SRCDIR)\sounds\0.wav" \
606 "$(SRCDIR)\sounds\1.wav" \
@@ -1205,11 +1204,10 @@
1205 echo "$(SRCDIR)\hbmenu.js" >> $@
1206 echo "$(SRCDIR)\href.js" >> $@
1207 echo "$(SRCDIR)\login.js" >> $@
1208 echo "$(SRCDIR)\markdown.md" >> $@
1209 echo "$(SRCDIR)\menu.js" >> $@
1210 echo "$(SRCDIR)\sbsdiff.js" >> $@
1211 echo "$(SRCDIR)\scroll.js" >> $@
1212 echo "$(SRCDIR)\skin.js" >> $@
1213 echo "$(SRCDIR)\sorttable.js" >> $@
1214 echo "$(SRCDIR)\sounds/0.wav" >> $@
1215 echo "$(SRCDIR)\sounds/1.wav" >> $@
1216
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -596,11 +596,10 @@
596 "$(SRCDIR)\hbmenu.js" \
597 "$(SRCDIR)\href.js" \
598 "$(SRCDIR)\login.js" \
599 "$(SRCDIR)\markdown.md" \
600 "$(SRCDIR)\menu.js" \
 
601 "$(SRCDIR)\scroll.js" \
602 "$(SRCDIR)\skin.js" \
603 "$(SRCDIR)\sorttable.js" \
604 "$(SRCDIR)\sounds\0.wav" \
605 "$(SRCDIR)\sounds\1.wav" \
@@ -1205,11 +1204,10 @@
1204 echo "$(SRCDIR)\hbmenu.js" >> $@
1205 echo "$(SRCDIR)\href.js" >> $@
1206 echo "$(SRCDIR)\login.js" >> $@
1207 echo "$(SRCDIR)\markdown.md" >> $@
1208 echo "$(SRCDIR)\menu.js" >> $@
 
1209 echo "$(SRCDIR)\scroll.js" >> $@
1210 echo "$(SRCDIR)\skin.js" >> $@
1211 echo "$(SRCDIR)\sorttable.js" >> $@
1212 echo "$(SRCDIR)\sounds/0.wav" >> $@
1213 echo "$(SRCDIR)\sounds/1.wav" >> $@
1214

Keyboard Shortcuts

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