diff options
Diffstat (limited to 'xdelta3/xdelta3.c')
-rw-r--r-- | xdelta3/xdelta3.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 8dc43e0..0bf2d77 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -1927,7 +1927,7 @@ xd3_getblk (xd3_stream *stream, xoff_t blkno) | |||
1927 | ret = stream->getblk (stream, source, blkno); | 1927 | ret = stream->getblk (stream, source, blkno); |
1928 | if (ret != 0) | 1928 | if (ret != 0) |
1929 | { | 1929 | { |
1930 | IF_DEBUG1 (DP(RINT "[getblk] app error blkno %"Q"u: %s\n", | 1930 | IF_DEBUG2 (DP(RINT "[getblk] app error blkno %"Q"u: %s\n", |
1931 | blkno, xd3_strerror (ret))); | 1931 | blkno, xd3_strerror (ret))); |
1932 | return ret; | 1932 | return ret; |
1933 | } | 1933 | } |
@@ -3750,13 +3750,17 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos) | |||
3750 | if (srcpos < stream->srcwin_cksum_pos && | 3750 | if (srcpos < stream->srcwin_cksum_pos && |
3751 | stream->srcwin_cksum_pos - srcpos > src->max_winsize) | 3751 | stream->srcwin_cksum_pos - srcpos > src->max_winsize) |
3752 | { | 3752 | { |
3753 | IF_DEBUG1(DP(RINT "[match_setup] rejected due to src->max_winsize " | 3753 | IF_DEBUG2(DP(RINT "[match_setup] rejected due to src->max_winsize " |
3754 | "distance eof=%"Q"u srcpos=%"Q"u max_winsz=%"Q"u\n", | 3754 | "distance eof=%"Q"u srcpos=%"Q"u max_winsz=%"Q"u\n", |
3755 | xd3_source_eof (src), | 3755 | xd3_source_eof (src), |
3756 | srcpos, src->max_winsize)); | 3756 | srcpos, src->max_winsize)); |
3757 | goto bad; | 3757 | goto bad; |
3758 | } | 3758 | } |
3759 | 3759 | ||
3760 | /* There are cases where the above test does not reject a match that | ||
3761 | * will experience XD3_TOOFARBACK at the first xd3_getblk call | ||
3762 | * because the input may have advanced up to one block beyond the | ||
3763 | * actual EOF. */ | ||
3760 | IF_DEBUG2(DP(RINT "[match_setup] %"Q"u srcpos %"Q"u, " | 3764 | IF_DEBUG2(DP(RINT "[match_setup] %"Q"u srcpos %"Q"u, " |
3761 | "src->max_winsize %"Q"u\n", | 3765 | "src->max_winsize %"Q"u\n", |
3762 | stream->total_in + stream->input_position, | 3766 | stream->total_in + stream->input_position, |
@@ -3929,9 +3933,6 @@ xd3_source_extend_match (xd3_stream *stream) | |||
3929 | usize_t tryrem; /* tryrem is the number of matchable bytes */ | 3933 | usize_t tryrem; /* tryrem is the number of matchable bytes */ |
3930 | usize_t matched; | 3934 | usize_t matched; |
3931 | 3935 | ||
3932 | IF_DEBUG2(DP(RINT "[extend match] srcpos %"Q"u\n", | ||
3933 | stream->match_srcpos)); | ||
3934 | |||
3935 | XD3_ASSERT (src != NULL); | 3936 | XD3_ASSERT (src != NULL); |
3936 | 3937 | ||
3937 | /* Does it make sense to compute backward match AFTER forward match? */ | 3938 | /* Does it make sense to compute backward match AFTER forward match? */ |
@@ -3957,8 +3958,10 @@ xd3_source_extend_match (xd3_stream *stream) | |||
3957 | { | 3958 | { |
3958 | if (ret == XD3_TOOFARBACK) | 3959 | if (ret == XD3_TOOFARBACK) |
3959 | { | 3960 | { |
3960 | IF_DEBUG1(DP(RINT "[maxback] %"Q"u TOOFARBACK: %u\n", | 3961 | IF_DEBUG2(DP(RINT "[maxback] %"Q"u TOOFARBACK: %u INP %"Q"u CKSUM %"Q"u\n", |
3961 | tryblk, stream->match_back)); | 3962 | tryblk, stream->match_back, |
3963 | stream->total_in + stream->input_position, | ||
3964 | stream->srcwin_cksum_pos)); | ||
3962 | 3965 | ||
3963 | /* the starting position is too far back. */ | 3966 | /* the starting position is too far back. */ |
3964 | if (stream->match_back == 0) | 3967 | if (stream->match_back == 0) |
@@ -4014,7 +4017,14 @@ xd3_source_extend_match (xd3_stream *stream) | |||
4014 | 4017 | ||
4015 | if ((ret = xd3_getblk (stream, tryblk))) | 4018 | if ((ret = xd3_getblk (stream, tryblk))) |
4016 | { | 4019 | { |
4017 | XD3_ASSERT (ret != XD3_TOOFARBACK); | 4020 | if (ret == XD3_TOOFARBACK) |
4021 | { | ||
4022 | IF_DEBUG2(DP(RINT "[maxfwd] %"Q"u TOOFARBACK: %u INP %"Q"u CKSUM %"Q"u\n", | ||
4023 | tryblk, stream->match_fwd, | ||
4024 | stream->total_in + stream->input_position, | ||
4025 | stream->srcwin_cksum_pos)); | ||
4026 | goto donefwd; | ||
4027 | } | ||
4018 | 4028 | ||
4019 | /* could be a XD3_GETSRCBLK failure. */ | 4029 | /* could be a XD3_GETSRCBLK failure. */ |
4020 | return ret; | 4030 | return ret; |
@@ -4048,6 +4058,11 @@ xd3_source_extend_match (xd3_stream *stream) | |||
4048 | donefwd: | 4058 | donefwd: |
4049 | stream->match_state = MATCH_SEARCHING; | 4059 | stream->match_state = MATCH_SEARCHING; |
4050 | 4060 | ||
4061 | IF_DEBUG2(DP(RINT "[extend match] input %"Q"u srcpos %"Q"u len %u\n", | ||
4062 | stream->input_position + stream->total_in, | ||
4063 | stream->match_srcpos, | ||
4064 | stream->match_fwd)); | ||
4065 | |||
4051 | /* If the match ends short of the last instruction end, we probably | 4066 | /* If the match ends short of the last instruction end, we probably |
4052 | * don't want it. There is the possibility that a copy ends short | 4067 | * don't want it. There is the possibility that a copy ends short |
4053 | * of the last copy but also goes further back, in which case we | 4068 | * of the last copy but also goes further back, in which case we |
@@ -4099,8 +4114,9 @@ xd3_source_extend_match (xd3_stream *stream) | |||
4099 | 4114 | ||
4100 | IF_DEBUG2 ({ | 4115 | IF_DEBUG2 ({ |
4101 | static int x = 0; | 4116 | static int x = 0; |
4102 | DP(RINT "[source match:%d] <inp %"Q"u %"Q"u> <src %"Q"u %"Q"u> (%s) [ %u bytes ]\n", | 4117 | DP(RINT "[source match:%d] length %u <inp %"Q"u %"Q"u> <src %"Q"u %"Q"u> (%s) [ %u bytes ]\n", |
4103 | x++, | 4118 | x++, |
4119 | match_length, | ||
4104 | stream->total_in + target_position, | 4120 | stream->total_in + target_position, |
4105 | stream->total_in + target_position + match_length, | 4121 | stream->total_in + target_position + match_length, |
4106 | match_position, | 4122 | match_position, |