| | @@ -351,10 +351,12 @@ |
| 351 | 351 | appendDiffLine(pOut, ' ', &B[b+j], html); |
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | +static int maxwidth; |
| 357 | + |
| 356 | 358 | /* |
| 357 | 359 | ** Status of a single output line |
| 358 | 360 | */ |
| 359 | 361 | typedef struct SbsLine SbsLine; |
| 360 | 362 | struct SbsLine { |
| | @@ -388,10 +390,14 @@ |
| 388 | 390 | int k; /* Cursor position */ |
| 389 | 391 | int needEndSpan = 0; |
| 390 | 392 | const char *zIn = pLine->z; |
| 391 | 393 | char *z = &p->zLine[p->n]; |
| 392 | 394 | int w = p->width; |
| 395 | + |
| 396 | + if (n > maxwidth) |
| 397 | + maxwidth = n; |
| 398 | + |
| 393 | 399 | for(i=j=k=0; k<w && i<n; i++, k++){ |
| 394 | 400 | char c = zIn[i]; |
| 395 | 401 | if( p->escHtml ){ |
| 396 | 402 | if( i==p->iStart ){ |
| 397 | 403 | int x = strlen(p->zStart); |
| | @@ -863,11 +869,11 @@ |
| 863 | 869 | static void sbsDiff( |
| 864 | 870 | DContext *p, /* The computed diff */ |
| 865 | 871 | Blob *pOut, /* Write the results here */ |
| 866 | 872 | int nContext, /* Number of lines of context around each change */ |
| 867 | 873 | int width, /* Width of each column of output */ |
| 868 | | - int escHtml /* True to generate HTML output */ |
| 874 | + int escHtml /* True to generate HTML output */ |
| 869 | 875 | ){ |
| 870 | 876 | DLine *A; /* Left side of the diff */ |
| 871 | 877 | DLine *B; /* Right side of the diff */ |
| 872 | 878 | int a = 0; /* Index of next line in A[] */ |
| 873 | 879 | int b = 0; /* Index of next line in B[] */ |
| | @@ -1432,11 +1438,10 @@ |
| 1432 | 1438 | ** Extract the width of columns for side-by-side diff. Supply an |
| 1433 | 1439 | ** appropriate default if no width is given. |
| 1434 | 1440 | */ |
| 1435 | 1441 | int diff_width(int diffFlags){ |
| 1436 | 1442 | int w = (diffFlags & DIFF_WIDTH_MASK)/(DIFF_CONTEXT_MASK+1); |
| 1437 | | - if( w==0 ) w = 80; |
| 1438 | 1443 | return w; |
| 1439 | 1444 | } |
| 1440 | 1445 | |
| 1441 | 1446 | /* |
| 1442 | 1447 | ** Generate a report of the differences between files pA and pB. |
| | @@ -1492,10 +1497,18 @@ |
| 1492 | 1497 | if( pOut ){ |
| 1493 | 1498 | /* Compute a context or side-by-side diff into pOut */ |
| 1494 | 1499 | int escHtml = (diffFlags & DIFF_HTML)!=0; |
| 1495 | 1500 | if( diffFlags & DIFF_SIDEBYSIDE ){ |
| 1496 | 1501 | int width = diff_width(diffFlags); |
| 1502 | + if (width == 0){ /* Autocalculate */ |
| 1503 | + Blob dump; |
| 1504 | + /* Webserver */ |
| 1505 | + maxwidth = 0; |
| 1506 | + blob_zero(&dump); |
| 1507 | + sbsDiff(&c, &dump, nContext, width, escHtml); |
| 1508 | + width = maxwidth; |
| 1509 | + } |
| 1497 | 1510 | sbsDiff(&c, pOut, nContext, width, escHtml); |
| 1498 | 1511 | }else{ |
| 1499 | 1512 | int showLn = (diffFlags & DIFF_LINENO)!=0; |
| 1500 | 1513 | contextDiff(&c, pOut, nContext, showLn, escHtml); |
| 1501 | 1514 | } |
| 1502 | 1515 | |