Fossil

Check-in [36cdc17c]
Login

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

Overview
Comment:Fixing the automatic calculation of sbs line length, for the case of TABs and UTF8 sequences. I also set the tab size to 4 spaces.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | annotate_links
Files: files | file ages | folders
SHA1:36cdc17cc83c22251109463601acc41a9cb597f4
User & Date: viriketo 2012-08-20 13:20:28
Context
2012-10-09
13:48
Updating from trunk. I solved some merge conflicts: 1) the checkin info in the vdiff page, taking that from trunk, and 2) the vdiff menu options, which I tried to get similar to what I had in the branch. check-in: f4b082d4 user: viriketo tags: annotate_links
2012-08-20
13:20
Fixing the automatic calculation of sbs line length, for the case of TABs and UTF8 sequences. I also set the tab size to 4 spaces. check-in: 36cdc17c user: viriketo tags: annotate_links
2012-08-08
13:46
Updating from trunk. I solved three merge conflicts about hyperlinks. check-in: 08db3204 user: viriketo tags: annotate_links
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diff.c.

41
42
43
44
45
46
47

48
49
50
51
52
53
54
...
392
393
394
395
396
397
398
399
400
401

402
403
404
405
406

407
408
409
410
411
412
413
414
415

416
417
418
419
420
421
422
423
424
425

426


427


428

429
430

431
432

433

434
435

436

437
438

439

440

441
442
443
444
445
446
447




448
449
450
451
452
453
454

#endif /* INTERFACE */

/*
** Maximum length of a line in a text file.  (8192)
*/
#define LENGTH_MASK_SZ  13

#define LENGTH_MASK     ((1<<LENGTH_MASK_SZ)-1)

/*
** Information about each line of a file being diffed.
**
** The lower LENGTH_MASK_SZ bits of the hash (DLine.h) are the length
** of the line.  If any line is longer than LENGTH_MASK characters,
................................................................................
  int j;   /* Number of output characters generated */
  int k;   /* Cursor position */
  int needEndSpan = 0;
  const char *zIn = pLine->z;
  char *z = &p->zLine[p->n];
  int w = p->width;

  if (n > maxwidth)
    maxwidth = n;


  for(i=j=k=0; k<w && i<n; i++, k++){
    char c = zIn[i];
    if( p->escHtml ){
      if( i==p->iStart ){
        int x = strlen(p->zStart);

        memcpy(z+j, p->zStart, x);
        j += x;
        needEndSpan = 1;
        if( p->iStart2 ){
          p->iStart = p->iStart2;
          p->zStart = p->zStart2;
          p->iStart2 = 0;
        }
      }else if( i==p->iEnd ){

        memcpy(z+j, "</span>", 7);
        j += 7;
        needEndSpan = 0;
        if( p->iEnd2 ){
          p->iEnd = p->iEnd2;
          p->iEnd2 = 0;
        }
      }
    }
    if( c=='\t' ){

      z[j++] = ' ';


      while( (k&7)!=7 && k<w ){ z[j++] = ' '; k++; }


    }else if( c=='\r' || c=='\f' ){

      z[j++] = ' ';
    }else if( c=='<' && p->escHtml ){

      memcpy(&z[j], "&lt;", 4);
      j += 4;

    }else if( c=='&' && p->escHtml ){

      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 ){
    while( k<w ){ k++;  z[j++] = ' '; }
  }
  if( flags & SBS_NEWLINE ){
    z[j++] = '\n';
  }
  p->n += j;







>







 







|
|
<
>
|




>
|








>
|









>
|
>
>
|
>
>

>
|

>
|
|
>

>
|
|
>

>
|
|
>

>
|
>







>
>
>
>







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
...
393
394
395
396
397
398
399
400
401

402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475

#endif /* INTERFACE */

/*
** Maximum length of a line in a text file.  (8192)
*/
#define LENGTH_MASK_SZ  13
#define TABLENGTH        4
#define LENGTH_MASK     ((1<<LENGTH_MASK_SZ)-1)

/*
** Information about each line of a file being diffed.
**
** The lower LENGTH_MASK_SZ bits of the hash (DLine.h) are the length
** of the line.  If any line is longer than LENGTH_MASK characters,
................................................................................
  int j;   /* Number of output characters generated */
  int k;   /* Cursor position */
  int needEndSpan = 0;
  const char *zIn = pLine->z;
  char *z = &p->zLine[p->n];
  int w = p->width;

  /* In the case w == 0, we want to calculate the output line
   * width (k), but not write anything to 'z', because it has

   * a buffer of limited size. */
  for(i=j=k=0; (w == 0 || k<w) && i<n; i++, k++){
    char c = zIn[i];
    if( p->escHtml ){
      if( i==p->iStart ){
        int x = strlen(p->zStart);
        if (w != 0)
          memcpy(z+j, p->zStart, x);
        j += x;
        needEndSpan = 1;
        if( p->iStart2 ){
          p->iStart = p->iStart2;
          p->zStart = p->zStart2;
          p->iStart2 = 0;
        }
      }else if( i==p->iEnd ){
        if (w != 0)
          memcpy(z+j, "</span>", 7);
        j += 7;
        needEndSpan = 0;
        if( p->iEnd2 ){
          p->iEnd = p->iEnd2;
          p->iEnd2 = 0;
        }
      }
    }
    if( c=='\t' ){
      if (w != 0)
        z[j++] = ' ';
      while( (k%TABLENGTH)!=0 && (w == 0 || k<w) ){
        if (w != 0)
          z[j++] = ' ';
        k++;
      }
    }else if( c=='\r' || c=='\f' ){
      if (w != 0)
        z[j++] = ' ';
    }else if( c=='<' && p->escHtml ){
      if (w != 0) {
        memcpy(&z[j], "&lt;", 4);
        j += 4;
      }
    }else if( c=='&' && p->escHtml ){
      if (w != 0) {
        memcpy(&z[j], "&amp;", 5);
        j += 5;
      }
    }else if( c=='>' && p->escHtml ){
      if (w != 0) {
        memcpy(&z[j], "&gt;", 4);
        j += 4;
      }
    }else{
      if (w != 0) {
        z[j++] = c;
      }
      if( (c&0xc0)==0x80 ) k--;
    }
  }
  if( needEndSpan ){
    memcpy(&z[j], "</span>", 7);
    j += 7;
  }

  if (k > maxwidth)
    maxwidth = k;

  if( (flags & SBS_PAD)!=0 ){
    while( k<w ){ k++;  z[j++] = ' '; }
  }
  if( flags & SBS_NEWLINE ){
    z[j++] = '\n';
  }
  p->n += j;