Check-in [484f8d29af]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:484f8d29af0d130e5b5bb62eb69285a1c83cbd96
Date: 2012-06-20 11:02:30
User: drh
Comment:Account for multibyte unicode characters when computing column widths for side-by-side diffs.
Tags And Properties
Changes

Changes to src/diff.c

377 #define SBS_PAD 0x0002 /* Pad output to width spaces */ 377 #define SBS_PAD 0x0002 /* Pad output to width spaces */ 378 378 379 /* 379 /* 380 ** Write up to width characters of pLine into p->zLine[]. Translate tabs into 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 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. 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 ** to test the ability of the diff code to handle such characters. 385 ** to test the ability of the diff code to handle such characters. 386 */ 386 */ 387 static void sbsWriteText(SbsLine *p, DLine *pLine, unsigned flags){ 387 static void sbsWriteText(SbsLine *p, DLine *pLine, unsigned flags){ 388 int n = pLine->h & LENGTH_MASK; 388 int n = pLine->h & LENGTH_MASK; 389 int i; /* Number of input characters consumed */ 389 int i; /* Number of input characters consumed */ 390 int j; /* Number of output characters generated */ 390 int j; /* Number of output characters generated */ 391 int k; /* Cursor position */ 391 int k; /* Cursor position */ ................................................................................................................................................................................ 428 memcpy(&z[j], "&amp;", 5); 428 memcpy(&z[j], "&amp;", 5); 429 j += 5; 429 j += 5; 430 }else if( c=='>' && p->escHtml ){ 430 }else if( c=='>' && p->escHtml ){ 431 memcpy(&z[j], "&gt;", 4); 431 memcpy(&z[j], "&gt;", 4); 432 j += 4; 432 j += 4; 433 }else{ 433 }else{ 434 z[j++] = c; 434 z[j++] = c; > 435 if( (c&0xc0)==0x80 ) k--; 435 } 436 } 436 } 437 } 437 if( needEndSpan ){ 438 if( needEndSpan ){ 438 memcpy(&z[j], "</span>", 7); 439 memcpy(&z[j], "</span>", 7); 439 j += 7; 440 j += 7; 440 } 441 } 441 if( (flags & SBS_PAD)!=0 ){ 442 if( (flags & SBS_PAD)!=0 ){ ................................................................................................................................................................................ 883 int i, j; /* Loop counters */ 884 int i, j; /* Loop counters */ 884 int m, ma, mb;/* Number of lines to output */ 885 int m, ma, mb;/* Number of lines to output */ 885 int skip; /* Number of lines to skip */ 886 int skip; /* Number of lines to skip */ 886 int nChunk = 0; /* Number of chunks of diff output seen so far */ 887 int nChunk = 0; /* Number of chunks of diff output seen so far */ 887 SbsLine s; /* Output line buffer */ 888 SbsLine s; /* Output line buffer */ 888 889 889 memset(&s, 0, sizeof(s)); 890 memset(&s, 0, sizeof(s)); 890 s.zLine = fossil_malloc( 10*width + 200 ); | 891 s.zLine = fossil_malloc( 15*width + 200 ); 891 if( s.zLine==0 ) return; 892 if( s.zLine==0 ) return; 892 s.width = width; 893 s.width = width; 893 s.escHtml = escHtml; 894 s.escHtml = escHtml; 894 s.iStart = -1; 895 s.iStart = -1; 895 s.iStart2 = 0; 896 s.iStart2 = 0; 896 s.iEnd = -1; 897 s.iEnd = -1; 897 A = p->aFrom; 898 A = p->aFrom;