diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2008-04-22 03:51:33 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2008-04-22 03:51:33 +0000 |
commit | 9cbfc47a5aa5bd5d2f61a5dc4a969336d27485fa (patch) | |
tree | f0bd0f7a7993affea43ac5b9182e3567c512de8d /xdelta3 | |
parent | 705dcf8e17695a6a825af621c68ab1f67158e313 (diff) |
First successful merge command. :)
Diffstat (limited to 'xdelta3')
-rw-r--r-- | xdelta3/xdelta3-merge.h | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/xdelta3/xdelta3-merge.h b/xdelta3/xdelta3-merge.h index abc7c54..cd1d7b5 100644 --- a/xdelta3/xdelta3-merge.h +++ b/xdelta3/xdelta3-merge.h | |||
@@ -151,7 +151,7 @@ xd3_whole_append_inst (xd3_stream *stream, | |||
151 | winst->position = stream->whole_target.length; | 151 | winst->position = stream->whole_target.length; |
152 | stream->whole_target.length += inst->size; | 152 | stream->whole_target.length += inst->size; |
153 | 153 | ||
154 | if ((inst->type <= XD3_ADD) && | 154 | if (((inst->type == XD3_ADD) || (inst->type == XD3_RUN)) && |
155 | (ret = xd3_whole_alloc_adds (stream, | 155 | (ret = xd3_whole_alloc_adds (stream, |
156 | (inst->type == XD3_RUN ? 1 : inst->size)))) | 156 | (inst->type == XD3_RUN ? 1 : inst->size)))) |
157 | { | 157 | { |
@@ -249,7 +249,7 @@ int xd3_merge_input_output (xd3_stream *stream, | |||
249 | 249 | ||
250 | static int | 250 | static int |
251 | xd3_merge_run (xd3_stream *stream, | 251 | xd3_merge_run (xd3_stream *stream, |
252 | xd3_whole_state *source, | 252 | xd3_whole_state *target, |
253 | xd3_winst *iinst) | 253 | xd3_winst *iinst) |
254 | { | 254 | { |
255 | int ret; | 255 | int ret; |
@@ -271,14 +271,14 @@ xd3_merge_run (xd3_stream *stream, | |||
271 | stream->whole_target.length += iinst->size; | 271 | stream->whole_target.length += iinst->size; |
272 | 272 | ||
273 | stream->whole_target.adds[stream->whole_target.addslen++] = | 273 | stream->whole_target.adds[stream->whole_target.addslen++] = |
274 | source->adds[iinst->addr]; | 274 | target->adds[iinst->addr]; |
275 | 275 | ||
276 | return 0; | 276 | return 0; |
277 | } | 277 | } |
278 | 278 | ||
279 | static int | 279 | static int |
280 | xd3_merge_add (xd3_stream *stream, | 280 | xd3_merge_add (xd3_stream *stream, |
281 | xd3_whole_state *source, | 281 | xd3_whole_state *target, |
282 | xd3_winst *iinst) | 282 | xd3_winst *iinst) |
283 | { | 283 | { |
284 | int ret; | 284 | int ret; |
@@ -300,7 +300,7 @@ xd3_merge_add (xd3_stream *stream, | |||
300 | stream->whole_target.length += iinst->size; | 300 | stream->whole_target.length += iinst->size; |
301 | 301 | ||
302 | memcpy(stream->whole_target.adds, | 302 | memcpy(stream->whole_target.adds, |
303 | source->adds + iinst->addr, | 303 | target->adds + iinst->addr, |
304 | stream->whole_target.addslen); | 304 | stream->whole_target.addslen); |
305 | 305 | ||
306 | stream->whole_target.addslen += iinst->size; | 306 | stream->whole_target.addslen += iinst->size; |
@@ -315,6 +315,8 @@ xd3_merge_target_copy (xd3_stream *stream, | |||
315 | int ret; | 315 | int ret; |
316 | xd3_winst *oinst; | 316 | xd3_winst *oinst; |
317 | 317 | ||
318 | // TODO: this is totally untested | ||
319 | |||
318 | if ((ret = xd3_whole_alloc_winst (stream, &oinst))) | 320 | if ((ret = xd3_whole_alloc_winst (stream, &oinst))) |
319 | { | 321 | { |
320 | return ret; | 322 | return ret; |
@@ -422,10 +424,39 @@ xd3_merge_source_copy (xd3_stream *stream, | |||
422 | } | 424 | } |
423 | 425 | ||
424 | minst->size = this_take; | 426 | minst->size = this_take; |
425 | minst->mode = VCD_SOURCE; | 427 | minst->type = sinst->type; |
426 | minst->type = XD3_CPY; | ||
427 | minst->addr = sinst->addr + sinst_offset; | ||
428 | minst->position = iinst.position; | 428 | minst->position = iinst.position; |
429 | minst->mode = 0; | ||
430 | |||
431 | switch (sinst->type) | ||
432 | { | ||
433 | case XD3_RUN: | ||
434 | if ((ret = xd3_whole_alloc_adds (stream, 1))) | ||
435 | { | ||
436 | return ret; | ||
437 | } | ||
438 | |||
439 | minst->addr = stream->whole_target.addslen; | ||
440 | stream->whole_target.adds[stream->whole_target.addslen++] = | ||
441 | source->adds[sinst->addr]; | ||
442 | break; | ||
443 | case XD3_ADD: | ||
444 | if ((ret = xd3_whole_alloc_adds (stream, this_take))) | ||
445 | { | ||
446 | return ret; | ||
447 | } | ||
448 | |||
449 | minst->addr = stream->whole_target.addslen; | ||
450 | memcpy(stream->whole_target.adds + stream->whole_target.addslen, | ||
451 | source->adds + sinst->addr + sinst_offset, | ||
452 | this_take); | ||
453 | stream->whole_target.addslen += this_take; | ||
454 | break; | ||
455 | default: | ||
456 | minst->mode = VCD_SOURCE; | ||
457 | minst->addr = sinst->addr + sinst_offset; | ||
458 | break; | ||
459 | } | ||
429 | 460 | ||
430 | stream->whole_target.length += this_take; | 461 | stream->whole_target.length += this_take; |
431 | iinst.position += this_take; | 462 | iinst.position += this_take; |
@@ -454,10 +485,10 @@ int xd3_merge_inputs (xd3_stream *stream, | |||
454 | switch (iinst->type) | 485 | switch (iinst->type) |
455 | { | 486 | { |
456 | case XD3_RUN: | 487 | case XD3_RUN: |
457 | ret = xd3_merge_run (stream, source, iinst); | 488 | ret = xd3_merge_run (stream, input, iinst); |
458 | break; | 489 | break; |
459 | case XD3_ADD: | 490 | case XD3_ADD: |
460 | ret = xd3_merge_add (stream, source, iinst); | 491 | ret = xd3_merge_add (stream, input, iinst); |
461 | break; | 492 | break; |
462 | default: | 493 | default: |
463 | /* Note: VCD_TARGET support is completely untested all | 494 | /* Note: VCD_TARGET support is completely untested all |