Check-in [e976aa6fcb]
Not logged in
Overview

SHA1 Hash:e976aa6fcbc4a0eae6fd754b81726e67a297ea7d
Date: 2008-06-08 19:31:28
User: drh
Comment:Use cr/nl instead of just nl at the end of every line on the check-in comment template for windows. Strip out the cr characters before completing the commit.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/blob.c from [abc48788ed] to [ea84a9c14c].

@@ -834,6 +834,47 @@
     blob_reset(&b1);
     blob_reset(&b2);
     blob_reset(&b3);
   }
   printf("ok\n");
+}
+
+/*
+** Convert every \n character in the given blob into \r\n.
+*/
+void blob_add_cr(Blob *p){
+  int i, j, n;
+  char *z = p->aData;
+  for(i=n=0; i<p->nUsed; i++){
+    if( z[i]=='\n' ) n++;
+  }
+  if( p->nUsed+n+1>p->nAlloc ){
+    blob_resize(p, p->nUsed+n);
+    z = p->aData;
+  }
+  i = p->nUsed - 1;
+  j = i + n;
+  while( j>i ){
+    z[j--] = z[i];
+    if( z[i]=='\n' ){
+      z[j--] = '\r';
+    }
+    i--;
+  }
+  p->nUsed += n;
+  p->aData[p->nUsed] = 0;
+}
+
+/*
+** Remove every \r character from the given blob.
+*/
+void blob_remove_cr(Blob *p){
+  int i, j;
+  char *z;
+  blob_materialize(p);
+  z = p->aData;
+  for(i=j=0; z[i]; i++){
+    if( z[i]!='\r' ) z[j++] = z[i];
+  }
+  z[j] = 0;
+  p->nUsed = j;
 }

Modified src/checkin.c from [2acc611eda] to [e9356000f0].

@@ -245,18 +245,22 @@
   if( zEditor==0 ){
     zEditor = "ed";
   }
   zFile = db_text(0, "SELECT '%qci-comment-' || hex(randomblob(6)) || '.txt'",
                    g.zLocalRoot);
+#ifdef __MINGW32__
+  blob_add_cr(&text);
+#endif
   blob_write_to_file(&text, zFile);
   zCmd = mprintf("%s \"%s\"", zEditor, zFile);
   printf("%s\n", zCmd);
   if( system(zCmd) ){
     fossil_panic("editor aborted");
   }
   blob_reset(&text);
   blob_read_from_file(&text, zFile);
+  blob_remove_cr(&text);
   unlink(zFile);
   free(zFile);
   blob_zero(pComment);
   while( blob_line(&text, &line) ){
     int i, n;