Differences From:
File
src/blob.c
part of check-in
[61ddd63b72]
- Work toward making fossil work better on large repositories.
This version implements a cache in the content manager. It is not
clear yet if this is necessarily a good idea - this check-in might
end up on an abandoned branch at some point.
by
drh on
2008-03-06 22:58:48.
[view]
To:
File
src/blob.c
part of check-in
[e976aa6fcb]
- 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.
by
drh on
2008-06-08 19:31:28.
[view]
@@ -835,5 +835,46 @@
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;
}