Check-in [f030c0aea7]
Not logged in
Overview

SHA1 Hash:f030c0aea76a40c60e420db1aaaf82bab07ebe4b
Date: 2007-08-30 19:46:06
User: drh
Comment:Fix multiple bugs in the comment parser of the commit command. Allow blank lines in comments.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/blob.c from [57c4e58592] to [f2c016552c].

@@ -343,11 +343,13 @@
 }
 
 /*
 ** Extract a single line of text from pFrom beginning at the current
 ** cursor location and use that line of text to initialize pTo.
-** Return the number of bytes in the line.
+** pTo will include the terminating \n.  Return the number of bytes
+** in the line including the \n at the end.  0 is returned at
+** end-of-file.
 **
 ** The cursor of pFrom is left pointing at the first byte past the
 ** \n that terminated the line.
 **
 ** pTo will be an ephermeral blob.  If pFrom changes, it might alter
@@ -355,17 +357,17 @@
 */
 int blob_line(Blob *pFrom, Blob *pTo){
   char *aData = pFrom->aData;
   int n = pFrom->nUsed;
   int i = pFrom->iCursor;
-  /* Do not skip blank lines
-  ** while( i<n && aData[i]=='\n' ){ i++; }
-  ** pFrom->iCursor = i;
-  */
+
   while( i<n && aData[i]!='\n' ){ i++; }
-  blob_extract(pFrom, i-pFrom->iCursor, pTo);
-  if( i<n && aData[i]=='\n' ){ pFrom->iCursor++; }
+  if( i<n ){
+    assert( aData[i]=='\n' );
+    i++;
+  }
+  blob_extract(pFrom, i-pFrom->iCursor, pTo);
   return pTo->nUsed;
 }
 
 /*
 ** Extract a single token from pFrom and use it to initialize pTo.

Modified src/checkin.c from [670906c45d] to [66b4512b45].

@@ -235,11 +235,13 @@
     char *z;
     n = blob_size(&line);
     z = blob_buffer(&line);
     for(i=0; i<n && isspace(z[i]);  i++){}
     if( i<n && z[i]=='#' ) continue;
-    blob_appendf(pComment, "%b\n", &line);
+    if( i<n || blob_size(pComment)>0 ){
+      blob_appendf(pComment, "%b", &line);
+    }
   }
   blob_reset(&text);
   zComment = blob_str(pComment);
   i = strlen(zComment);
   while( i>0 && isspace(zComment[i-1]) ){ i--; }

Modified src/manifest.c from [bf7dfee62a] to [2a7dfdcb16].

@@ -94,19 +94,19 @@
         goto manifest_syntax_error;
       }
       if( seenHeader ){
         break;
       }
-      while( blob_line(pContent, &line)>1 ){}
+      while( blob_line(pContent, &line)>2 ){}
       if( blob_line(pContent, &line)==0 ) break;
       z = blob_buffer(&line);
     }
     seenHeader = 1;
     if( blob_token(&line, &token)!=1 ) goto manifest_syntax_error;
     if( z[0]=='F' ){
       char *zName, *zUuid;
-      md5sum_step_text(blob_buffer(&line), blob_size(&line)+1);
+      md5sum_step_text(blob_buffer(&line), blob_size(&line));
       if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a3)!=0 ) goto manifest_syntax_error;
       zName = blob_terminate(&a1);
       zUuid = blob_terminate(&a2);
@@ -126,41 +126,41 @@
       p->aFile[i].zUuid = zUuid;
       if( i>0 && strcmp(p->aFile[i-1].zName, zName)>=0 ){
         goto manifest_syntax_error;
       }
     }else if( z[0]=='C' ){
-      md5sum_step_text(blob_buffer(&line), blob_size(&line)+1);
+      md5sum_step_text(blob_buffer(&line), blob_size(&line));
       if( p->zComment!=0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
       p->zComment = blob_terminate(&a1);
       defossilize(p->zComment);
     }else if( z[0]=='D' ){
       char *zDate;
-      md5sum_step_text(blob_buffer(&line), blob_size(&line)+1);
+      md5sum_step_text(blob_buffer(&line), blob_size(&line));
       if( p->rDate!=0.0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
       zDate = blob_terminate(&a1);
       p->rDate = db_double(0.0, "SELECT julianday(%Q)", zDate);
     }else if( z[0]=='U' ){
-      md5sum_step_text(blob_buffer(&line), blob_size(&line)+1);
+      md5sum_step_text(blob_buffer(&line), blob_size(&line));
       if( p->zUser!=0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
       p->zUser = blob_terminate(&a1);
       defossilize(p->zUser);
     }else if( z[0]=='R' ){
-      md5sum_step_text(blob_buffer(&line), blob_size(&line)+1);
+      md5sum_step_text(blob_buffer(&line), blob_size(&line));
       if( p->zRepoCksum!=0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
       if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
       if( blob_size(&a1)!=32 ) goto manifest_syntax_error;
       p->zRepoCksum = blob_terminate(&a1);
       if( !validate16(p->zRepoCksum, 32) ) goto manifest_syntax_error;
     }else if( z[0]=='P' ){
-      md5sum_step_text(blob_buffer(&line), blob_size(&line)+1);
+      md5sum_step_text(blob_buffer(&line), blob_size(&line));
       while( blob_token(&line, &a1) ){
         char *zUuid;
         if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error;
         zUuid = blob_terminate(&a1);
         if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error;