Fossil SCM
Restore "const" before "DLine*" where possible in the diff generator. And even add some new instances of "const".
Commit
cf69ac4e394c668bedc1c868af684cf21b452e4eae2063332f4443b3ce12aed5
Parent
44b6f128453b350…
1 file changed
+53
-53
+53
-53
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -164,11 +164,11 @@ | ||
| 164 | 164 | int nEditAlloc; /* Space allocated for aEdit[] */ |
| 165 | 165 | DLine *aFrom; /* File on left side of the diff */ |
| 166 | 166 | int nFrom; /* Number of lines in aFrom[] */ |
| 167 | 167 | DLine *aTo; /* File on right side of the diff */ |
| 168 | 168 | int nTo; /* Number of lines in aTo[] */ |
| 169 | - int (*xDiffer)(DLine*,DLine*); /* comparison function */ | |
| 169 | + int (*xDiffer)(const DLine *,const DLine *); /* comparison function */ | |
| 170 | 170 | }; |
| 171 | 171 | |
| 172 | 172 | /* Fast isspace for use by diff */ |
| 173 | 173 | static const char diffIsSpace[] = { |
| 174 | 174 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, |
| @@ -313,11 +313,11 @@ | ||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /* |
| 316 | 316 | ** Return zero if two DLine elements are identical. |
| 317 | 317 | */ |
| 318 | -static int compare_dline(DLine *pA, DLine *pB){ | |
| 318 | +static int compare_dline(const DLine *pA, const DLine *pB){ | |
| 319 | 319 | if( pA->h!=pB->h ) return 1; |
| 320 | 320 | return memcmp(pA->z,pB->z, pA->h&LENGTH_MASK); |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /* |
| @@ -324,11 +324,11 @@ | ||
| 324 | 324 | ** Return zero if two DLine elements are identical, ignoring |
| 325 | 325 | ** all whitespace. The indent field of pA/pB already points |
| 326 | 326 | ** to the first non-space character in the string. |
| 327 | 327 | */ |
| 328 | 328 | |
| 329 | -static int compare_dline_ignore_allws(DLine *pA, DLine *pB){ | |
| 329 | +static int compare_dline_ignore_allws(const DLine *pA, const DLine *pB){ | |
| 330 | 330 | int a = pA->indent, b = pB->indent; |
| 331 | 331 | if( pA->h==pB->h ){ |
| 332 | 332 | while( a<pA->n || b<pB->n ){ |
| 333 | 333 | if( a<pA->n && b<pB->n && pA->z[a++] != pB->z[b++] ) return 1; |
| 334 | 334 | while( a<pA->n && diff_isspace(pA->z[a])) ++a; |
| @@ -343,11 +343,11 @@ | ||
| 343 | 343 | ** Return true if the regular expression *pRe matches any of the |
| 344 | 344 | ** N dlines |
| 345 | 345 | */ |
| 346 | 346 | static int re_dline_match( |
| 347 | 347 | ReCompiled *pRe, /* The regular expression to be matched */ |
| 348 | - DLine *aDLine, /* First of N DLines to compare against */ | |
| 348 | + const DLine *aDLine, /* First of N DLines to compare against */ | |
| 349 | 349 | int N /* Number of DLines to check */ |
| 350 | 350 | ){ |
| 351 | 351 | while( N-- ){ |
| 352 | 352 | if( re_match(pRe, (const unsigned char *)aDLine->z, LENGTH(aDLine)) ){ |
| 353 | 353 | return 1; |
| @@ -361,11 +361,11 @@ | ||
| 361 | 361 | ** Append a single line of context-diff output to pOut. |
| 362 | 362 | */ |
| 363 | 363 | static void appendDiffLine( |
| 364 | 364 | Blob *pOut, /* Where to write the line of output */ |
| 365 | 365 | char cPrefix, /* One of " ", "+", or "-" */ |
| 366 | - DLine *pLine /* The line to be output */ | |
| 366 | + const DLine *pLine /* The line to be output */ | |
| 367 | 367 | ){ |
| 368 | 368 | blob_append_char(pOut, cPrefix); |
| 369 | 369 | blob_append(pOut, pLine->z, pLine->n); |
| 370 | 370 | blob_append_char(pOut, '\n'); |
| 371 | 371 | } |
| @@ -394,14 +394,14 @@ | ||
| 394 | 394 | static void contextDiff( |
| 395 | 395 | DContext *p, /* The difference */ |
| 396 | 396 | Blob *pOut, /* Output a context diff to here */ |
| 397 | 397 | DiffConfig *pCfg /* Configuration options */ |
| 398 | 398 | ){ |
| 399 | - DLine *A; /* Left side of the diff */ | |
| 400 | - DLine *B; /* Right side of the diff */ | |
| 401 | - int a = 0; /* Index of next line in A[] */ | |
| 402 | - int b = 0; /* Index of next line in B[] */ | |
| 399 | + const DLine *A; /* Left side of the diff */ | |
| 400 | + const DLine *B; /* Right side of the diff */ | |
| 401 | + int a = 0; /* Index of next line in A[] */ | |
| 402 | + int b = 0; /* Index of next line in B[] */ | |
| 403 | 403 | int *R; /* Array of COPY/DELETE/INSERT triples */ |
| 404 | 404 | int r; /* Index into R[] */ |
| 405 | 405 | int nr; /* Number of COPY/DELETE/INSERT triples to process */ |
| 406 | 406 | int mxr; /* Maximum value for r */ |
| 407 | 407 | int na, nb; /* Number of lines shown from A and B */ |
| @@ -713,12 +713,12 @@ | ||
| 713 | 713 | ** |
| 714 | 714 | ** The result is written into the LineChange object given by the |
| 715 | 715 | ** third parameter. |
| 716 | 716 | */ |
| 717 | 717 | static void oneLineChange( |
| 718 | - DLine *pLeft, /* Left line of the change */ | |
| 719 | - DLine *pRight, /* Right line of the change */ | |
| 718 | + const DLine *pLeft, /* Left line of the change */ | |
| 719 | + const DLine *pRight, /* Right line of the change */ | |
| 720 | 720 | LineChange *p /* OUTPUT: Write the results here */ |
| 721 | 721 | ){ |
| 722 | 722 | int nLeft; /* Length of left line in bytes */ |
| 723 | 723 | int nRight; /* Length of right line in bytes */ |
| 724 | 724 | int nShort; /* Shortest of left and right */ |
| @@ -909,15 +909,15 @@ | ||
| 909 | 909 | ** in appropriate method implementations. |
| 910 | 910 | */ |
| 911 | 911 | typedef struct DiffBuilder DiffBuilder; |
| 912 | 912 | struct DiffBuilder { |
| 913 | 913 | void (*xSkip)(DiffBuilder*, unsigned int, int); |
| 914 | - void (*xCommon)(DiffBuilder*,DLine*); | |
| 915 | - void (*xInsert)(DiffBuilder*,DLine*); | |
| 916 | - void (*xDelete)(DiffBuilder*,DLine*); | |
| 917 | - void (*xReplace)(DiffBuilder*,DLine*, DLine*); | |
| 918 | - void (*xEdit)(DiffBuilder*,DLine*,DLine*); | |
| 914 | + void (*xCommon)(DiffBuilder*,const DLine*); | |
| 915 | + void (*xInsert)(DiffBuilder*,const DLine*); | |
| 916 | + void (*xDelete)(DiffBuilder*,const DLine*); | |
| 917 | + void (*xReplace)(DiffBuilder*,const DLine*,const DLine*); | |
| 918 | + void (*xEdit)(DiffBuilder*,const DLine*,const DLine*); | |
| 919 | 919 | void (*xEnd)(DiffBuilder*); |
| 920 | 920 | unsigned int lnLeft; /* Lines seen on the left (delete) side */ |
| 921 | 921 | unsigned int lnRight; /* Lines seen on the right (insert) side */ |
| 922 | 922 | unsigned int nPending; /* Number of pending lines */ |
| 923 | 923 | int eState; /* State of the output */ |
| @@ -939,35 +939,35 @@ | ||
| 939 | 939 | n, p->lnLeft+1, p->lnLeft+n, p->lnRight+1, p->lnRight+n, |
| 940 | 940 | isFinal ? " FINAL" : ""); |
| 941 | 941 | p->lnLeft += n; |
| 942 | 942 | p->lnRight += n; |
| 943 | 943 | } |
| 944 | -static void dfdebugCommon(DiffBuilder *p, DLine *pLine){ | |
| 944 | +static void dfdebugCommon(DiffBuilder *p, const DLine *pLine){ | |
| 945 | 945 | p->lnLeft++; |
| 946 | 946 | p->lnRight++; |
| 947 | 947 | blob_appendf(p->pOut, "COMMON %8u %8u %.*s\n", |
| 948 | 948 | p->lnLeft, p->lnRight, (int)pLine->n, pLine->z); |
| 949 | 949 | } |
| 950 | -static void dfdebugInsert(DiffBuilder *p, DLine *pLine){ | |
| 950 | +static void dfdebugInsert(DiffBuilder *p, const DLine *pLine){ | |
| 951 | 951 | p->lnRight++; |
| 952 | 952 | blob_appendf(p->pOut, "INSERT %8d %.*s\n", |
| 953 | 953 | p->lnRight, (int)pLine->n, pLine->z); |
| 954 | 954 | } |
| 955 | -static void dfdebugDelete(DiffBuilder *p, DLine *pLine){ | |
| 955 | +static void dfdebugDelete(DiffBuilder *p, const DLine *pLine){ | |
| 956 | 956 | p->lnLeft++; |
| 957 | 957 | blob_appendf(p->pOut, "DELETE %8u %.*s\n", |
| 958 | 958 | p->lnLeft, (int)pLine->n, pLine->z); |
| 959 | 959 | } |
| 960 | -static void dfdebugReplace(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 960 | +static void dfdebugReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 961 | 961 | p->lnLeft++; |
| 962 | 962 | p->lnRight++; |
| 963 | 963 | blob_appendf(p->pOut, "REPLACE %8u %.*s\n", |
| 964 | 964 | p->lnLeft, (int)pX->n, pX->z); |
| 965 | 965 | blob_appendf(p->pOut, " %8u %.*s\n", |
| 966 | 966 | p->lnRight, (int)pY->n, pY->z); |
| 967 | 967 | } |
| 968 | -static void dfdebugEdit(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 968 | +static void dfdebugEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 969 | 969 | int i, j; |
| 970 | 970 | int x; |
| 971 | 971 | LineChange chng; |
| 972 | 972 | p->lnLeft++; |
| 973 | 973 | p->lnRight++; |
| @@ -1055,33 +1055,33 @@ | ||
| 1055 | 1055 | ** additional string which is a common suffix. |
| 1056 | 1056 | */ |
| 1057 | 1057 | static void dftclSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1058 | 1058 | blob_appendf(p->pOut, "SKIP %u\n", n); |
| 1059 | 1059 | } |
| 1060 | -static void dftclCommon(DiffBuilder *p, DLine *pLine){ | |
| 1060 | +static void dftclCommon(DiffBuilder *p, const DLine *pLine){ | |
| 1061 | 1061 | blob_appendf(p->pOut, "COM "); |
| 1062 | 1062 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1063 | 1063 | blob_append_char(p->pOut, '\n'); |
| 1064 | 1064 | } |
| 1065 | -static void dftclInsert(DiffBuilder *p, DLine *pLine){ | |
| 1065 | +static void dftclInsert(DiffBuilder *p, const DLine *pLine){ | |
| 1066 | 1066 | blob_append(p->pOut, "INS ", -1); |
| 1067 | 1067 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1068 | 1068 | blob_append_char(p->pOut, '\n'); |
| 1069 | 1069 | } |
| 1070 | -static void dftclDelete(DiffBuilder *p, DLine *pLine){ | |
| 1070 | +static void dftclDelete(DiffBuilder *p, const DLine *pLine){ | |
| 1071 | 1071 | blob_append(p->pOut, "DEL ", -1); |
| 1072 | 1072 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1073 | 1073 | blob_append_char(p->pOut, '\n'); |
| 1074 | 1074 | } |
| 1075 | -static void dftclReplace(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1075 | +static void dftclReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1076 | 1076 | blob_append(p->pOut, "EDIT \"\" ", -1); |
| 1077 | 1077 | blob_append_tcl_literal(p->pOut, pX->z, pX->n); |
| 1078 | 1078 | blob_append_char(p->pOut, ' '); |
| 1079 | 1079 | blob_append_tcl_literal(p->pOut, pY->z, pY->n); |
| 1080 | 1080 | blob_append_char(p->pOut, '\n'); |
| 1081 | 1081 | } |
| 1082 | -static void dftclEdit(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1082 | +static void dftclEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1083 | 1083 | int i, x; |
| 1084 | 1084 | LineChange chng; |
| 1085 | 1085 | blob_append(p->pOut, "EDIT", 4); |
| 1086 | 1086 | oneLineChange(pX, pY, &chng); |
| 1087 | 1087 | for(i=x=0; i<chng.n; i++){ |
| @@ -1139,33 +1139,33 @@ | ||
| 1139 | 1139 | ** not apply. |
| 1140 | 1140 | */ |
| 1141 | 1141 | static void dfjsonSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1142 | 1142 | blob_appendf(p->pOut, "1,%u,\n", n); |
| 1143 | 1143 | } |
| 1144 | -static void dfjsonCommon(DiffBuilder *p, DLine *pLine){ | |
| 1144 | +static void dfjsonCommon(DiffBuilder *p, const DLine *pLine){ | |
| 1145 | 1145 | blob_append(p->pOut, "2,",2); |
| 1146 | 1146 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1147 | 1147 | blob_append(p->pOut, ",\n",2); |
| 1148 | 1148 | } |
| 1149 | -static void dfjsonInsert(DiffBuilder *p, DLine *pLine){ | |
| 1149 | +static void dfjsonInsert(DiffBuilder *p, const DLine *pLine){ | |
| 1150 | 1150 | blob_append(p->pOut, "3,",2); |
| 1151 | 1151 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1152 | 1152 | blob_append(p->pOut, ",\n",2); |
| 1153 | 1153 | } |
| 1154 | -static void dfjsonDelete(DiffBuilder *p, DLine *pLine){ | |
| 1154 | +static void dfjsonDelete(DiffBuilder *p, const DLine *pLine){ | |
| 1155 | 1155 | blob_append(p->pOut, "4,",2); |
| 1156 | 1156 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1157 | 1157 | blob_append(p->pOut, ",\n",2); |
| 1158 | 1158 | } |
| 1159 | -static void dfjsonReplace(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1159 | +static void dfjsonReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1160 | 1160 | blob_append(p->pOut, "5,[\"\",",-1); |
| 1161 | 1161 | blob_append_json_literal(p->pOut, pX->z, (int)pX->n); |
| 1162 | 1162 | blob_append(p->pOut, ",",1); |
| 1163 | 1163 | blob_append_json_literal(p->pOut, pY->z, (int)pY->n); |
| 1164 | 1164 | blob_append(p->pOut, ",\"\"],\n",-1); |
| 1165 | 1165 | } |
| 1166 | -static void dfjsonEdit(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1166 | +static void dfjsonEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1167 | 1167 | int i, x; |
| 1168 | 1168 | LineChange chng; |
| 1169 | 1169 | blob_append(p->pOut, "5,[", 3); |
| 1170 | 1170 | oneLineChange(pX, pY, &chng); |
| 1171 | 1171 | for(i=x=0; i<chng.n; i++){ |
| @@ -1294,11 +1294,11 @@ | ||
| 1294 | 1294 | blob_append(p->pOut, "<td class=\"diffln difflne\">" |
| 1295 | 1295 | "︙</td><td></td><td></td></tr>\n", -1); |
| 1296 | 1296 | p->lnLeft += n; |
| 1297 | 1297 | p->lnRight += n; |
| 1298 | 1298 | } |
| 1299 | -static void dfunifiedCommon(DiffBuilder *p, DLine *pLine){ | |
| 1299 | +static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){ | |
| 1300 | 1300 | dfunifiedStartRow(p); |
| 1301 | 1301 | dfunifiedFinishDelete(p); |
| 1302 | 1302 | dfunifiedFinishInsert(p); |
| 1303 | 1303 | p->lnLeft++; |
| 1304 | 1304 | p->lnRight++; |
| @@ -1306,20 +1306,20 @@ | ||
| 1306 | 1306 | blob_appendf(&p->aCol[0],"%d\n",p->lnRight); |
| 1307 | 1307 | blob_append_char(&p->aCol[1], '\n'); |
| 1308 | 1308 | htmlize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n); |
| 1309 | 1309 | blob_append_char(&p->aCol[2], '\n'); |
| 1310 | 1310 | } |
| 1311 | -static void dfunifiedInsert(DiffBuilder *p, DLine *pLine){ | |
| 1311 | +static void dfunifiedInsert(DiffBuilder *p, const DLine *pLine){ | |
| 1312 | 1312 | dfunifiedStartRow(p); |
| 1313 | 1313 | p->lnRight++; |
| 1314 | 1314 | blob_appendf(&p->aCol[3],"%d\n", p->lnRight); |
| 1315 | 1315 | blob_append(&p->aCol[4], "<ins>", 5); |
| 1316 | 1316 | htmlize_to_blob(&p->aCol[4], pLine->z, (int)pLine->n); |
| 1317 | 1317 | blob_append(&p->aCol[4], "</ins>\n", 7); |
| 1318 | 1318 | p->nPending++; |
| 1319 | 1319 | } |
| 1320 | -static void dfunifiedDelete(DiffBuilder *p, DLine *pLine){ | |
| 1320 | +static void dfunifiedDelete(DiffBuilder *p, const DLine *pLine){ | |
| 1321 | 1321 | dfunifiedStartRow(p); |
| 1322 | 1322 | dfunifiedFinishInsert(p); |
| 1323 | 1323 | if( p->eState==0 ){ |
| 1324 | 1324 | dfunifiedFinishInsert(p); |
| 1325 | 1325 | blob_append(p->pOut, "<del>", 5); |
| @@ -1332,11 +1332,11 @@ | ||
| 1332 | 1332 | blob_append(&p->aCol[1],"-\n",2); |
| 1333 | 1333 | blob_append(&p->aCol[2], "<del>", 5); |
| 1334 | 1334 | htmlize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n); |
| 1335 | 1335 | blob_append(&p->aCol[2], "</del>\n", 7); |
| 1336 | 1336 | } |
| 1337 | -static void dfunifiedReplace(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1337 | +static void dfunifiedReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1338 | 1338 | dfunifiedStartRow(p); |
| 1339 | 1339 | if( p->eState==0 ){ |
| 1340 | 1340 | dfunifiedFinishInsert(p); |
| 1341 | 1341 | blob_append(p->pOut, "<del>", 5); |
| 1342 | 1342 | blob_append(&p->aCol[2], "<del>", 5); |
| @@ -1355,11 +1355,11 @@ | ||
| 1355 | 1355 | |
| 1356 | 1356 | htmlize_to_blob(&p->aCol[4], pY->z, pY->n); |
| 1357 | 1357 | blob_append_char(&p->aCol[4], '\n'); |
| 1358 | 1358 | p->nPending++; |
| 1359 | 1359 | } |
| 1360 | -static void dfunifiedEdit(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1360 | +static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1361 | 1361 | int i; |
| 1362 | 1362 | int x; |
| 1363 | 1363 | LineChange chng; |
| 1364 | 1364 | oneLineChange(pX, pY, &chng); |
| 1365 | 1365 | dfunifiedStartRow(p); |
| @@ -1524,11 +1524,11 @@ | ||
| 1524 | 1524 | "<td class=\"diffln difflnr difflne\">︙</td>" |
| 1525 | 1525 | "<td/td></tr>\n", -1); |
| 1526 | 1526 | p->lnLeft += n; |
| 1527 | 1527 | p->lnRight += n; |
| 1528 | 1528 | } |
| 1529 | -static void dfsplitCommon(DiffBuilder *p, DLine *pLine){ | |
| 1529 | +static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){ | |
| 1530 | 1530 | dfsplitStartRow(p); |
| 1531 | 1531 | dfsplitChangeState(p, 0); |
| 1532 | 1532 | p->lnLeft++; |
| 1533 | 1533 | p->lnRight++; |
| 1534 | 1534 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| @@ -1537,11 +1537,11 @@ | ||
| 1537 | 1537 | blob_append_char(&p->aCol[1], '\n'); |
| 1538 | 1538 | blob_appendf(&p->aCol[2],"%d\n",p->lnRight); |
| 1539 | 1539 | htmlize_to_blob(&p->aCol[3], pLine->z, (int)pLine->n); |
| 1540 | 1540 | blob_append_char(&p->aCol[3], '\n'); |
| 1541 | 1541 | } |
| 1542 | -static void dfsplitInsert(DiffBuilder *p, DLine *pLine){ | |
| 1542 | +static void dfsplitInsert(DiffBuilder *p, const DLine *pLine){ | |
| 1543 | 1543 | dfsplitStartRow(p); |
| 1544 | 1544 | dfsplitChangeState(p, 2); |
| 1545 | 1545 | p->lnRight++; |
| 1546 | 1546 | blob_append_char(p->pOut, '\n'); |
| 1547 | 1547 | blob_append_char(&p->aCol[0], '\n'); |
| @@ -1549,11 +1549,11 @@ | ||
| 1549 | 1549 | blob_appendf(&p->aCol[2],"%d\n", p->lnRight); |
| 1550 | 1550 | blob_append(&p->aCol[3], "<ins>", 5); |
| 1551 | 1551 | htmlize_to_blob(&p->aCol[3], pLine->z, (int)pLine->n); |
| 1552 | 1552 | blob_append(&p->aCol[3], "</ins>\n", 7); |
| 1553 | 1553 | } |
| 1554 | -static void dfsplitDelete(DiffBuilder *p, DLine *pLine){ | |
| 1554 | +static void dfsplitDelete(DiffBuilder *p, const DLine *pLine){ | |
| 1555 | 1555 | dfsplitStartRow(p); |
| 1556 | 1556 | dfsplitChangeState(p, 1); |
| 1557 | 1557 | p->lnLeft++; |
| 1558 | 1558 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| 1559 | 1559 | blob_append(&p->aCol[0], "<del>", 5); |
| @@ -1561,11 +1561,11 @@ | ||
| 1561 | 1561 | blob_append(&p->aCol[0], "</del>\n", 7); |
| 1562 | 1562 | blob_append(&p->aCol[1], "<\n", -1); |
| 1563 | 1563 | blob_append_char(&p->aCol[2],'\n'); |
| 1564 | 1564 | blob_append_char(&p->aCol[3],'\n'); |
| 1565 | 1565 | } |
| 1566 | -static void dfsplitReplace(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1566 | +static void dfsplitReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1567 | 1567 | dfsplitStartRow(p); |
| 1568 | 1568 | dfsplitChangeState(p, 3); |
| 1569 | 1569 | p->lnLeft++; |
| 1570 | 1570 | p->lnRight++; |
| 1571 | 1571 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| @@ -1577,11 +1577,11 @@ | ||
| 1577 | 1577 | blob_appendf(&p->aCol[2],"%d\n", p->lnRight); |
| 1578 | 1578 | |
| 1579 | 1579 | htmlize_to_blob(&p->aCol[3], pY->z, pY->n); |
| 1580 | 1580 | blob_append_char(&p->aCol[3], '\n'); |
| 1581 | 1581 | } |
| 1582 | -static void dfsplitEdit(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1582 | +static void dfsplitEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1583 | 1583 | int i; |
| 1584 | 1584 | int x; |
| 1585 | 1585 | LineChange chng; |
| 1586 | 1586 | oneLineChange(pX, pY, &chng); |
| 1587 | 1587 | dfsplitStartRow(p); |
| @@ -1679,11 +1679,11 @@ | ||
| 1679 | 1679 | ** from pX onto the into of p. |
| 1680 | 1680 | ** |
| 1681 | 1681 | ** This comment contains multibyte unicode characters (ü, Æ, ð) in order |
| 1682 | 1682 | ** to test the ability of the diff code to handle such characters. |
| 1683 | 1683 | */ |
| 1684 | -static void sbs_append_chars(Blob *p, int iMin, int iMax, DLine *pX){ | |
| 1684 | +static void sbs_append_chars(Blob *p, int iMin, int iMax, const DLine *pX){ | |
| 1685 | 1685 | int i; |
| 1686 | 1686 | const char *z = pX->z; |
| 1687 | 1687 | for(i=0; i<iMax && i<pX->n; i++){ |
| 1688 | 1688 | char c = z[i]; |
| 1689 | 1689 | blob_append_char(p, c); |
| @@ -1693,33 +1693,33 @@ | ||
| 1693 | 1693 | blob_append_char(p, ' '); |
| 1694 | 1694 | i++; |
| 1695 | 1695 | } |
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | -static void dfsbsCommon(DiffBuilder *p, DLine *pLine){ | |
| 1698 | +static void dfsbsCommon(DiffBuilder *p, const DLine *pLine){ | |
| 1699 | 1699 | p->lnLeft++; |
| 1700 | 1700 | p->lnRight++; |
| 1701 | 1701 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1702 | 1702 | sbs_append_chars(p->pOut, p->width, p->width, pLine); |
| 1703 | 1703 | blob_appendf(p->pOut," %6u ", p->lnRight); |
| 1704 | 1704 | sbs_append_chars(p->pOut, 0, p->width, pLine); |
| 1705 | 1705 | blob_append_char(p->pOut, '\n'); |
| 1706 | 1706 | } |
| 1707 | -static void dfsbsInsert(DiffBuilder *p, DLine *pLine){ | |
| 1707 | +static void dfsbsInsert(DiffBuilder *p, const DLine *pLine){ | |
| 1708 | 1708 | p->lnRight++; |
| 1709 | 1709 | blob_appendf(p->pOut,"%6s %*s > %6u ", |
| 1710 | 1710 | "", p->width, "", p->lnRight); |
| 1711 | 1711 | sbs_append_chars(p->pOut, 0, p->width, pLine); |
| 1712 | 1712 | blob_append_char(p->pOut, '\n'); |
| 1713 | 1713 | } |
| 1714 | -static void dfsbsDelete(DiffBuilder *p, DLine *pLine){ | |
| 1714 | +static void dfsbsDelete(DiffBuilder *p, const DLine *pLine){ | |
| 1715 | 1715 | p->lnLeft++; |
| 1716 | 1716 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1717 | 1717 | sbs_append_chars(p->pOut, p->width, p->width, pLine); |
| 1718 | 1718 | blob_append(p->pOut," <\n", 3); |
| 1719 | 1719 | } |
| 1720 | -static void dfsbsEdit(DiffBuilder *p, DLine *pX, DLine *pY){ | |
| 1720 | +static void dfsbsEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ | |
| 1721 | 1721 | p->lnLeft++; |
| 1722 | 1722 | p->lnRight++; |
| 1723 | 1723 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1724 | 1724 | sbs_append_chars(p->pOut, p->width, p->width, pX); |
| 1725 | 1725 | blob_appendf(p->pOut, " | %6u ", p->lnRight); |
| @@ -1887,12 +1887,12 @@ | ||
| 1887 | 1887 | ** mismatch. |
| 1888 | 1888 | */ |
| 1889 | 1889 | static unsigned char *diffBlockAlignment( |
| 1890 | 1890 | DLine *aLeft, int nLeft, /* Text on the left */ |
| 1891 | 1891 | DLine *aRight, int nRight, /* Text on the right */ |
| 1892 | - DiffConfig *pCfg, /* Configuration options */ | |
| 1893 | - int *pNResult /* OUTPUT: Bytes of result */ | |
| 1892 | + DiffConfig *pCfg, /* Configuration options */ | |
| 1893 | + int *pNResult /* OUTPUT: Bytes of result */ | |
| 1894 | 1894 | ){ |
| 1895 | 1895 | int i, j, k; /* Loop counters */ |
| 1896 | 1896 | int *a; /* One row of the Wagner matrix */ |
| 1897 | 1897 | int *pToFree; /* Space that needs to be freed */ |
| 1898 | 1898 | unsigned char *aM; /* Wagner result matrix */ |
| @@ -1916,13 +1916,13 @@ | ||
| 1916 | 1916 | ** O(NlogN). The result is not as precise, but this whole thing is an |
| 1917 | 1917 | ** approximation anyhow, and the faster response time is an acceptable |
| 1918 | 1918 | ** trade-off for reduced precision. |
| 1919 | 1919 | */ |
| 1920 | 1920 | if( nLeft*nRight>DIFF_ALIGN_MX && (pCfg->diffFlags & DIFF_SLOW_SBS)==0 ){ |
| 1921 | - DLine *aSmall; /* The smaller of aLeft and aRight */ | |
| 1922 | - DLine *aBig; /* The larger of aLeft and aRight */ | |
| 1923 | - int nSmall, nBig; /* Size of aSmall and aBig. nSmall<=nBig */ | |
| 1921 | + DLine *aSmall; /* The smaller of aLeft and aRight */ | |
| 1922 | + DLine *aBig; /* The larger of aLeft and aRight */ | |
| 1923 | + int nSmall, nBig; /* Size of aSmall and aBig. nSmall<=nBig */ | |
| 1924 | 1924 | int iDivSmall, iDivBig; /* Divider point for aSmall and aBig */ |
| 1925 | 1925 | int iDivLeft, iDivRight; /* Divider point for aLeft and aRight */ |
| 1926 | 1926 | unsigned char *a1, *a2; /* Results of the alignments on two halves */ |
| 1927 | 1927 | int n1, n2; /* Number of entries in a1 and a2 */ |
| 1928 | 1928 | int score, bestScore; /* Score and best score seen so far */ |
| @@ -2061,12 +2061,12 @@ | ||
| 2061 | 2061 | static void formatDiff( |
| 2062 | 2062 | DContext *p, /* The computed diff */ |
| 2063 | 2063 | DiffConfig *pCfg, /* Configuration options */ |
| 2064 | 2064 | DiffBuilder *pBuilder /* The formatter object */ |
| 2065 | 2065 | ){ |
| 2066 | - DLine *A; /* Left side of the diff */ | |
| 2067 | - DLine *B; /* Right side of the diff */ | |
| 2066 | + DLine *A; /* Left side of the diff */ | |
| 2067 | + DLine *B; /* Right side of the diff */ | |
| 2068 | 2068 | unsigned int a = 0; /* Index of next line in A[] */ |
| 2069 | 2069 | unsigned int b = 0; /* Index of next line in B[] */ |
| 2070 | 2070 | const int *R; /* Array of COPY/DELETE/INSERT triples */ |
| 2071 | 2071 | unsigned int r; /* Index into R[] */ |
| 2072 | 2072 | unsigned int nr; /* Number of COPY/DELETE/INSERT triples to process */ |
| 2073 | 2073 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -164,11 +164,11 @@ | |
| 164 | int nEditAlloc; /* Space allocated for aEdit[] */ |
| 165 | DLine *aFrom; /* File on left side of the diff */ |
| 166 | int nFrom; /* Number of lines in aFrom[] */ |
| 167 | DLine *aTo; /* File on right side of the diff */ |
| 168 | int nTo; /* Number of lines in aTo[] */ |
| 169 | int (*xDiffer)(DLine*,DLine*); /* comparison function */ |
| 170 | }; |
| 171 | |
| 172 | /* Fast isspace for use by diff */ |
| 173 | static const char diffIsSpace[] = { |
| 174 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, |
| @@ -313,11 +313,11 @@ | |
| 313 | } |
| 314 | |
| 315 | /* |
| 316 | ** Return zero if two DLine elements are identical. |
| 317 | */ |
| 318 | static int compare_dline(DLine *pA, DLine *pB){ |
| 319 | if( pA->h!=pB->h ) return 1; |
| 320 | return memcmp(pA->z,pB->z, pA->h&LENGTH_MASK); |
| 321 | } |
| 322 | |
| 323 | /* |
| @@ -324,11 +324,11 @@ | |
| 324 | ** Return zero if two DLine elements are identical, ignoring |
| 325 | ** all whitespace. The indent field of pA/pB already points |
| 326 | ** to the first non-space character in the string. |
| 327 | */ |
| 328 | |
| 329 | static int compare_dline_ignore_allws(DLine *pA, DLine *pB){ |
| 330 | int a = pA->indent, b = pB->indent; |
| 331 | if( pA->h==pB->h ){ |
| 332 | while( a<pA->n || b<pB->n ){ |
| 333 | if( a<pA->n && b<pB->n && pA->z[a++] != pB->z[b++] ) return 1; |
| 334 | while( a<pA->n && diff_isspace(pA->z[a])) ++a; |
| @@ -343,11 +343,11 @@ | |
| 343 | ** Return true if the regular expression *pRe matches any of the |
| 344 | ** N dlines |
| 345 | */ |
| 346 | static int re_dline_match( |
| 347 | ReCompiled *pRe, /* The regular expression to be matched */ |
| 348 | DLine *aDLine, /* First of N DLines to compare against */ |
| 349 | int N /* Number of DLines to check */ |
| 350 | ){ |
| 351 | while( N-- ){ |
| 352 | if( re_match(pRe, (const unsigned char *)aDLine->z, LENGTH(aDLine)) ){ |
| 353 | return 1; |
| @@ -361,11 +361,11 @@ | |
| 361 | ** Append a single line of context-diff output to pOut. |
| 362 | */ |
| 363 | static void appendDiffLine( |
| 364 | Blob *pOut, /* Where to write the line of output */ |
| 365 | char cPrefix, /* One of " ", "+", or "-" */ |
| 366 | DLine *pLine /* The line to be output */ |
| 367 | ){ |
| 368 | blob_append_char(pOut, cPrefix); |
| 369 | blob_append(pOut, pLine->z, pLine->n); |
| 370 | blob_append_char(pOut, '\n'); |
| 371 | } |
| @@ -394,14 +394,14 @@ | |
| 394 | static void contextDiff( |
| 395 | DContext *p, /* The difference */ |
| 396 | Blob *pOut, /* Output a context diff to here */ |
| 397 | DiffConfig *pCfg /* Configuration options */ |
| 398 | ){ |
| 399 | DLine *A; /* Left side of the diff */ |
| 400 | DLine *B; /* Right side of the diff */ |
| 401 | int a = 0; /* Index of next line in A[] */ |
| 402 | int b = 0; /* Index of next line in B[] */ |
| 403 | int *R; /* Array of COPY/DELETE/INSERT triples */ |
| 404 | int r; /* Index into R[] */ |
| 405 | int nr; /* Number of COPY/DELETE/INSERT triples to process */ |
| 406 | int mxr; /* Maximum value for r */ |
| 407 | int na, nb; /* Number of lines shown from A and B */ |
| @@ -713,12 +713,12 @@ | |
| 713 | ** |
| 714 | ** The result is written into the LineChange object given by the |
| 715 | ** third parameter. |
| 716 | */ |
| 717 | static void oneLineChange( |
| 718 | DLine *pLeft, /* Left line of the change */ |
| 719 | DLine *pRight, /* Right line of the change */ |
| 720 | LineChange *p /* OUTPUT: Write the results here */ |
| 721 | ){ |
| 722 | int nLeft; /* Length of left line in bytes */ |
| 723 | int nRight; /* Length of right line in bytes */ |
| 724 | int nShort; /* Shortest of left and right */ |
| @@ -909,15 +909,15 @@ | |
| 909 | ** in appropriate method implementations. |
| 910 | */ |
| 911 | typedef struct DiffBuilder DiffBuilder; |
| 912 | struct DiffBuilder { |
| 913 | void (*xSkip)(DiffBuilder*, unsigned int, int); |
| 914 | void (*xCommon)(DiffBuilder*,DLine*); |
| 915 | void (*xInsert)(DiffBuilder*,DLine*); |
| 916 | void (*xDelete)(DiffBuilder*,DLine*); |
| 917 | void (*xReplace)(DiffBuilder*,DLine*, DLine*); |
| 918 | void (*xEdit)(DiffBuilder*,DLine*,DLine*); |
| 919 | void (*xEnd)(DiffBuilder*); |
| 920 | unsigned int lnLeft; /* Lines seen on the left (delete) side */ |
| 921 | unsigned int lnRight; /* Lines seen on the right (insert) side */ |
| 922 | unsigned int nPending; /* Number of pending lines */ |
| 923 | int eState; /* State of the output */ |
| @@ -939,35 +939,35 @@ | |
| 939 | n, p->lnLeft+1, p->lnLeft+n, p->lnRight+1, p->lnRight+n, |
| 940 | isFinal ? " FINAL" : ""); |
| 941 | p->lnLeft += n; |
| 942 | p->lnRight += n; |
| 943 | } |
| 944 | static void dfdebugCommon(DiffBuilder *p, DLine *pLine){ |
| 945 | p->lnLeft++; |
| 946 | p->lnRight++; |
| 947 | blob_appendf(p->pOut, "COMMON %8u %8u %.*s\n", |
| 948 | p->lnLeft, p->lnRight, (int)pLine->n, pLine->z); |
| 949 | } |
| 950 | static void dfdebugInsert(DiffBuilder *p, DLine *pLine){ |
| 951 | p->lnRight++; |
| 952 | blob_appendf(p->pOut, "INSERT %8d %.*s\n", |
| 953 | p->lnRight, (int)pLine->n, pLine->z); |
| 954 | } |
| 955 | static void dfdebugDelete(DiffBuilder *p, DLine *pLine){ |
| 956 | p->lnLeft++; |
| 957 | blob_appendf(p->pOut, "DELETE %8u %.*s\n", |
| 958 | p->lnLeft, (int)pLine->n, pLine->z); |
| 959 | } |
| 960 | static void dfdebugReplace(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 961 | p->lnLeft++; |
| 962 | p->lnRight++; |
| 963 | blob_appendf(p->pOut, "REPLACE %8u %.*s\n", |
| 964 | p->lnLeft, (int)pX->n, pX->z); |
| 965 | blob_appendf(p->pOut, " %8u %.*s\n", |
| 966 | p->lnRight, (int)pY->n, pY->z); |
| 967 | } |
| 968 | static void dfdebugEdit(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 969 | int i, j; |
| 970 | int x; |
| 971 | LineChange chng; |
| 972 | p->lnLeft++; |
| 973 | p->lnRight++; |
| @@ -1055,33 +1055,33 @@ | |
| 1055 | ** additional string which is a common suffix. |
| 1056 | */ |
| 1057 | static void dftclSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1058 | blob_appendf(p->pOut, "SKIP %u\n", n); |
| 1059 | } |
| 1060 | static void dftclCommon(DiffBuilder *p, DLine *pLine){ |
| 1061 | blob_appendf(p->pOut, "COM "); |
| 1062 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1063 | blob_append_char(p->pOut, '\n'); |
| 1064 | } |
| 1065 | static void dftclInsert(DiffBuilder *p, DLine *pLine){ |
| 1066 | blob_append(p->pOut, "INS ", -1); |
| 1067 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1068 | blob_append_char(p->pOut, '\n'); |
| 1069 | } |
| 1070 | static void dftclDelete(DiffBuilder *p, DLine *pLine){ |
| 1071 | blob_append(p->pOut, "DEL ", -1); |
| 1072 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1073 | blob_append_char(p->pOut, '\n'); |
| 1074 | } |
| 1075 | static void dftclReplace(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1076 | blob_append(p->pOut, "EDIT \"\" ", -1); |
| 1077 | blob_append_tcl_literal(p->pOut, pX->z, pX->n); |
| 1078 | blob_append_char(p->pOut, ' '); |
| 1079 | blob_append_tcl_literal(p->pOut, pY->z, pY->n); |
| 1080 | blob_append_char(p->pOut, '\n'); |
| 1081 | } |
| 1082 | static void dftclEdit(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1083 | int i, x; |
| 1084 | LineChange chng; |
| 1085 | blob_append(p->pOut, "EDIT", 4); |
| 1086 | oneLineChange(pX, pY, &chng); |
| 1087 | for(i=x=0; i<chng.n; i++){ |
| @@ -1139,33 +1139,33 @@ | |
| 1139 | ** not apply. |
| 1140 | */ |
| 1141 | static void dfjsonSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1142 | blob_appendf(p->pOut, "1,%u,\n", n); |
| 1143 | } |
| 1144 | static void dfjsonCommon(DiffBuilder *p, DLine *pLine){ |
| 1145 | blob_append(p->pOut, "2,",2); |
| 1146 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1147 | blob_append(p->pOut, ",\n",2); |
| 1148 | } |
| 1149 | static void dfjsonInsert(DiffBuilder *p, DLine *pLine){ |
| 1150 | blob_append(p->pOut, "3,",2); |
| 1151 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1152 | blob_append(p->pOut, ",\n",2); |
| 1153 | } |
| 1154 | static void dfjsonDelete(DiffBuilder *p, DLine *pLine){ |
| 1155 | blob_append(p->pOut, "4,",2); |
| 1156 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1157 | blob_append(p->pOut, ",\n",2); |
| 1158 | } |
| 1159 | static void dfjsonReplace(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1160 | blob_append(p->pOut, "5,[\"\",",-1); |
| 1161 | blob_append_json_literal(p->pOut, pX->z, (int)pX->n); |
| 1162 | blob_append(p->pOut, ",",1); |
| 1163 | blob_append_json_literal(p->pOut, pY->z, (int)pY->n); |
| 1164 | blob_append(p->pOut, ",\"\"],\n",-1); |
| 1165 | } |
| 1166 | static void dfjsonEdit(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1167 | int i, x; |
| 1168 | LineChange chng; |
| 1169 | blob_append(p->pOut, "5,[", 3); |
| 1170 | oneLineChange(pX, pY, &chng); |
| 1171 | for(i=x=0; i<chng.n; i++){ |
| @@ -1294,11 +1294,11 @@ | |
| 1294 | blob_append(p->pOut, "<td class=\"diffln difflne\">" |
| 1295 | "︙</td><td></td><td></td></tr>\n", -1); |
| 1296 | p->lnLeft += n; |
| 1297 | p->lnRight += n; |
| 1298 | } |
| 1299 | static void dfunifiedCommon(DiffBuilder *p, DLine *pLine){ |
| 1300 | dfunifiedStartRow(p); |
| 1301 | dfunifiedFinishDelete(p); |
| 1302 | dfunifiedFinishInsert(p); |
| 1303 | p->lnLeft++; |
| 1304 | p->lnRight++; |
| @@ -1306,20 +1306,20 @@ | |
| 1306 | blob_appendf(&p->aCol[0],"%d\n",p->lnRight); |
| 1307 | blob_append_char(&p->aCol[1], '\n'); |
| 1308 | htmlize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n); |
| 1309 | blob_append_char(&p->aCol[2], '\n'); |
| 1310 | } |
| 1311 | static void dfunifiedInsert(DiffBuilder *p, DLine *pLine){ |
| 1312 | dfunifiedStartRow(p); |
| 1313 | p->lnRight++; |
| 1314 | blob_appendf(&p->aCol[3],"%d\n", p->lnRight); |
| 1315 | blob_append(&p->aCol[4], "<ins>", 5); |
| 1316 | htmlize_to_blob(&p->aCol[4], pLine->z, (int)pLine->n); |
| 1317 | blob_append(&p->aCol[4], "</ins>\n", 7); |
| 1318 | p->nPending++; |
| 1319 | } |
| 1320 | static void dfunifiedDelete(DiffBuilder *p, DLine *pLine){ |
| 1321 | dfunifiedStartRow(p); |
| 1322 | dfunifiedFinishInsert(p); |
| 1323 | if( p->eState==0 ){ |
| 1324 | dfunifiedFinishInsert(p); |
| 1325 | blob_append(p->pOut, "<del>", 5); |
| @@ -1332,11 +1332,11 @@ | |
| 1332 | blob_append(&p->aCol[1],"-\n",2); |
| 1333 | blob_append(&p->aCol[2], "<del>", 5); |
| 1334 | htmlize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n); |
| 1335 | blob_append(&p->aCol[2], "</del>\n", 7); |
| 1336 | } |
| 1337 | static void dfunifiedReplace(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1338 | dfunifiedStartRow(p); |
| 1339 | if( p->eState==0 ){ |
| 1340 | dfunifiedFinishInsert(p); |
| 1341 | blob_append(p->pOut, "<del>", 5); |
| 1342 | blob_append(&p->aCol[2], "<del>", 5); |
| @@ -1355,11 +1355,11 @@ | |
| 1355 | |
| 1356 | htmlize_to_blob(&p->aCol[4], pY->z, pY->n); |
| 1357 | blob_append_char(&p->aCol[4], '\n'); |
| 1358 | p->nPending++; |
| 1359 | } |
| 1360 | static void dfunifiedEdit(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1361 | int i; |
| 1362 | int x; |
| 1363 | LineChange chng; |
| 1364 | oneLineChange(pX, pY, &chng); |
| 1365 | dfunifiedStartRow(p); |
| @@ -1524,11 +1524,11 @@ | |
| 1524 | "<td class=\"diffln difflnr difflne\">︙</td>" |
| 1525 | "<td/td></tr>\n", -1); |
| 1526 | p->lnLeft += n; |
| 1527 | p->lnRight += n; |
| 1528 | } |
| 1529 | static void dfsplitCommon(DiffBuilder *p, DLine *pLine){ |
| 1530 | dfsplitStartRow(p); |
| 1531 | dfsplitChangeState(p, 0); |
| 1532 | p->lnLeft++; |
| 1533 | p->lnRight++; |
| 1534 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| @@ -1537,11 +1537,11 @@ | |
| 1537 | blob_append_char(&p->aCol[1], '\n'); |
| 1538 | blob_appendf(&p->aCol[2],"%d\n",p->lnRight); |
| 1539 | htmlize_to_blob(&p->aCol[3], pLine->z, (int)pLine->n); |
| 1540 | blob_append_char(&p->aCol[3], '\n'); |
| 1541 | } |
| 1542 | static void dfsplitInsert(DiffBuilder *p, DLine *pLine){ |
| 1543 | dfsplitStartRow(p); |
| 1544 | dfsplitChangeState(p, 2); |
| 1545 | p->lnRight++; |
| 1546 | blob_append_char(p->pOut, '\n'); |
| 1547 | blob_append_char(&p->aCol[0], '\n'); |
| @@ -1549,11 +1549,11 @@ | |
| 1549 | blob_appendf(&p->aCol[2],"%d\n", p->lnRight); |
| 1550 | blob_append(&p->aCol[3], "<ins>", 5); |
| 1551 | htmlize_to_blob(&p->aCol[3], pLine->z, (int)pLine->n); |
| 1552 | blob_append(&p->aCol[3], "</ins>\n", 7); |
| 1553 | } |
| 1554 | static void dfsplitDelete(DiffBuilder *p, DLine *pLine){ |
| 1555 | dfsplitStartRow(p); |
| 1556 | dfsplitChangeState(p, 1); |
| 1557 | p->lnLeft++; |
| 1558 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| 1559 | blob_append(&p->aCol[0], "<del>", 5); |
| @@ -1561,11 +1561,11 @@ | |
| 1561 | blob_append(&p->aCol[0], "</del>\n", 7); |
| 1562 | blob_append(&p->aCol[1], "<\n", -1); |
| 1563 | blob_append_char(&p->aCol[2],'\n'); |
| 1564 | blob_append_char(&p->aCol[3],'\n'); |
| 1565 | } |
| 1566 | static void dfsplitReplace(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1567 | dfsplitStartRow(p); |
| 1568 | dfsplitChangeState(p, 3); |
| 1569 | p->lnLeft++; |
| 1570 | p->lnRight++; |
| 1571 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| @@ -1577,11 +1577,11 @@ | |
| 1577 | blob_appendf(&p->aCol[2],"%d\n", p->lnRight); |
| 1578 | |
| 1579 | htmlize_to_blob(&p->aCol[3], pY->z, pY->n); |
| 1580 | blob_append_char(&p->aCol[3], '\n'); |
| 1581 | } |
| 1582 | static void dfsplitEdit(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1583 | int i; |
| 1584 | int x; |
| 1585 | LineChange chng; |
| 1586 | oneLineChange(pX, pY, &chng); |
| 1587 | dfsplitStartRow(p); |
| @@ -1679,11 +1679,11 @@ | |
| 1679 | ** from pX onto the into of p. |
| 1680 | ** |
| 1681 | ** This comment contains multibyte unicode characters (ü, Æ, ð) in order |
| 1682 | ** to test the ability of the diff code to handle such characters. |
| 1683 | */ |
| 1684 | static void sbs_append_chars(Blob *p, int iMin, int iMax, DLine *pX){ |
| 1685 | int i; |
| 1686 | const char *z = pX->z; |
| 1687 | for(i=0; i<iMax && i<pX->n; i++){ |
| 1688 | char c = z[i]; |
| 1689 | blob_append_char(p, c); |
| @@ -1693,33 +1693,33 @@ | |
| 1693 | blob_append_char(p, ' '); |
| 1694 | i++; |
| 1695 | } |
| 1696 | } |
| 1697 | |
| 1698 | static void dfsbsCommon(DiffBuilder *p, DLine *pLine){ |
| 1699 | p->lnLeft++; |
| 1700 | p->lnRight++; |
| 1701 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1702 | sbs_append_chars(p->pOut, p->width, p->width, pLine); |
| 1703 | blob_appendf(p->pOut," %6u ", p->lnRight); |
| 1704 | sbs_append_chars(p->pOut, 0, p->width, pLine); |
| 1705 | blob_append_char(p->pOut, '\n'); |
| 1706 | } |
| 1707 | static void dfsbsInsert(DiffBuilder *p, DLine *pLine){ |
| 1708 | p->lnRight++; |
| 1709 | blob_appendf(p->pOut,"%6s %*s > %6u ", |
| 1710 | "", p->width, "", p->lnRight); |
| 1711 | sbs_append_chars(p->pOut, 0, p->width, pLine); |
| 1712 | blob_append_char(p->pOut, '\n'); |
| 1713 | } |
| 1714 | static void dfsbsDelete(DiffBuilder *p, DLine *pLine){ |
| 1715 | p->lnLeft++; |
| 1716 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1717 | sbs_append_chars(p->pOut, p->width, p->width, pLine); |
| 1718 | blob_append(p->pOut," <\n", 3); |
| 1719 | } |
| 1720 | static void dfsbsEdit(DiffBuilder *p, DLine *pX, DLine *pY){ |
| 1721 | p->lnLeft++; |
| 1722 | p->lnRight++; |
| 1723 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1724 | sbs_append_chars(p->pOut, p->width, p->width, pX); |
| 1725 | blob_appendf(p->pOut, " | %6u ", p->lnRight); |
| @@ -1887,12 +1887,12 @@ | |
| 1887 | ** mismatch. |
| 1888 | */ |
| 1889 | static unsigned char *diffBlockAlignment( |
| 1890 | DLine *aLeft, int nLeft, /* Text on the left */ |
| 1891 | DLine *aRight, int nRight, /* Text on the right */ |
| 1892 | DiffConfig *pCfg, /* Configuration options */ |
| 1893 | int *pNResult /* OUTPUT: Bytes of result */ |
| 1894 | ){ |
| 1895 | int i, j, k; /* Loop counters */ |
| 1896 | int *a; /* One row of the Wagner matrix */ |
| 1897 | int *pToFree; /* Space that needs to be freed */ |
| 1898 | unsigned char *aM; /* Wagner result matrix */ |
| @@ -1916,13 +1916,13 @@ | |
| 1916 | ** O(NlogN). The result is not as precise, but this whole thing is an |
| 1917 | ** approximation anyhow, and the faster response time is an acceptable |
| 1918 | ** trade-off for reduced precision. |
| 1919 | */ |
| 1920 | if( nLeft*nRight>DIFF_ALIGN_MX && (pCfg->diffFlags & DIFF_SLOW_SBS)==0 ){ |
| 1921 | DLine *aSmall; /* The smaller of aLeft and aRight */ |
| 1922 | DLine *aBig; /* The larger of aLeft and aRight */ |
| 1923 | int nSmall, nBig; /* Size of aSmall and aBig. nSmall<=nBig */ |
| 1924 | int iDivSmall, iDivBig; /* Divider point for aSmall and aBig */ |
| 1925 | int iDivLeft, iDivRight; /* Divider point for aLeft and aRight */ |
| 1926 | unsigned char *a1, *a2; /* Results of the alignments on two halves */ |
| 1927 | int n1, n2; /* Number of entries in a1 and a2 */ |
| 1928 | int score, bestScore; /* Score and best score seen so far */ |
| @@ -2061,12 +2061,12 @@ | |
| 2061 | static void formatDiff( |
| 2062 | DContext *p, /* The computed diff */ |
| 2063 | DiffConfig *pCfg, /* Configuration options */ |
| 2064 | DiffBuilder *pBuilder /* The formatter object */ |
| 2065 | ){ |
| 2066 | DLine *A; /* Left side of the diff */ |
| 2067 | DLine *B; /* Right side of the diff */ |
| 2068 | unsigned int a = 0; /* Index of next line in A[] */ |
| 2069 | unsigned int b = 0; /* Index of next line in B[] */ |
| 2070 | const int *R; /* Array of COPY/DELETE/INSERT triples */ |
| 2071 | unsigned int r; /* Index into R[] */ |
| 2072 | unsigned int nr; /* Number of COPY/DELETE/INSERT triples to process */ |
| 2073 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -164,11 +164,11 @@ | |
| 164 | int nEditAlloc; /* Space allocated for aEdit[] */ |
| 165 | DLine *aFrom; /* File on left side of the diff */ |
| 166 | int nFrom; /* Number of lines in aFrom[] */ |
| 167 | DLine *aTo; /* File on right side of the diff */ |
| 168 | int nTo; /* Number of lines in aTo[] */ |
| 169 | int (*xDiffer)(const DLine *,const DLine *); /* comparison function */ |
| 170 | }; |
| 171 | |
| 172 | /* Fast isspace for use by diff */ |
| 173 | static const char diffIsSpace[] = { |
| 174 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, |
| @@ -313,11 +313,11 @@ | |
| 313 | } |
| 314 | |
| 315 | /* |
| 316 | ** Return zero if two DLine elements are identical. |
| 317 | */ |
| 318 | static int compare_dline(const DLine *pA, const DLine *pB){ |
| 319 | if( pA->h!=pB->h ) return 1; |
| 320 | return memcmp(pA->z,pB->z, pA->h&LENGTH_MASK); |
| 321 | } |
| 322 | |
| 323 | /* |
| @@ -324,11 +324,11 @@ | |
| 324 | ** Return zero if two DLine elements are identical, ignoring |
| 325 | ** all whitespace. The indent field of pA/pB already points |
| 326 | ** to the first non-space character in the string. |
| 327 | */ |
| 328 | |
| 329 | static int compare_dline_ignore_allws(const DLine *pA, const DLine *pB){ |
| 330 | int a = pA->indent, b = pB->indent; |
| 331 | if( pA->h==pB->h ){ |
| 332 | while( a<pA->n || b<pB->n ){ |
| 333 | if( a<pA->n && b<pB->n && pA->z[a++] != pB->z[b++] ) return 1; |
| 334 | while( a<pA->n && diff_isspace(pA->z[a])) ++a; |
| @@ -343,11 +343,11 @@ | |
| 343 | ** Return true if the regular expression *pRe matches any of the |
| 344 | ** N dlines |
| 345 | */ |
| 346 | static int re_dline_match( |
| 347 | ReCompiled *pRe, /* The regular expression to be matched */ |
| 348 | const DLine *aDLine, /* First of N DLines to compare against */ |
| 349 | int N /* Number of DLines to check */ |
| 350 | ){ |
| 351 | while( N-- ){ |
| 352 | if( re_match(pRe, (const unsigned char *)aDLine->z, LENGTH(aDLine)) ){ |
| 353 | return 1; |
| @@ -361,11 +361,11 @@ | |
| 361 | ** Append a single line of context-diff output to pOut. |
| 362 | */ |
| 363 | static void appendDiffLine( |
| 364 | Blob *pOut, /* Where to write the line of output */ |
| 365 | char cPrefix, /* One of " ", "+", or "-" */ |
| 366 | const DLine *pLine /* The line to be output */ |
| 367 | ){ |
| 368 | blob_append_char(pOut, cPrefix); |
| 369 | blob_append(pOut, pLine->z, pLine->n); |
| 370 | blob_append_char(pOut, '\n'); |
| 371 | } |
| @@ -394,14 +394,14 @@ | |
| 394 | static void contextDiff( |
| 395 | DContext *p, /* The difference */ |
| 396 | Blob *pOut, /* Output a context diff to here */ |
| 397 | DiffConfig *pCfg /* Configuration options */ |
| 398 | ){ |
| 399 | const DLine *A; /* Left side of the diff */ |
| 400 | const DLine *B; /* Right side of the diff */ |
| 401 | int a = 0; /* Index of next line in A[] */ |
| 402 | int b = 0; /* Index of next line in B[] */ |
| 403 | int *R; /* Array of COPY/DELETE/INSERT triples */ |
| 404 | int r; /* Index into R[] */ |
| 405 | int nr; /* Number of COPY/DELETE/INSERT triples to process */ |
| 406 | int mxr; /* Maximum value for r */ |
| 407 | int na, nb; /* Number of lines shown from A and B */ |
| @@ -713,12 +713,12 @@ | |
| 713 | ** |
| 714 | ** The result is written into the LineChange object given by the |
| 715 | ** third parameter. |
| 716 | */ |
| 717 | static void oneLineChange( |
| 718 | const DLine *pLeft, /* Left line of the change */ |
| 719 | const DLine *pRight, /* Right line of the change */ |
| 720 | LineChange *p /* OUTPUT: Write the results here */ |
| 721 | ){ |
| 722 | int nLeft; /* Length of left line in bytes */ |
| 723 | int nRight; /* Length of right line in bytes */ |
| 724 | int nShort; /* Shortest of left and right */ |
| @@ -909,15 +909,15 @@ | |
| 909 | ** in appropriate method implementations. |
| 910 | */ |
| 911 | typedef struct DiffBuilder DiffBuilder; |
| 912 | struct DiffBuilder { |
| 913 | void (*xSkip)(DiffBuilder*, unsigned int, int); |
| 914 | void (*xCommon)(DiffBuilder*,const DLine*); |
| 915 | void (*xInsert)(DiffBuilder*,const DLine*); |
| 916 | void (*xDelete)(DiffBuilder*,const DLine*); |
| 917 | void (*xReplace)(DiffBuilder*,const DLine*,const DLine*); |
| 918 | void (*xEdit)(DiffBuilder*,const DLine*,const DLine*); |
| 919 | void (*xEnd)(DiffBuilder*); |
| 920 | unsigned int lnLeft; /* Lines seen on the left (delete) side */ |
| 921 | unsigned int lnRight; /* Lines seen on the right (insert) side */ |
| 922 | unsigned int nPending; /* Number of pending lines */ |
| 923 | int eState; /* State of the output */ |
| @@ -939,35 +939,35 @@ | |
| 939 | n, p->lnLeft+1, p->lnLeft+n, p->lnRight+1, p->lnRight+n, |
| 940 | isFinal ? " FINAL" : ""); |
| 941 | p->lnLeft += n; |
| 942 | p->lnRight += n; |
| 943 | } |
| 944 | static void dfdebugCommon(DiffBuilder *p, const DLine *pLine){ |
| 945 | p->lnLeft++; |
| 946 | p->lnRight++; |
| 947 | blob_appendf(p->pOut, "COMMON %8u %8u %.*s\n", |
| 948 | p->lnLeft, p->lnRight, (int)pLine->n, pLine->z); |
| 949 | } |
| 950 | static void dfdebugInsert(DiffBuilder *p, const DLine *pLine){ |
| 951 | p->lnRight++; |
| 952 | blob_appendf(p->pOut, "INSERT %8d %.*s\n", |
| 953 | p->lnRight, (int)pLine->n, pLine->z); |
| 954 | } |
| 955 | static void dfdebugDelete(DiffBuilder *p, const DLine *pLine){ |
| 956 | p->lnLeft++; |
| 957 | blob_appendf(p->pOut, "DELETE %8u %.*s\n", |
| 958 | p->lnLeft, (int)pLine->n, pLine->z); |
| 959 | } |
| 960 | static void dfdebugReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 961 | p->lnLeft++; |
| 962 | p->lnRight++; |
| 963 | blob_appendf(p->pOut, "REPLACE %8u %.*s\n", |
| 964 | p->lnLeft, (int)pX->n, pX->z); |
| 965 | blob_appendf(p->pOut, " %8u %.*s\n", |
| 966 | p->lnRight, (int)pY->n, pY->z); |
| 967 | } |
| 968 | static void dfdebugEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 969 | int i, j; |
| 970 | int x; |
| 971 | LineChange chng; |
| 972 | p->lnLeft++; |
| 973 | p->lnRight++; |
| @@ -1055,33 +1055,33 @@ | |
| 1055 | ** additional string which is a common suffix. |
| 1056 | */ |
| 1057 | static void dftclSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1058 | blob_appendf(p->pOut, "SKIP %u\n", n); |
| 1059 | } |
| 1060 | static void dftclCommon(DiffBuilder *p, const DLine *pLine){ |
| 1061 | blob_appendf(p->pOut, "COM "); |
| 1062 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1063 | blob_append_char(p->pOut, '\n'); |
| 1064 | } |
| 1065 | static void dftclInsert(DiffBuilder *p, const DLine *pLine){ |
| 1066 | blob_append(p->pOut, "INS ", -1); |
| 1067 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1068 | blob_append_char(p->pOut, '\n'); |
| 1069 | } |
| 1070 | static void dftclDelete(DiffBuilder *p, const DLine *pLine){ |
| 1071 | blob_append(p->pOut, "DEL ", -1); |
| 1072 | blob_append_tcl_literal(p->pOut, pLine->z, pLine->n); |
| 1073 | blob_append_char(p->pOut, '\n'); |
| 1074 | } |
| 1075 | static void dftclReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1076 | blob_append(p->pOut, "EDIT \"\" ", -1); |
| 1077 | blob_append_tcl_literal(p->pOut, pX->z, pX->n); |
| 1078 | blob_append_char(p->pOut, ' '); |
| 1079 | blob_append_tcl_literal(p->pOut, pY->z, pY->n); |
| 1080 | blob_append_char(p->pOut, '\n'); |
| 1081 | } |
| 1082 | static void dftclEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1083 | int i, x; |
| 1084 | LineChange chng; |
| 1085 | blob_append(p->pOut, "EDIT", 4); |
| 1086 | oneLineChange(pX, pY, &chng); |
| 1087 | for(i=x=0; i<chng.n; i++){ |
| @@ -1139,33 +1139,33 @@ | |
| 1139 | ** not apply. |
| 1140 | */ |
| 1141 | static void dfjsonSkip(DiffBuilder *p, unsigned int n, int isFinal){ |
| 1142 | blob_appendf(p->pOut, "1,%u,\n", n); |
| 1143 | } |
| 1144 | static void dfjsonCommon(DiffBuilder *p, const DLine *pLine){ |
| 1145 | blob_append(p->pOut, "2,",2); |
| 1146 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1147 | blob_append(p->pOut, ",\n",2); |
| 1148 | } |
| 1149 | static void dfjsonInsert(DiffBuilder *p, const DLine *pLine){ |
| 1150 | blob_append(p->pOut, "3,",2); |
| 1151 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1152 | blob_append(p->pOut, ",\n",2); |
| 1153 | } |
| 1154 | static void dfjsonDelete(DiffBuilder *p, const DLine *pLine){ |
| 1155 | blob_append(p->pOut, "4,",2); |
| 1156 | blob_append_json_literal(p->pOut, pLine->z, (int)pLine->n); |
| 1157 | blob_append(p->pOut, ",\n",2); |
| 1158 | } |
| 1159 | static void dfjsonReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1160 | blob_append(p->pOut, "5,[\"\",",-1); |
| 1161 | blob_append_json_literal(p->pOut, pX->z, (int)pX->n); |
| 1162 | blob_append(p->pOut, ",",1); |
| 1163 | blob_append_json_literal(p->pOut, pY->z, (int)pY->n); |
| 1164 | blob_append(p->pOut, ",\"\"],\n",-1); |
| 1165 | } |
| 1166 | static void dfjsonEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1167 | int i, x; |
| 1168 | LineChange chng; |
| 1169 | blob_append(p->pOut, "5,[", 3); |
| 1170 | oneLineChange(pX, pY, &chng); |
| 1171 | for(i=x=0; i<chng.n; i++){ |
| @@ -1294,11 +1294,11 @@ | |
| 1294 | blob_append(p->pOut, "<td class=\"diffln difflne\">" |
| 1295 | "︙</td><td></td><td></td></tr>\n", -1); |
| 1296 | p->lnLeft += n; |
| 1297 | p->lnRight += n; |
| 1298 | } |
| 1299 | static void dfunifiedCommon(DiffBuilder *p, const DLine *pLine){ |
| 1300 | dfunifiedStartRow(p); |
| 1301 | dfunifiedFinishDelete(p); |
| 1302 | dfunifiedFinishInsert(p); |
| 1303 | p->lnLeft++; |
| 1304 | p->lnRight++; |
| @@ -1306,20 +1306,20 @@ | |
| 1306 | blob_appendf(&p->aCol[0],"%d\n",p->lnRight); |
| 1307 | blob_append_char(&p->aCol[1], '\n'); |
| 1308 | htmlize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n); |
| 1309 | blob_append_char(&p->aCol[2], '\n'); |
| 1310 | } |
| 1311 | static void dfunifiedInsert(DiffBuilder *p, const DLine *pLine){ |
| 1312 | dfunifiedStartRow(p); |
| 1313 | p->lnRight++; |
| 1314 | blob_appendf(&p->aCol[3],"%d\n", p->lnRight); |
| 1315 | blob_append(&p->aCol[4], "<ins>", 5); |
| 1316 | htmlize_to_blob(&p->aCol[4], pLine->z, (int)pLine->n); |
| 1317 | blob_append(&p->aCol[4], "</ins>\n", 7); |
| 1318 | p->nPending++; |
| 1319 | } |
| 1320 | static void dfunifiedDelete(DiffBuilder *p, const DLine *pLine){ |
| 1321 | dfunifiedStartRow(p); |
| 1322 | dfunifiedFinishInsert(p); |
| 1323 | if( p->eState==0 ){ |
| 1324 | dfunifiedFinishInsert(p); |
| 1325 | blob_append(p->pOut, "<del>", 5); |
| @@ -1332,11 +1332,11 @@ | |
| 1332 | blob_append(&p->aCol[1],"-\n",2); |
| 1333 | blob_append(&p->aCol[2], "<del>", 5); |
| 1334 | htmlize_to_blob(&p->aCol[2], pLine->z, (int)pLine->n); |
| 1335 | blob_append(&p->aCol[2], "</del>\n", 7); |
| 1336 | } |
| 1337 | static void dfunifiedReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1338 | dfunifiedStartRow(p); |
| 1339 | if( p->eState==0 ){ |
| 1340 | dfunifiedFinishInsert(p); |
| 1341 | blob_append(p->pOut, "<del>", 5); |
| 1342 | blob_append(&p->aCol[2], "<del>", 5); |
| @@ -1355,11 +1355,11 @@ | |
| 1355 | |
| 1356 | htmlize_to_blob(&p->aCol[4], pY->z, pY->n); |
| 1357 | blob_append_char(&p->aCol[4], '\n'); |
| 1358 | p->nPending++; |
| 1359 | } |
| 1360 | static void dfunifiedEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1361 | int i; |
| 1362 | int x; |
| 1363 | LineChange chng; |
| 1364 | oneLineChange(pX, pY, &chng); |
| 1365 | dfunifiedStartRow(p); |
| @@ -1524,11 +1524,11 @@ | |
| 1524 | "<td class=\"diffln difflnr difflne\">︙</td>" |
| 1525 | "<td/td></tr>\n", -1); |
| 1526 | p->lnLeft += n; |
| 1527 | p->lnRight += n; |
| 1528 | } |
| 1529 | static void dfsplitCommon(DiffBuilder *p, const DLine *pLine){ |
| 1530 | dfsplitStartRow(p); |
| 1531 | dfsplitChangeState(p, 0); |
| 1532 | p->lnLeft++; |
| 1533 | p->lnRight++; |
| 1534 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| @@ -1537,11 +1537,11 @@ | |
| 1537 | blob_append_char(&p->aCol[1], '\n'); |
| 1538 | blob_appendf(&p->aCol[2],"%d\n",p->lnRight); |
| 1539 | htmlize_to_blob(&p->aCol[3], pLine->z, (int)pLine->n); |
| 1540 | blob_append_char(&p->aCol[3], '\n'); |
| 1541 | } |
| 1542 | static void dfsplitInsert(DiffBuilder *p, const DLine *pLine){ |
| 1543 | dfsplitStartRow(p); |
| 1544 | dfsplitChangeState(p, 2); |
| 1545 | p->lnRight++; |
| 1546 | blob_append_char(p->pOut, '\n'); |
| 1547 | blob_append_char(&p->aCol[0], '\n'); |
| @@ -1549,11 +1549,11 @@ | |
| 1549 | blob_appendf(&p->aCol[2],"%d\n", p->lnRight); |
| 1550 | blob_append(&p->aCol[3], "<ins>", 5); |
| 1551 | htmlize_to_blob(&p->aCol[3], pLine->z, (int)pLine->n); |
| 1552 | blob_append(&p->aCol[3], "</ins>\n", 7); |
| 1553 | } |
| 1554 | static void dfsplitDelete(DiffBuilder *p, const DLine *pLine){ |
| 1555 | dfsplitStartRow(p); |
| 1556 | dfsplitChangeState(p, 1); |
| 1557 | p->lnLeft++; |
| 1558 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| 1559 | blob_append(&p->aCol[0], "<del>", 5); |
| @@ -1561,11 +1561,11 @@ | |
| 1561 | blob_append(&p->aCol[0], "</del>\n", 7); |
| 1562 | blob_append(&p->aCol[1], "<\n", -1); |
| 1563 | blob_append_char(&p->aCol[2],'\n'); |
| 1564 | blob_append_char(&p->aCol[3],'\n'); |
| 1565 | } |
| 1566 | static void dfsplitReplace(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1567 | dfsplitStartRow(p); |
| 1568 | dfsplitChangeState(p, 3); |
| 1569 | p->lnLeft++; |
| 1570 | p->lnRight++; |
| 1571 | blob_appendf(p->pOut,"%d\n", p->lnLeft); |
| @@ -1577,11 +1577,11 @@ | |
| 1577 | blob_appendf(&p->aCol[2],"%d\n", p->lnRight); |
| 1578 | |
| 1579 | htmlize_to_blob(&p->aCol[3], pY->z, pY->n); |
| 1580 | blob_append_char(&p->aCol[3], '\n'); |
| 1581 | } |
| 1582 | static void dfsplitEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1583 | int i; |
| 1584 | int x; |
| 1585 | LineChange chng; |
| 1586 | oneLineChange(pX, pY, &chng); |
| 1587 | dfsplitStartRow(p); |
| @@ -1679,11 +1679,11 @@ | |
| 1679 | ** from pX onto the into of p. |
| 1680 | ** |
| 1681 | ** This comment contains multibyte unicode characters (ü, Æ, ð) in order |
| 1682 | ** to test the ability of the diff code to handle such characters. |
| 1683 | */ |
| 1684 | static void sbs_append_chars(Blob *p, int iMin, int iMax, const DLine *pX){ |
| 1685 | int i; |
| 1686 | const char *z = pX->z; |
| 1687 | for(i=0; i<iMax && i<pX->n; i++){ |
| 1688 | char c = z[i]; |
| 1689 | blob_append_char(p, c); |
| @@ -1693,33 +1693,33 @@ | |
| 1693 | blob_append_char(p, ' '); |
| 1694 | i++; |
| 1695 | } |
| 1696 | } |
| 1697 | |
| 1698 | static void dfsbsCommon(DiffBuilder *p, const DLine *pLine){ |
| 1699 | p->lnLeft++; |
| 1700 | p->lnRight++; |
| 1701 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1702 | sbs_append_chars(p->pOut, p->width, p->width, pLine); |
| 1703 | blob_appendf(p->pOut," %6u ", p->lnRight); |
| 1704 | sbs_append_chars(p->pOut, 0, p->width, pLine); |
| 1705 | blob_append_char(p->pOut, '\n'); |
| 1706 | } |
| 1707 | static void dfsbsInsert(DiffBuilder *p, const DLine *pLine){ |
| 1708 | p->lnRight++; |
| 1709 | blob_appendf(p->pOut,"%6s %*s > %6u ", |
| 1710 | "", p->width, "", p->lnRight); |
| 1711 | sbs_append_chars(p->pOut, 0, p->width, pLine); |
| 1712 | blob_append_char(p->pOut, '\n'); |
| 1713 | } |
| 1714 | static void dfsbsDelete(DiffBuilder *p, const DLine *pLine){ |
| 1715 | p->lnLeft++; |
| 1716 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1717 | sbs_append_chars(p->pOut, p->width, p->width, pLine); |
| 1718 | blob_append(p->pOut," <\n", 3); |
| 1719 | } |
| 1720 | static void dfsbsEdit(DiffBuilder *p, const DLine *pX, const DLine *pY){ |
| 1721 | p->lnLeft++; |
| 1722 | p->lnRight++; |
| 1723 | blob_appendf(p->pOut,"%6u ", p->lnLeft); |
| 1724 | sbs_append_chars(p->pOut, p->width, p->width, pX); |
| 1725 | blob_appendf(p->pOut, " | %6u ", p->lnRight); |
| @@ -1887,12 +1887,12 @@ | |
| 1887 | ** mismatch. |
| 1888 | */ |
| 1889 | static unsigned char *diffBlockAlignment( |
| 1890 | DLine *aLeft, int nLeft, /* Text on the left */ |
| 1891 | DLine *aRight, int nRight, /* Text on the right */ |
| 1892 | DiffConfig *pCfg, /* Configuration options */ |
| 1893 | int *pNResult /* OUTPUT: Bytes of result */ |
| 1894 | ){ |
| 1895 | int i, j, k; /* Loop counters */ |
| 1896 | int *a; /* One row of the Wagner matrix */ |
| 1897 | int *pToFree; /* Space that needs to be freed */ |
| 1898 | unsigned char *aM; /* Wagner result matrix */ |
| @@ -1916,13 +1916,13 @@ | |
| 1916 | ** O(NlogN). The result is not as precise, but this whole thing is an |
| 1917 | ** approximation anyhow, and the faster response time is an acceptable |
| 1918 | ** trade-off for reduced precision. |
| 1919 | */ |
| 1920 | if( nLeft*nRight>DIFF_ALIGN_MX && (pCfg->diffFlags & DIFF_SLOW_SBS)==0 ){ |
| 1921 | DLine *aSmall; /* The smaller of aLeft and aRight */ |
| 1922 | DLine *aBig; /* The larger of aLeft and aRight */ |
| 1923 | int nSmall, nBig; /* Size of aSmall and aBig. nSmall<=nBig */ |
| 1924 | int iDivSmall, iDivBig; /* Divider point for aSmall and aBig */ |
| 1925 | int iDivLeft, iDivRight; /* Divider point for aLeft and aRight */ |
| 1926 | unsigned char *a1, *a2; /* Results of the alignments on two halves */ |
| 1927 | int n1, n2; /* Number of entries in a1 and a2 */ |
| 1928 | int score, bestScore; /* Score and best score seen so far */ |
| @@ -2061,12 +2061,12 @@ | |
| 2061 | static void formatDiff( |
| 2062 | DContext *p, /* The computed diff */ |
| 2063 | DiffConfig *pCfg, /* Configuration options */ |
| 2064 | DiffBuilder *pBuilder /* The formatter object */ |
| 2065 | ){ |
| 2066 | DLine *A; /* Left side of the diff */ |
| 2067 | DLine *B; /* Right side of the diff */ |
| 2068 | unsigned int a = 0; /* Index of next line in A[] */ |
| 2069 | unsigned int b = 0; /* Index of next line in B[] */ |
| 2070 | const int *R; /* Array of COPY/DELETE/INSERT triples */ |
| 2071 | unsigned int r; /* Index into R[] */ |
| 2072 | unsigned int nr; /* Number of COPY/DELETE/INSERT triples to process */ |
| 2073 |