summaryrefslogtreecommitdiff
path: root/xdelta3
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2007-09-13 09:59:55 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2007-09-13 09:59:55 +0000
commit94fc679c61ca73182ba9d473a36253364f8f1967 (patch)
tree50db96ee01d0a73bd2809bb2fcd0401955180850 /xdelta3
parentc453ed7952ef5ee3f7d799f8ed7ee113ee711e28 (diff)
Fix secondary compression for recode. Now able to reproduce doytchin's
bug report by recoding an FGK as a DJW.
Diffstat (limited to 'xdelta3')
-rw-r--r--xdelta3/setup.py2
-rw-r--r--xdelta3/xdelta3-decode.h35
-rw-r--r--xdelta3/xdelta3-main.h66
-rw-r--r--xdelta3/xdelta3-second.h1
-rw-r--r--xdelta3/xdelta3.h4
-rw-r--r--xdelta3/xdelta3.prj2
6 files changed, 59 insertions, 51 deletions
diff --git a/xdelta3/setup.py b/xdelta3/setup.py
index f50e34a..6e2bd66 100644
--- a/xdelta3/setup.py
+++ b/xdelta3/setup.py
@@ -49,7 +49,7 @@ xdelta3_ext = Extension('xdelta3main',
49 ]) 49 ])
50 50
51# $Format: "REL='$Xdelta3Version$'" $ 51# $Format: "REL='$Xdelta3Version$'" $
52REL='0q' 52REL='0p_0'
53 53
54# This provides xdelta3.main(), which calls the xdelta3 command-line main() 54# This provides xdelta3.main(), which calls the xdelta3 command-line main()
55# from python. 55# from python.
diff --git a/xdelta3/xdelta3-decode.h b/xdelta3/xdelta3-decode.h
index fd41675..0368cdc 100644
--- a/xdelta3/xdelta3-decode.h
+++ b/xdelta3/xdelta3-decode.h
@@ -495,6 +495,27 @@ xd3_decode_finish_window (xd3_stream *stream)
495} 495}
496 496
497static int 497static int
498xd3_decode_secondary_sections (xd3_stream *secondary_stream)
499{
500#if SECONDARY_ANY
501 int ret;
502#define DECODE_SECONDARY_SECTION(UPPER,LOWER) \
503 ((secondary_stream->dec_del_ind & VCD_ ## UPPER ## COMP) && \
504 (ret = xd3_decode_secondary (secondary_stream, & secondary_stream-> LOWER ## _sect, \
505 & xd3_sec_ ## LOWER (secondary_stream))))
506
507 if (DECODE_SECONDARY_SECTION (DATA, data) ||
508 DECODE_SECONDARY_SECTION (INST, inst) ||
509 DECODE_SECONDARY_SECTION (ADDR, addr))
510 {
511 return ret;
512 }
513#undef DECODE_SECONDARY_SECTION
514#endif
515 return 0;
516}
517
518static int
498xd3_decode_sections (xd3_stream *stream) 519xd3_decode_sections (xd3_stream *stream)
499{ 520{
500 usize_t need, more, take; 521 usize_t need, more, take;
@@ -557,19 +578,7 @@ xd3_decode_sections (xd3_stream *stream)
557 578
558 XD3_ASSERT (stream->dec_winbytes == need); 579 XD3_ASSERT (stream->dec_winbytes == need);
559 580
560#if SECONDARY_ANY 581 if ((ret = xd3_decode_secondary_sections (stream))) { return ret; }
561#define DECODE_SECONDARY_SECTION(UPPER,LOWER) \
562 ((stream->dec_del_ind & VCD_ ## UPPER ## COMP) && \
563 (ret = xd3_decode_secondary (stream, & stream-> LOWER ## _sect, \
564 & xd3_sec_ ## LOWER (stream))))
565
566 if (DECODE_SECONDARY_SECTION (DATA, data) ||
567 DECODE_SECONDARY_SECTION (INST, inst) ||
568 DECODE_SECONDARY_SECTION (ADDR, addr))
569 {
570 return ret;
571 }
572#endif
573 582
574 if (stream->flags & XD3_SKIP_EMIT) 583 if (stream->flags & XD3_SKIP_EMIT)
575 { 584 {
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 5d13ad6..c56bead 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -1261,6 +1261,7 @@ main_recode_copy (xd3_stream* stream,
1261 &output->base, 1261 &output->base,
1262 &output->avail))) 1262 &output->avail)))
1263 { 1263 {
1264 XPR(NT XD3_LIB_ERRMSG (stream, ret));
1264 return ret; 1265 return ret;
1265 } 1266 }
1266 1267
@@ -2484,13 +2485,40 @@ main_input (xd3_cmd cmd,
2484 2485
2485 start_time = get_millisecs_now (); 2486 start_time = get_millisecs_now ();
2486 2487
2488 if (option_use_secondary)
2489 {
2490 /* The default secondary compressor is DJW, if it's compiled, being used, etc. */
2491 if (option_secondary == NULL)
2492 {
2493 if (SECONDARY_DJW) { stream_flags |= XD3_SEC_DJW; }
2494 }
2495 else
2496 {
2497 if (strcmp (option_secondary, "fgk") == 0 && SECONDARY_FGK)
2498 {
2499 stream_flags |= XD3_SEC_FGK;
2500 }
2501 else if (strcmp (option_secondary, "djw") == 0 && SECONDARY_DJW)
2502 {
2503 stream_flags |= XD3_SEC_DJW;
2504 }
2505 else
2506 {
2507 XPR(NT "unrecognized secondary compressor type: %s\n", option_secondary);
2508 return EXIT_FAILURE;
2509 }
2510 }
2511 }
2512
2513 if (option_use_checksum) { stream_flags |= XD3_ADLER32; }
2514
2487 /* main_input setup. */ 2515 /* main_input setup. */
2488 switch ((int) cmd) 2516 switch ((int) cmd)
2489 { 2517 {
2490#if VCDIFF_TOOLS 2518#if VCDIFF_TOOLS
2491 if (1) { case CMD_PRINTHDR: stream_flags = XD3_JUST_HDR; } 2519 if (1) { case CMD_PRINTHDR: stream_flags |= XD3_JUST_HDR; }
2492 else if (1) { case CMD_PRINTHDRS: stream_flags = XD3_SKIP_WINDOW; } 2520 else if (1) { case CMD_PRINTHDRS: stream_flags |= XD3_SKIP_WINDOW; }
2493 else { case CMD_PRINTDELTA: stream_flags = XD3_SKIP_EMIT; } 2521 else { case CMD_PRINTDELTA: stream_flags |= XD3_SKIP_EMIT; }
2494 ifile->flags |= RD_NONEXTERNAL; 2522 ifile->flags |= RD_NONEXTERNAL;
2495 input_func = xd3_decode_input; 2523 input_func = xd3_decode_input;
2496 output_func = main_print_func; 2524 output_func = main_print_func;
@@ -2499,14 +2527,13 @@ main_input (xd3_cmd cmd,
2499 break; 2527 break;
2500 2528
2501 case CMD_RECODE: 2529 case CMD_RECODE:
2502
2503 // No source will be read 2530 // No source will be read
2504 stream_flags |= XD3_ADLER32_NOVER; 2531 stream_flags |= XD3_ADLER32_NOVER | XD3_SKIP_EMIT;
2505 2532
2506 XD3_ASSERT (recode_stream == NULL); 2533 XD3_ASSERT (recode_stream == NULL);
2507 recode_stream = (xd3_stream*) main_malloc(sizeof(xd3_stream)); 2534 recode_stream = (xd3_stream*) main_malloc(sizeof(xd3_stream));
2508 2535
2509 int recode_flags = (stream.flags & XD3_SEC_TYPE); 2536 int recode_flags = (stream_flags & XD3_SEC_TYPE);
2510 // TODO: what about sec_xxxx.ngroups = 1? 2537 // TODO: what about sec_xxxx.ngroups = 1?
2511 2538
2512 xd3_config recode_config; 2539 xd3_config recode_config;
@@ -2521,6 +2548,7 @@ main_input (xd3_cmd cmd,
2521 if ((ret = xd3_config_stream (recode_stream, &recode_config)) || 2548 if ((ret = xd3_config_stream (recode_stream, &recode_config)) ||
2522 (ret = xd3_encode_init_buffers (recode_stream))) 2549 (ret = xd3_encode_init_buffers (recode_stream)))
2523 { 2550 {
2551 XPR(NT XD3_LIB_ERRMSG (& stream, ret));
2524 return EXIT_FAILURE; 2552 return EXIT_FAILURE;
2525 } 2553 }
2526 2554
@@ -2537,31 +2565,6 @@ main_input (xd3_cmd cmd,
2537 input_func = xd3_encode_input; 2565 input_func = xd3_encode_input;
2538 output_func = main_write_output; 2566 output_func = main_write_output;
2539 2567
2540 if (option_use_checksum) { stream_flags |= XD3_ADLER32; }
2541 if (option_use_secondary)
2542 {
2543 /* The default secondary compressor is DJW, if it's compiled, being used, etc. */
2544 if (option_secondary == NULL)
2545 {
2546 if (SECONDARY_DJW) { stream_flags |= XD3_SEC_DJW; }
2547 }
2548 else
2549 {
2550 if (strcmp (option_secondary, "fgk") == 0 && SECONDARY_FGK)
2551 {
2552 stream_flags |= XD3_SEC_FGK;
2553 }
2554 else if (strcmp (option_secondary, "djw") == 0 && SECONDARY_DJW)
2555 {
2556 stream_flags |= XD3_SEC_DJW;
2557 }
2558 else
2559 {
2560 XPR(NT "unrecognized secondary compressor type: %s\n", option_secondary);
2561 return EXIT_FAILURE;
2562 }
2563 }
2564 }
2565 if (option_no_compress) { stream_flags |= XD3_NOCOMPRESS; } 2568 if (option_no_compress) { stream_flags |= XD3_NOCOMPRESS; }
2566 if (option_use_altcodetable) { stream_flags |= XD3_ALT_CODE_TABLE; } 2569 if (option_use_altcodetable) { stream_flags |= XD3_ALT_CODE_TABLE; }
2567 if (option_smatch_config) 2570 if (option_smatch_config)
@@ -2615,7 +2618,6 @@ main_input (xd3_cmd cmd,
2615#endif 2618#endif
2616 case CMD_DECODE: 2619 case CMD_DECODE:
2617 if (option_use_checksum == 0) { stream_flags |= XD3_ADLER32_NOVER; } 2620 if (option_use_checksum == 0) { stream_flags |= XD3_ADLER32_NOVER; }
2618 stream_flags = 0;
2619 ifile->flags |= RD_NONEXTERNAL; 2621 ifile->flags |= RD_NONEXTERNAL;
2620 input_func = xd3_decode_input; 2622 input_func = xd3_decode_input;
2621 output_func = main_write_output; 2623 output_func = main_write_output;
diff --git a/xdelta3/xdelta3-second.h b/xdelta3/xdelta3-second.h
index f925586..db3a68c 100644
--- a/xdelta3/xdelta3-second.h
+++ b/xdelta3/xdelta3-second.h
@@ -198,6 +198,7 @@ xd3_decode_secondary (xd3_stream *stream,
198 198
199 sect->buf = sect->copied2; 199 sect->buf = sect->copied2;
200 sect->buf_max = sect->copied2 + dec_size; 200 sect->buf_max = sect->copied2 + dec_size;
201 sect->size = dec_size;
201 202
202 return 0; 203 return 0;
203} 204}
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index 2b6169b..07b2be0 100644
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -100,11 +100,7 @@ typedef u_int16_t uint16_t;
100typedef u_int32_t uint32_t; 100typedef u_int32_t uint32_t;
101#endif 101#endif
102 102
103#if sizeof(long) < 8
104typedef u_int64_t uint64_t;
105#else
106typedef long long unsigned int uint64_t; 103typedef long long unsigned int uint64_t;
107#endif
108 104
109#else 105#else
110#define WIN32_LEAN_AND_MEAN 106#define WIN32_LEAN_AND_MEAN
diff --git a/xdelta3/xdelta3.prj b/xdelta3/xdelta3.prj
index 130abed..42ddee9 100644
--- a/xdelta3/xdelta3.prj
+++ b/xdelta3/xdelta3.prj
@@ -9,7 +9,7 @@
9(Checkin-Login jmacd) 9(Checkin-Login jmacd)
10(Populate-Ignore ("\\.svn")) 10(Populate-Ignore ("\\.svn"))
11(Project-Keywords 11(Project-Keywords
12 (Xdelta3Version "0q") 12 (Xdelta3Version "0p_0")
13 ) 13 )
14(Files 14(Files
15 (COPYING (xdelta3/b/29_COPYING 1.1 744)) 15 (COPYING (xdelta3/b/29_COPYING 1.1 744))