Diff
Not logged in

Differences From:

File src/diff.c part of check-in [68c24b1857] - Progress toward getting ticket handling to work. by drh on 2008-05-16 18:11:39. [view]

To:

File src/diff.c part of check-in [7a2c37063a] - merge trunk into creole branch by bob on 2009-09-22 07:49:39. Also file src/diff.c part of check-in [713b8be852] - Deleted some obsolete "todo" files. Updated the FAQ. Modified the the "vinfo" page to show check-in differences and made "vinfo" the default display for check-ins instead of "vdiff". by drh on 2009-08-28 22:59:27. [view]

@@ -77,17 +77,17 @@
 **
 ** Return 0 if the file is binary or contains a line that is
 ** too long.
 */
-static DLine *break_into_lines(const char *z, int *pnLine){
+static DLine *break_into_lines(const char *z, int n, int *pnLine){
   int nLine, i, j, k, x;
   unsigned int h, h2;
   DLine *a;
 
   /* Count the number of lines.  Allocate space to hold
   ** the returned array.
   */
-  for(i=j=0, nLine=1; z[i]; i++, j++){
+  for(i=j=0, nLine=1; i<n; i++, j++){
     int c = z[i];
     if( c==0 ){
       return 0;
     }
@@ -485,10 +485,10 @@
   DContext c;
 
   /* Prepare the input files */
   memset(&c, 0, sizeof(c));
-  c.aFrom = break_into_lines(blob_str(pA_Blob), &c.nFrom);
-  c.aTo = break_into_lines(blob_str(pB_Blob), &c.nTo);
+  c.aFrom = break_into_lines(blob_str(pA_Blob), blob_size(pA_Blob), &c.nFrom);
+  c.aTo = break_into_lines(blob_str(pB_Blob), blob_size(pB_Blob), &c.nTo);
   if( c.aFrom==0 || c.aTo==0 ){
     free(c.aFrom);
     free(c.aTo);
     if( pOut ){
@@ -581,9 +581,9 @@
 static int annotation_start(Annotator *p, Blob *pInput){
   int i;
 
   memset(p, 0, sizeof(*p));
-  p->c.aTo = break_into_lines(blob_str(pInput), &p->c.nTo);
+  p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput), &p->c.nTo);
   if( p->c.aTo==0 ){
     return 1;
   }
   p->aOrig = malloc( sizeof(p->aOrig[0])*p->c.nTo );
@@ -608,9 +608,10 @@
   int i, j;
   int lnTo;
 
   /* Prepare the parent file to be diffed */
-  p->c.aFrom = break_into_lines(blob_str(pParent), &p->c.nFrom);
+  p->c.aFrom = break_into_lines(blob_str(pParent), blob_size(pParent),
+                                &p->c.nFrom);
   if( p->c.aFrom==0 ){
     return 1;
   }