Fossil SCM
Account for multibyte unicode characters when computing column widths for side-by-side diffs.
Commit
484f8d29af0d130e5b5bb62eb69285a1c83cbd96
Parent
d1fc2f4a1643708…
1 file changed
+3
-2
+3
-2
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -379,11 +379,11 @@ | ||
| 379 | 379 | /* |
| 380 | 380 | ** Write up to width characters of pLine into p->zLine[]. Translate tabs into |
| 381 | 381 | ** spaces. Add a newline if SBS_NEWLINE is set. Translate HTML characters |
| 382 | 382 | ** if SBS_HTML is set. Pad the rendering out width bytes if SBS_PAD is set. |
| 383 | 383 | ** |
| 384 | -** This comment contains multi-byte unicode characters (ü, Æ, ð) in order | |
| 384 | +** This comment contains multibyte unicode characters (ü, Æ, ð) in order | |
| 385 | 385 | ** to test the ability of the diff code to handle such characters. |
| 386 | 386 | */ |
| 387 | 387 | static void sbsWriteText(SbsLine *p, DLine *pLine, unsigned flags){ |
| 388 | 388 | int n = pLine->h & LENGTH_MASK; |
| 389 | 389 | int i; /* Number of input characters consumed */ |
| @@ -430,10 +430,11 @@ | ||
| 430 | 430 | }else if( c=='>' && p->escHtml ){ |
| 431 | 431 | memcpy(&z[j], ">", 4); |
| 432 | 432 | j += 4; |
| 433 | 433 | }else{ |
| 434 | 434 | z[j++] = c; |
| 435 | + if( (c&0xc0)==0x80 ) k--; | |
| 435 | 436 | } |
| 436 | 437 | } |
| 437 | 438 | if( needEndSpan ){ |
| 438 | 439 | memcpy(&z[j], "</span>", 7); |
| 439 | 440 | j += 7; |
| @@ -885,11 +886,11 @@ | ||
| 885 | 886 | int skip; /* Number of lines to skip */ |
| 886 | 887 | int nChunk = 0; /* Number of chunks of diff output seen so far */ |
| 887 | 888 | SbsLine s; /* Output line buffer */ |
| 888 | 889 | |
| 889 | 890 | memset(&s, 0, sizeof(s)); |
| 890 | - s.zLine = fossil_malloc( 10*width + 200 ); | |
| 891 | + s.zLine = fossil_malloc( 15*width + 200 ); | |
| 891 | 892 | if( s.zLine==0 ) return; |
| 892 | 893 | s.width = width; |
| 893 | 894 | s.escHtml = escHtml; |
| 894 | 895 | s.iStart = -1; |
| 895 | 896 | s.iStart2 = 0; |
| 896 | 897 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -379,11 +379,11 @@ | |
| 379 | /* |
| 380 | ** Write up to width characters of pLine into p->zLine[]. Translate tabs into |
| 381 | ** spaces. Add a newline if SBS_NEWLINE is set. Translate HTML characters |
| 382 | ** if SBS_HTML is set. Pad the rendering out width bytes if SBS_PAD is set. |
| 383 | ** |
| 384 | ** This comment contains multi-byte unicode characters (ü, Æ, ð) in order |
| 385 | ** to test the ability of the diff code to handle such characters. |
| 386 | */ |
| 387 | static void sbsWriteText(SbsLine *p, DLine *pLine, unsigned flags){ |
| 388 | int n = pLine->h & LENGTH_MASK; |
| 389 | int i; /* Number of input characters consumed */ |
| @@ -430,10 +430,11 @@ | |
| 430 | }else if( c=='>' && p->escHtml ){ |
| 431 | memcpy(&z[j], ">", 4); |
| 432 | j += 4; |
| 433 | }else{ |
| 434 | z[j++] = c; |
| 435 | } |
| 436 | } |
| 437 | if( needEndSpan ){ |
| 438 | memcpy(&z[j], "</span>", 7); |
| 439 | j += 7; |
| @@ -885,11 +886,11 @@ | |
| 885 | int skip; /* Number of lines to skip */ |
| 886 | int nChunk = 0; /* Number of chunks of diff output seen so far */ |
| 887 | SbsLine s; /* Output line buffer */ |
| 888 | |
| 889 | memset(&s, 0, sizeof(s)); |
| 890 | s.zLine = fossil_malloc( 10*width + 200 ); |
| 891 | if( s.zLine==0 ) return; |
| 892 | s.width = width; |
| 893 | s.escHtml = escHtml; |
| 894 | s.iStart = -1; |
| 895 | s.iStart2 = 0; |
| 896 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -379,11 +379,11 @@ | |
| 379 | /* |
| 380 | ** Write up to width characters of pLine into p->zLine[]. Translate tabs into |
| 381 | ** spaces. Add a newline if SBS_NEWLINE is set. Translate HTML characters |
| 382 | ** if SBS_HTML is set. Pad the rendering out width bytes if SBS_PAD is set. |
| 383 | ** |
| 384 | ** This comment contains multibyte unicode characters (ü, Æ, ð) in order |
| 385 | ** to test the ability of the diff code to handle such characters. |
| 386 | */ |
| 387 | static void sbsWriteText(SbsLine *p, DLine *pLine, unsigned flags){ |
| 388 | int n = pLine->h & LENGTH_MASK; |
| 389 | int i; /* Number of input characters consumed */ |
| @@ -430,10 +430,11 @@ | |
| 430 | }else if( c=='>' && p->escHtml ){ |
| 431 | memcpy(&z[j], ">", 4); |
| 432 | j += 4; |
| 433 | }else{ |
| 434 | z[j++] = c; |
| 435 | if( (c&0xc0)==0x80 ) k--; |
| 436 | } |
| 437 | } |
| 438 | if( needEndSpan ){ |
| 439 | memcpy(&z[j], "</span>", 7); |
| 440 | j += 7; |
| @@ -885,11 +886,11 @@ | |
| 886 | int skip; /* Number of lines to skip */ |
| 887 | int nChunk = 0; /* Number of chunks of diff output seen so far */ |
| 888 | SbsLine s; /* Output line buffer */ |
| 889 | |
| 890 | memset(&s, 0, sizeof(s)); |
| 891 | s.zLine = fossil_malloc( 15*width + 200 ); |
| 892 | if( s.zLine==0 ) return; |
| 893 | s.width = width; |
| 894 | s.escHtml = escHtml; |
| 895 | s.iStart = -1; |
| 896 | s.iStart2 = 0; |
| 897 |