summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua MacDonald <josh.macdonald@gmail.com>2015-12-07 23:50:05 -0800
committerJoshua MacDonald <josh.macdonald@gmail.com>2015-12-07 23:50:05 -0800
commitc362b118eaeffa62b273b56d10715ab61f49fd9d (patch)
tree34e55faa85f02df5fc446af110e967fd5319bfea
parentc5884f221e281b0fa52c5e71f9329813ec9cea48 (diff)
One more XD3_TOOFARBACK case handled (regtest.go)
-rw-r--r--xdelta3/xdelta3-decode.h6
-rw-r--r--xdelta3/xdelta3-main.h7
-rw-r--r--xdelta3/xdelta3.c34
3 files changed, 36 insertions, 11 deletions
diff --git a/xdelta3/xdelta3-decode.h b/xdelta3/xdelta3-decode.h
index 3266425..65877a4 100644
--- a/xdelta3/xdelta3-decode.h
+++ b/xdelta3/xdelta3-decode.h
@@ -207,6 +207,8 @@ xd3_decode_section (xd3_stream *stream,
207 /* No allocation/copy needed */ 207 /* No allocation/copy needed */
208 section->buf = stream->next_in; 208 section->buf = stream->next_in;
209 sect_take = section->size; 209 sect_take = section->size;
210 IF_DEBUG1 (DP(RINT "[xd3_decode_section] zerocopy %u @ %u avail %u\n",
211 sect_take, section->pos, stream->avail_in));
210 } 212 }
211 else 213 else
212 { 214 {
@@ -230,8 +232,8 @@ xd3_decode_section (xd3_stream *stream,
230 section->buf = section->copied1; 232 section->buf = section->copied1;
231 } 233 }
232 234
233 IF_DEBUG2 (DP(RINT "[xd3_decode_section] take %u @ %u[%u] size %u\n", 235 IF_DEBUG2 (DP(RINT "[xd3_decode_section] take %u @ %u [need %u] avail %u\n",
234 sect_take, section->pos, section->alloc1, section->size)); 236 sect_take, section->pos, sect_need, stream->avail_in));
235 XD3_ASSERT (section->pos + sect_take <= section->alloc1); 237 XD3_ASSERT (section->pos + sect_take <= section->alloc1);
236 238
237 memcpy (section->copied1 + section->pos, 239 memcpy (section->copied1 + section->pos,
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index e7ce493..ede5e73 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -856,6 +856,8 @@ main_file_open (main_file *xfile, const char* name, int mode)
856 return XD3_INVALID; 856 return XD3_INVALID;
857 } 857 }
858 858
859 IF_DEBUG1(DP(RINT "[main] open source %s\n", name));
860
859#if XD3_STDIO 861#if XD3_STDIO
860 xfile->file = fopen (name, XOPEN_STDIO); 862 xfile->file = fopen (name, XOPEN_STDIO);
861 863
@@ -1027,6 +1029,7 @@ main_file_read (main_file *ifile,
1027 const char *msg) 1029 const char *msg)
1028{ 1030{
1029 int ret = 0; 1031 int ret = 0;
1032 IF_DEBUG1(DP(RINT "[main] read %s up to %"Z"u\n", ifile->filename, size));
1030 1033
1031#if XD3_STDIO 1034#if XD3_STDIO
1032 size_t result; 1035 size_t result;
@@ -1067,6 +1070,8 @@ main_file_write (main_file *ofile, uint8_t *buf, usize_t size, const char *msg)
1067{ 1070{
1068 int ret = 0; 1071 int ret = 0;
1069 1072
1073 IF_DEBUG1(DP(RINT "[main] write %u\n bytes", size));
1074
1070#if XD3_STDIO 1075#if XD3_STDIO
1071 usize_t result; 1076 usize_t result;
1072 1077
@@ -1136,6 +1141,8 @@ main_write_output (xd3_stream* stream, main_file *ofile)
1136{ 1141{
1137 int ret; 1142 int ret;
1138 1143
1144 IF_DEBUG1(DP(RINT "[main] write(%s) %u\n bytes", ofile->filename, stream->avail_out));
1145
1139 if (option_no_output) 1146 if (option_no_output)
1140 { 1147 {
1141 return 0; 1148 return 0;
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,