Fossil

Check-in [484f8d29]
Login

Check-in [484f8d29]

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

Overview
Comment:Account for multibyte unicode characters when computing column widths for side-by-side diffs.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 484f8d29af0d130e5b5bb62eb69285a1c83cbd96
User & Date: drh 2012-06-20 11:02:30
Context
2012-06-20
11:31
Update the diff-test-1.wiki tests to include a case for side-by-side diffs of multibyte characters. ... (check-in: c2b681e6 user: drh tags: trunk)
11:02
Account for multibyte unicode characters when computing column widths for side-by-side diffs. ... (check-in: 484f8d29 user: drh tags: trunk)
10:57
Add a comment that contains multi-byte unicode characters. This will be used for testing diff logic. ... (check-in: d1fc2f4a user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
#define SBS_PAD          0x0002   /* Pad output to width spaces */

/*
** Write up to width characters of pLine into p->zLine[].  Translate tabs into
** spaces.  Add a newline if SBS_NEWLINE is set.  Translate HTML characters
** if SBS_HTML is set.  Pad the rendering out width bytes if SBS_PAD is set.
**
** This comment contains multi-byte unicode characters (ü, Æ, ð) in order
** to test the ability of the diff code to handle such characters.
*/
static void sbsWriteText(SbsLine *p, DLine *pLine, unsigned flags){
  int n = pLine->h & LENGTH_MASK;
  int i;   /* Number of input characters consumed */
  int j;   /* Number of output characters generated */
  int k;   /* Cursor position */







|







377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
#define SBS_PAD          0x0002   /* Pad output to width spaces */

/*
** Write up to width characters of pLine into p->zLine[].  Translate tabs into
** spaces.  Add a newline if SBS_NEWLINE is set.  Translate HTML characters
** if SBS_HTML is set.  Pad the rendering out width bytes if SBS_PAD is set.
**
** This comment contains multibyte unicode characters (ü, Æ, ð) in order
** to test the ability of the diff code to handle such characters.
*/
static void sbsWriteText(SbsLine *p, DLine *pLine, unsigned flags){
  int n = pLine->h & LENGTH_MASK;
  int i;   /* Number of input characters consumed */
  int j;   /* Number of output characters generated */
  int k;   /* Cursor position */
428
429
430
431
432
433
434

435
436
437
438
439
440
441
      memcpy(&z[j], "&", 5);
      j += 5;
    }else if( c=='>' && p->escHtml ){
      memcpy(&z[j], ">", 4);
      j += 4;
    }else{
      z[j++] = c;

    }
  }
  if( needEndSpan ){
    memcpy(&z[j], "</span>", 7);
    j += 7;
  }
  if( (flags & SBS_PAD)!=0 ){







>







428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
      memcpy(&z[j], "&amp;", 5);
      j += 5;
    }else if( c=='>' && p->escHtml ){
      memcpy(&z[j], "&gt;", 4);
      j += 4;
    }else{
      z[j++] = c;
      if( (c&0xc0)==0x80 ) k--;
    }
  }
  if( needEndSpan ){
    memcpy(&z[j], "</span>", 7);
    j += 7;
  }
  if( (flags & SBS_PAD)!=0 ){
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
  int i, j;     /* Loop counters */
  int m, ma, mb;/* Number of lines to output */
  int skip;     /* Number of lines to skip */
  int nChunk = 0; /* Number of chunks of diff output seen so far */
  SbsLine s;    /* Output line buffer */

  memset(&s, 0, sizeof(s));
  s.zLine = fossil_malloc( 10*width + 200 );
  if( s.zLine==0 ) return;
  s.width = width;
  s.escHtml = escHtml;
  s.iStart = -1;
  s.iStart2 = 0;
  s.iEnd = -1;
  A = p->aFrom;







|







884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
  int i, j;     /* Loop counters */
  int m, ma, mb;/* Number of lines to output */
  int skip;     /* Number of lines to skip */
  int nChunk = 0; /* Number of chunks of diff output seen so far */
  SbsLine s;    /* Output line buffer */

  memset(&s, 0, sizeof(s));
  s.zLine = fossil_malloc( 15*width + 200 );
  if( s.zLine==0 ) return;
  s.width = width;
  s.escHtml = escHtml;
  s.iStart = -1;
  s.iStart2 = 0;
  s.iEnd = -1;
  A = p->aFrom;