summaryrefslogtreecommitdiff
path: root/app/bin/cundo.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-05-27 14:58:02 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-05-27 14:58:02 +0200
commit359b557176b9bb2ff1aed2082641eed39c358d0d (patch)
treef6c2baca2e6a5d06b7bf32e48e475a6b7b1ea262 /app/bin/cundo.c
parent9a1d6eded2750572e9f5f79e53ec507dd7a06ba5 (diff)
New upstream version 5.1.2aupstream/5.1.2a
Diffstat (limited to 'app/bin/cundo.c')
-rw-r--r--app/bin/cundo.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/app/bin/cundo.c b/app/bin/cundo.c
index e27ee75..1ed5588 100644
--- a/app/bin/cundo.c
+++ b/app/bin/cundo.c
@@ -330,16 +330,25 @@ LOG( log_undo, 3, ( "TruncateStream( , %ld )\n", off ) )
UASSERT( stream->stream_da.cnt >= 0, stream->stream_da.cnt );
return TRUE;
}
+
BOOL_T WriteObject( stream_p stream, char op, track_p trk )
{
+ void * buff = NULL;
+ long len = 0;
if (!WriteStream( stream, &op, sizeof op ) ||
!WriteStream( stream, &trk, sizeof trk ) ||
!WriteStream( stream, trk, sizeof *trk ) ||
!WriteStream( stream, trk->endPt, trk->endCnt * sizeof trk->endPt[0] ) ||
- !WriteStream( stream, trk->extraData, trk->extraSize ) ) {
+ !WriteStream( stream, trk->extraData, trk->extraSize ))
return FALSE;
- }
+ /* Add a copy of the any type specific data before it is tampered with, for example */
+ StoreTrackData(trk,&buff,&len);
+ if (!WriteStream( stream, &len, sizeof len ))
+ return FALSE;
+ if (len)
+ if (!WriteStream( stream, buff, len ))
+ return FALSE;
return TRUE;
}
@@ -371,7 +380,19 @@ static BOOL_T ReadObject( stream_p stream, BOOL_T needRedo )
tempTrk.extraData = trk->extraData;
if (!ReadStream( stream, tempTrk.extraData, tempTrk.extraSize ))
return FALSE;
- RebuildTrackSegs(&tempTrk); //If we had an array of Segs - recreate it
+ long Addsize;
+ void * tempBuff;
+ /* Fix up pts to be as big as it was before -> because it may have changed since */
+ if (!ReadStream (stream, &Addsize, sizeof Addsize))
+ return FALSE;
+ if (Addsize) {
+ tempBuff = MyMalloc(Addsize);
+ if (!ReadStream( stream, tempBuff, Addsize ))
+ return FALSE;
+ ReplayTrackData(&tempTrk, tempBuff, Addsize);
+ MyFree(tempBuff);
+ }
+ RebuildTrackSegs(&tempTrk); //If we had an array of Segs - recreate it
if (recordUndo) Rprintf( "Restore T%D(%d) @ %lx\n", trk->index, tempTrk.index, (long)trk );
tempTrk.index = trk->index;
tempTrk.next = trk->next;
@@ -385,7 +406,7 @@ static BOOL_T ReadObject( stream_p stream, BOOL_T needRedo )
}
-static void RedrawInStream( stream_p stream, long start, long end, BOOL_T draw )
+static BOOL_T RedrawInStream( stream_p stream, long start, long end, BOOL_T draw )
{
char op;
track_p trk;
@@ -395,8 +416,12 @@ static void RedrawInStream( stream_p stream, long start, long end, BOOL_T draw )
if (!ReadStream( stream, &op, sizeof op ) ||
!ReadStream( stream, &trk, sizeof trk ) ||
!ReadStream( stream, &tempTrk, sizeof tempTrk ) )
- return;
- stream->curr += tempTrk.extraSize + tempTrk.endCnt*sizeof tempTrk.endPt[0];
+ return FALSE;
+ stream->curr += tempTrk.extraSize + tempTrk.endCnt*sizeof tempTrk.endPt[0];;
+ long Addsize;
+ if (!ReadStream( stream, &Addsize, sizeof Addsize ))
+ return FALSE;
+ stream->curr += Addsize;
if (!trk->deleted) {
if (draw)
DrawNewTrack( trk );
@@ -404,6 +429,7 @@ static void RedrawInStream( stream_p stream, long start, long end, BOOL_T draw )
UndrawNewTrack( trk );
}
}
+ return TRUE;
}
@@ -421,15 +447,20 @@ LOG( log_undo, 3, ( "DeleteInSteam( , %ld, %ld )\n", start, end ) )
return FALSE;
UASSERT( op == ModifyOp || op == DeleteOp, (long)op );
if (!ReadStream( stream, &trk, sizeof trk ) ||
- !ReadStream( stream, &tempTrk, sizeof tempTrk ) )
+ !ReadStream( stream, &tempTrk, sizeof tempTrk ))
return FALSE;
stream->curr += tempTrk.extraSize + tempTrk.endCnt*sizeof tempTrk.endPt[0];
+ long Addsize;
+ if (!ReadStream( stream, &Addsize, sizeof Addsize ))
+ return FALSE;
+ stream->curr += Addsize;
if (op == DeleteOp) {
if (recordUndo) Rprintf( " Free T%D(%d) @ %lx\n", trk->index, tempTrk.index, (long)trk );
UASSERT( IsTrackDeleted(trk), (long)trk );
trk->index = -1;
delCount++;
}
+
}
if (delCount) {
for (ptrk=&to_first; *ptrk; ) {
@@ -475,6 +506,10 @@ static BOOL_T SetDeleteOpInStream( stream_p stream, long start, long end, track_
if (!ReadStream( stream, &tempTrk, sizeof tempTrk ))
return FALSE;
stream->curr += tempTrk.extraSize + tempTrk.endCnt*sizeof tempTrk.endPt[0];
+ long Addsize;
+ if (!ReadStream( stream, &Addsize, sizeof Addsize))
+ return FALSE;
+ stream->curr += Addsize;
}
UASSERT( "Cannot find undo record to convert to DeleteOp", 0 );
return FALSE;