diff options
-rwxr-xr-x | xdelta3/.gdb_history | 256 | ||||
-rwxr-xr-x | xdelta3/.xdelta3.prcs_aux | 84 | ||||
-rwxr-xr-x | xdelta3/xdelta3-main.h | 44 | ||||
-rwxr-xr-x | xdelta3/xdelta3.c | 231 | ||||
-rwxr-xr-x | xdelta3/xdelta3.h | 4 |
5 files changed, 142 insertions, 477 deletions
diff --git a/xdelta3/.gdb_history b/xdelta3/.gdb_history deleted file mode 100755 index 72410e8..0000000 --- a/xdelta3/.gdb_history +++ /dev/null | |||
@@ -1,256 +0,0 @@ | |||
1 | run test | ||
2 | i[ | ||
3 | up | ||
4 | print tpos | ||
5 | print recon_size | ||
6 | break xdelta3-test.h:2323 | ||
7 | run | ||
8 | s | ||
9 | s | ||
10 | n | ||
11 | print input_size | ||
12 | up | ||
13 | up | ||
14 | print delta | ||
15 | print delta_size | ||
16 | run -vv -f -s ~/Desktop/hello.c ~/Desktop/world.c hw | ||
17 | up | ||
18 | down | ||
19 | break xdelta3-main.h:2252 | ||
20 | run | ||
21 | s | ||
22 | n | ||
23 | c | ||
24 | c | ||
25 | c | ||
26 | run -vv -f -s ~/Desktop/hello.c ~/Desktop/world.c hw | ||
27 | run -vv -f -s testcase/6/source testcase/6/target | ||
28 | break xdelta3.c:5792 | ||
29 | run | ||
30 | up | ||
31 | updown | ||
32 | break xdelta3.c:3837 | ||
33 | run | ||
34 | s | ||
35 | n | ||
36 | print matchoff | ||
37 | print streamoff | ||
38 | print tryblk | ||
39 | print tryoff | ||
40 | n | ||
41 | n | ||
42 | n | ||
43 | print stream->match_maxfwd | ||
44 | print stream->match_fwd | ||
45 | print str->cublk | ||
46 | print str->curblk | ||
47 | print src->curblk | ||
48 | print tryoff | ||
49 | n | ||
50 | n | ||
51 | print tryoff | ||
52 | n | ||
53 | print tryoff | ||
54 | print src->curblk[21] | ||
55 | print stream->next_in[21] | ||
56 | print src->curblk | ||
57 | print stream->next_in | ||
58 | break xdelta3.c:5726 | ||
59 | c | ||
60 | n | ||
61 | print stream->match_fwd | ||
62 | n | ||
63 | n | ||
64 | n | ||
65 | n | ||
66 | n | ||
67 | n | ||
68 | s | ||
69 | n | ||
70 | n | ||
71 | n | ||
72 | n | ||
73 | n | ||
74 | n | ||
75 | n | ||
76 | step 1 | ||
77 | step 1 | ||
78 | run -s testcase/3/source.doc testcase/3/target.doc | ||
79 | break xdelta3.c:2697 | ||
80 | run | ||
81 | p blkno | ||
82 | p source->blocks | ||
83 | up | ||
84 | run -s testcase/3/source.doc testcase/3/target.doc out | ||
85 | run -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
86 | break xdelta3.c:5095 | ||
87 | run | ||
88 | p logical_input_cksum_pos | ||
89 | p stream->input_pos | ||
90 | p stream->input_position | ||
91 | p stream->srcwin_size | ||
92 | p stream->total_in | ||
93 | n | ||
94 | p logical_input_cksum_pos | ||
95 | p stream-srcwin_cksum_pos | ||
96 | p stream->srcwin_cksum_pos | ||
97 | n | ||
98 | n | ||
99 | n | ||
100 | p stream->srcwin_size | ||
101 | n | ||
102 | n | ||
103 | p blkno | ||
104 | p blkoff | ||
105 | p onblk | ||
106 | n | ||
107 | n | ||
108 | n | ||
109 | break xdelta3.c:5114 | ||
110 | c | ||
111 | n | ||
112 | k | ||
113 | y | ||
114 | step 1 | ||
115 | d | ||
116 | break xdelta3.c:5103 | ||
117 | break xdelta3.c:5097 | ||
118 | run | ||
119 | n | ||
120 | p logical_input_cksum_pos | ||
121 | p stream->srcwin_size | ||
122 | c | ||
123 | n | ||
124 | p stream->srcwin_cksum_pos | ||
125 | run | ||
126 | n | ||
127 | c | ||
128 | fin | ||
129 | up | ||
130 | down | ||
131 | c | ||
132 | up | ||
133 | break xdelta3.c:5131 | ||
134 | c | ||
135 | n | ||
136 | p diff | ||
137 | p onblk | ||
138 | n | ||
139 | p onblk | ||
140 | p blkoff | ||
141 | p blkoff | ||
142 | p stream->large_look | ||
143 | k | ||
144 | y | ||
145 | c | ||
146 | k | ||
147 | break xdelta3.c:5103 | ||
148 | run -s testcase/3/source.doc testcase/3/target.doc | ||
149 | n | ||
150 | o ibbkj | ||
151 | p onblk | ||
152 | n | ||
153 | p blkoff | ||
154 | p onblk | ||
155 | n | ||
156 | p blkoff | ||
157 | break xdelta3.c:5119 | ||
158 | c | ||
159 | n | ||
160 | p stream->input_position | ||
161 | p stream->srcwin_cksum_pos | ||
162 | p stream->stream->srcwin_size | ||
163 | p stream->srcwin_size | ||
164 | p logical_input_cksum_pos | ||
165 | p *next_move_point | ||
166 | c | ||
167 | n | ||
168 | p stream->input_position | ||
169 | p logical_input_cksum_pos | ||
170 | p logical_input_cksum_pos | ||
171 | p stream->srcwin_cksum_pos | ||
172 | d | ||
173 | c | ||
174 | run -s testcase/3/source.doc testcase/3/target.doc -o /tmp/foo12 | ||
175 | run -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
176 | run -vv -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
177 | k | ||
178 | y | ||
179 | run -vv -s testcase/3/source.doc testcase/3/target.doc | ||
180 | run -vv -s testcase/3/source.doc testcase/3/target.doc | ||
181 | run -vv -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
182 | up | ||
183 | n | ||
184 | fin | ||
185 | n | ||
186 | break xdelta3.c:5119 | ||
187 | c | ||
188 | c | ||
189 | p stream->srcwin_cksum_pos | ||
190 | p logical_input_cksum_pos | ||
191 | p stream->total_iun | ||
192 | p stream->total_i | ||
193 | p stream->total_in | ||
194 | p stream->srcwin_cksum_pos | ||
195 | k | ||
196 | run -vv -s testcase/3/source.doc testcase/3/target.doc /tmp/fdsfd | ||
197 | kill | ||
198 | run -vv -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
199 | run -vv -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
200 | y | ||
201 | run | ||
202 | run -vv -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
203 | run | ||
204 | run -vv -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
205 | n | ||
206 | fin | ||
207 | n | ||
208 | p blkoff | ||
209 | p stream->large_look | ||
210 | p onblk | ||
211 | break xdelta3.c:5122 | ||
212 | c | ||
213 | n | ||
214 | p blkno | ||
215 | p stream->srcwin_cksum_pos | ||
216 | up | ||
217 | down | ||
218 | p blkno | ||
219 | p blkno * (1 <<18) | ||
220 | p stream->srcwin_cksum_pos | ||
221 | c | ||
222 | p blkno * (1 <<18) | ||
223 | p blkno | ||
224 | c | ||
225 | n | ||
226 | n | ||
227 | p onblk | ||
228 | n | ||
229 | p onblk | ||
230 | p diff | ||
231 | p stream->srcwin_cksum_pos | ||
232 | n | ||
233 | c | ||
234 | n | ||
235 | p stream->srcwin_cksum_pos | ||
236 | p blkno | ||
237 | c | ||
238 | n | ||
239 | p blkno | ||
240 | c | ||
241 | n | ||
242 | c | ||
243 | n | ||
244 | p stream->srcwin_cksum_pos | ||
245 | p logical_input_cksum_pos | ||
246 | n | ||
247 | run -vv -s testcase/3/source.doc testcase/3/target.doc | ||
248 | run -vv -s testcase/3/source.doc testcase/3/target.doc > /dev/null | ||
249 | up | ||
250 | break xdelta3.c:5123 | ||
251 | c | ||
252 | break xdelta3.c:5097 | ||
253 | c | ||
254 | p stream->srcwin_cksum_pos | ||
255 | p stream->logical_input_pos | ||
256 | p logical_input_cksum_pos | ||
diff --git a/xdelta3/.xdelta3.prcs_aux b/xdelta3/.xdelta3.prcs_aux deleted file mode 100755 index b30689c..0000000 --- a/xdelta3/.xdelta3.prcs_aux +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | ;; This file is automatically generated, editing may cause PRCS to do | ||
2 | ;; REALLY bad things. | ||
3 | (Created-By-Prcs-Version 1 3 3) | ||
4 | (www/xdelta3.css 938 1085949140 b/26_xdelta3.cs 1.3) | ||
5 | (analyze_pfx.py 1422 1022037044 12_analyze_pf 1.1) | ||
6 | (badcopy.c 2622 1047759845 20_badcopy.c 1.1) | ||
7 | (analyze_clen.py 1342 1021753567 14_analyze_cl 1.1) | ||
8 | (save.regtest.bug1/input.4 19022 1055471779 b/16_input.4 1.1) | ||
9 | (save.regtest.bug11/input.0 4 1055554284 b/8_input.0 1.1) | ||
10 | (save.regtest.bug8/input.0 203756 1055518432 28_input.0 1.1) | ||
11 | (save.regtest.bug1/input.5 21597 1055471779 b/17_input.5 1.1) | ||
12 | (save.regtest.bug6/input.20 1235 1055474005 39_input.20 1.1) | ||
13 | (save.regtest.bug11/input.1 10 1055554284 b/7_input.1 1.1) | ||
14 | (xdelta3-list.h 9892 1052598762 6_xdelta3-li 1.1) | ||
15 | (save.regtest.bug8/input.1 203756 1055518493 29_input.1 1.1) | ||
16 | (save.regtest.bug7/recon 51200 1055515262 36_recon 1.1) | ||
17 | (save.regtest.bug6/input.21 952 1055474005 38_input.21 1.1) | ||
18 | (save.regtest.bug6/recon 952 1055480638 37_recon 1.1) | ||
19 | (save.regtest.bug11/recon.x 10 1055554520 b/5_recon.x 1.1) | ||
20 | (vcdiff.ps 131548 1014968851 b/19_vcdiff.ps 1.1) | ||
21 | (www/Xdelta3.html 3200 1058668417 b/24_Xdelta3.ht 1.1) | ||
22 | (priorities.txt 339 1057496665 b/18_priorities 1.1) | ||
23 | (draft-korn-vcdiff.txt 60706 1018424758 b/22_draft-korn 1.1) | ||
24 | (dead.code 72096 1085893991 b/21_dead.code 1.2) | ||
25 | (linkxd3lib.c 1113 1056324075 19_linkxd3lib 1.1) | ||
26 | (www/xdelta3.html 4708 1085952599 b/24_Xdelta3.ht 1.4) | ||
27 | (xdelta3-second.h 8228 1057405215 3_xdelta3-se 1.1) | ||
28 | (testh.c 21 1042671351 17_testh.c 1.1) | ||
29 | (save.regtest.bug6/input.0 920 1055474005 40_input.0 1.1) | ||
30 | (save.regtest.bug12/output.x 705 1055556257 b/1_output.x 1.1) | ||
31 | (save.regtest.bug8/core 1159168 1055529025 23_core 1.1) | ||
32 | (save.regtest.bug9/foo,v 123233 1055532021 21_foo,vx 1.1) | ||
33 | (xdelta3.c 201721 1085893369 16_xdelta3.c 1.3) | ||
34 | (xdelta3-cfgs.h 2701 1057695639 9_xdelta3-cf 1.1) | ||
35 | (save.regtest.bug10/input.0 53274 1055532189 b/14_input.0 1.1) | ||
36 | (xdelta3-regtest.py 17976 1085947234 10_xdelta3-re 1.3) | ||
37 | (save.regtest.bug10/input.1 74663 1055532189 b/13_input.1 1.1) | ||
38 | (save.regtest.bug4/input.0 7571 1055461840 45_input.0 1.1) | ||
39 | (save.regtest.bug12/xd3regtest.27181/output 2336 1055566927 b/0_output 1.1) | ||
40 | (save.regtest.bug4/input.1 11312 1055461840 44_input.1 1.1) | ||
41 | (save.regtest.bug7/core 1146880 1055522004 30_core 1.1) | ||
42 | (xdelta3-main.h 79350 1085950532 5_xdelta3-ma 1.3) | ||
43 | (xdelta3.h 41796 1084138546 1_xdelta3.h 1.2) | ||
44 | (rcs_junk.cc 36315 1055086755 15_rcs_junk.c 1.1) | ||
45 | (www/xdelta3-cmdline.html 5234 1085953288 b/25_xdelta3-cm 1.2) | ||
46 | (save.regtest.bug7/input.0 7571 1055515262 34_input.0 1.1) | ||
47 | (save.regtest.bug7/output 14276 1055515262 35_output 1.1) | ||
48 | (save.regtest.bug2/input.0 2296 1055471815 49_input.0 1.1) | ||
49 | (save.regtest.bug7/input.1 11312 1055515262 33_input.1 1.1) | ||
50 | (www/xdelta3-api-guide.html 7553 1085953324 b/23_Xdelta3-ap 1.4) | ||
51 | (save.regtest.bug8/input.0.xz 70595 1055518500 27_input.0.xz 1.1) | ||
52 | (save.regtest.bug2/input.1 2521 1055471815 48_input.1 1.1) | ||
53 | (save.regtest.bug9/foo2,v 123233 1055532069 22_foo2,vx 1.1) | ||
54 | (xdelta3-python.h 1466 1055671733 4_xdelta3-py 1.1) | ||
55 | (save.regtest.bug10/output 48388 1055532189 b/15_output 1.1) | ||
56 | (save.regtest.bug10/output.x 48408 1055533319 b/12_output.x 1.1) | ||
57 | (save.regtest.bug7/recon.x 11312 1055517553 31_recon.x 1.1) | ||
58 | (save.regtest.bug11/recon 10 1055554284 b/10_recon 1.1) | ||
59 | (save.regtest.bug8/input.1.xz 89734 1055518503 26_input.1.xz 1.1) | ||
60 | (xdelta3-test.h 71959 1084138350 2_xdelta3-te 1.2) | ||
61 | (save.regtest.bug10/recon.x 74655 1055533328 b/11_recon.x 1.1) | ||
62 | (save.regtest.bug12/input.0 280 1055555649 b/3_input.0 1.1) | ||
63 | (save.regtest.bug12/input.1 1155 1055555649 b/2_input.1 1.1) | ||
64 | (draft-vcdiff-huffman.txt 2935 1021721074 b/20_draft-vcdi 1.1) | ||
65 | (save.regtest.bug8/output.x.right 48221 1055520912 24_output.x.r 1.1) | ||
66 | (save.regtest.bug5/input.0 7571 1055471668 43_input.0 1.1) | ||
67 | (save.regtest.bug11/output.x 45 1055554519 b/6_output.x 1.1) | ||
68 | (save.regtest.bug12/xd3regtest.27181/input.0 2521 1055566927 51_input.0 1.1) | ||
69 | (save.regtest.bug5/input.1 11312 1055471668 42_input.1 1.1) | ||
70 | (save.regtest.bug12/xd3regtest.27181/input.1 2296 1055566927 50_input.1 1.1) | ||
71 | (setup.py 626 1055562104 11_setup.py 1.1) | ||
72 | (Makefile 3840 1085893399 0_Makefile 1.3) | ||
73 | (save.regtest.bug3/input.0 732 1055471934 47_input.0 1.1) | ||
74 | (save.regtest.bug6/output 69 1055480559 41_output 1.1) | ||
75 | (xdelta3-fgk.h 21496 1057610026 7_xdelta3-fg 1.1) | ||
76 | (save.regtest.bug3/input.1 271 1055471934 46_input.1 1.1) | ||
77 | (www/Xdelta3-api.html 6128 1058674572 b/23_Xdelta3-ap 1.1) | ||
78 | (save.regtest.bug12/output 39 1055555649 b/4_output 1.1) | ||
79 | (analyze_gp.py 7442 1022750342 13_analyze_gp 1.1) | ||
80 | (save.regtest.bug11/output 45 1055554284 b/9_output 1.1) | ||
81 | (save.regtest.bug7/output.x 14296 1055517870 32_output.x 1.1) | ||
82 | (save.regtest.bug8/output.x 48225 1055530557 25_output.x 1.1) | ||
83 | (show.c 647 1043318861 18_show.c 1.1) | ||
84 | (xdelta3-djw.h 51152 1057610015 8_xdelta3-dj 1.1) | ||
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 29469c3..8fda5de 100755 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -1804,7 +1804,7 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour | |||
1804 | if (option_verbose > 1) { XPR(NT "source window size: %u\n", option_srcwinsz); } | 1804 | if (option_verbose > 1) { XPR(NT "source window size: %u\n", option_srcwinsz); } |
1805 | if (option_verbose > 1) { XPR(NT "source block size: %u\n", source->blksize); } | 1805 | if (option_verbose > 1) { XPR(NT "source block size: %u\n", source->blksize); } |
1806 | 1806 | ||
1807 | lru_size = (option_srcwinsz / source->blksize) + 1; | 1807 | lru_size = (option_srcwinsz / source->blksize); |
1808 | 1808 | ||
1809 | XD3_ASSERT(lru_size <= 128); /* TODO: fix performance here */ | 1809 | XD3_ASSERT(lru_size <= 128); /* TODO: fix performance here */ |
1810 | 1810 | ||
@@ -1862,7 +1862,7 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour | |||
1862 | source->curblkno = 0; | 1862 | source->curblkno = 0; |
1863 | source->onblk = nread; | 1863 | source->onblk = nread; |
1864 | 1864 | ||
1865 | if (option_verbose > 1) | 1865 | if (option_verbose > 2) |
1866 | { | 1866 | { |
1867 | XPR(NT "source block 0 read (not compressed)\n"); | 1867 | XPR(NT "source block 0 read (not compressed)\n"); |
1868 | } | 1868 | } |
@@ -1957,8 +1957,12 @@ main_getblk_func (xd3_stream *stream, | |||
1957 | lru_hits += 1; | 1957 | lru_hits += 1; |
1958 | return 0; | 1958 | return 0; |
1959 | } | 1959 | } |
1960 | XD3_ASSERT (lru[idx].blkno == -1LL || | 1960 | |
1961 | lru[idx].blkno == blkno - lru_size); | 1961 | if (lru[idx].blkno != -1LL && |
1962 | lru[idx].blkno != blkno - lru_size) | ||
1963 | { | ||
1964 | return XD3_TOOFARBACK; | ||
1965 | } | ||
1962 | } | 1966 | } |
1963 | else | 1967 | else |
1964 | { | 1968 | { |
@@ -2015,7 +2019,7 @@ main_getblk_func (xd3_stream *stream, | |||
2015 | 2019 | ||
2016 | main_blklru_list_push_back (& lru_list, blru); | 2020 | main_blklru_list_push_back (& lru_list, blru); |
2017 | 2021 | ||
2018 | if (option_verbose > 1) | 2022 | if (option_verbose > 2) |
2019 | { | 2023 | { |
2020 | if (blru->blkno != -1LL) | 2024 | if (blru->blkno != -1LL) |
2021 | { | 2025 | { |
@@ -2182,14 +2186,12 @@ main_input (xd3_cmd cmd, | |||
2182 | { | 2186 | { |
2183 | config.winsize = min (input_size, (xoff_t) option_winsize); | 2187 | config.winsize = min (input_size, (xoff_t) option_winsize); |
2184 | } | 2188 | } |
2185 | config.winsize = xd3_round_blksize (config.winsize, MIN_BUFSIZE); | ||
2186 | config.winsize = max (config.winsize, MIN_BUFSIZE); | 2189 | config.winsize = max (config.winsize, MIN_BUFSIZE); |
2187 | } | 2190 | } |
2188 | { | 2191 | { |
2189 | /* Source blocksize is not user-settable, only option_srcwinsz is, | 2192 | /* Source blocksize is not user-settable, only option_srcwinsz is, |
2190 | * which determines the number of blocks. */ | 2193 | * which determines the number of blocks. */ |
2191 | source.blksize = XD3_DEFAULT_SRCBLKSZ; | 2194 | source.blksize = XD3_DEFAULT_SRCBLKSZ; |
2192 | option_srcwinsz = xd3_round_blksize(option_srcwinsz, MIN_BUFSIZE); | ||
2193 | option_srcwinsz = max(option_srcwinsz, MIN_BUFSIZE); | 2195 | option_srcwinsz = max(option_srcwinsz, MIN_BUFSIZE); |
2194 | config.srcwin_maxsz = option_srcwinsz; | 2196 | config.srcwin_maxsz = option_srcwinsz; |
2195 | } | 2197 | } |
@@ -2391,34 +2393,34 @@ main_input (xd3_cmd cmd, | |||
2391 | if (option_verbose) | 2393 | if (option_verbose) |
2392 | { | 2394 | { |
2393 | char rrateavg[32], wrateavg[32], tm[32]; | 2395 | char rrateavg[32], wrateavg[32], tm[32]; |
2394 | char rdb[32], wdb[32], sb[32]; | 2396 | char rdb[32], wdb[32]; |
2395 | char trdb[32], twdb[32], tsb[32]; | 2397 | char trdb[32], twdb[32]; |
2396 | char srcbuf[48], tsrcbuf[48]; | ||
2397 | long millis = get_millisecs_since (); | 2398 | long millis = get_millisecs_since (); |
2398 | usize_t this_read = stream.total_in - last_total_in; | 2399 | usize_t this_read = stream.total_in - last_total_in; |
2399 | usize_t this_write = stream.total_out - last_total_out; | 2400 | usize_t this_write = stream.total_out - last_total_out; |
2400 | last_total_in = stream.total_in; | 2401 | last_total_in = stream.total_in; |
2401 | last_total_out = stream.total_out; | 2402 | last_total_out = stream.total_out; |
2402 | 2403 | ||
2403 | tsrcbuf[0] = srcbuf[0] = 0; | 2404 | if (option_verbose > 1) |
2404 | if (used_source) | ||
2405 | { | 2405 | { |
2406 | sprintf (srcbuf, ": src %s", main_format_bcnt (xd3_encoder_srclen (& stream), sb)); | 2406 | XPR(NT "%"Q"u: in %s (%s): out %s (%s): total in %s: out %s: %s\n", |
2407 | sprintf (tsrcbuf, ": src %s", main_format_bcnt (stream.srcwin_cksum_pos, tsb)); | ||
2408 | } | ||
2409 | /*if (stream.current_window >= option_first_window && | ||
2410 | stream.current_window <= option_last_window)*/ | ||
2411 | { | ||
2412 | XPR(NT "%"Q"u: in %s (%s): out %s (%s)%s: total in %s: out %s%s: %s\n", | ||
2413 | stream.current_window, | 2407 | stream.current_window, |
2414 | main_format_bcnt (this_read, rdb), | 2408 | main_format_bcnt (this_read, rdb), |
2415 | main_format_rate (this_read, millis, rrateavg), | 2409 | main_format_rate (this_read, millis, rrateavg), |
2416 | main_format_bcnt (this_write, wdb), | 2410 | main_format_bcnt (this_write, wdb), |
2417 | main_format_rate (this_write, millis, wrateavg), | 2411 | main_format_rate (this_write, millis, wrateavg), |
2418 | srcbuf, | ||
2419 | main_format_bcnt (stream.total_in, trdb), | 2412 | main_format_bcnt (stream.total_in, trdb), |
2420 | main_format_bcnt (stream.total_out, twdb), | 2413 | main_format_bcnt (stream.total_out, twdb), |
2421 | tsrcbuf, | 2414 | main_format_millis (millis, tm)); |
2415 | } | ||
2416 | else | ||
2417 | { | ||
2418 | XPR(NT "%"Q"u: in %s: out %s: total in %s: out %s: %s\n", | ||
2419 | stream.current_window, | ||
2420 | main_format_bcnt (this_read, rdb), | ||
2421 | main_format_bcnt (this_write, wdb), | ||
2422 | main_format_bcnt (stream.total_in, trdb), | ||
2423 | main_format_bcnt (stream.total_out, twdb), | ||
2422 | main_format_millis (millis, tm)); | 2424 | main_format_millis (millis, tm)); |
2423 | } | 2425 | } |
2424 | } | 2426 | } |
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index fb9a09f..a0c7a2a 100755 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -654,6 +654,8 @@ const char* xd3_strerror (int ret) | |||
654 | case XD3_GOTHEADER: return "XD3_GOTHEADER"; | 654 | case XD3_GOTHEADER: return "XD3_GOTHEADER"; |
655 | case XD3_WINSTART: return "XD3_WINSTART"; | 655 | case XD3_WINSTART: return "XD3_WINSTART"; |
656 | case XD3_WINFINISH: return "XD3_WINFINISH"; | 656 | case XD3_WINFINISH: return "XD3_WINFINISH"; |
657 | case XD3_TOOFARBACK: return "XD3_TOOFARBACK"; | ||
658 | case XD3_INTERNAL: return "XD3_INTERNAL"; | ||
657 | } | 659 | } |
658 | return strerror (ret); | 660 | return strerror (ret); |
659 | } | 661 | } |
@@ -692,7 +694,7 @@ static const xd3_sec_type fgk_sec_type = | |||
692 | #define IF_FGK(x) | 694 | #define IF_FGK(x) |
693 | #define FGK_CASE(s) \ | 695 | #define FGK_CASE(s) \ |
694 | s->msg = "unavailable secondary compressor: FGK Adaptive Huffman"; \ | 696 | s->msg = "unavailable secondary compressor: FGK Adaptive Huffman"; \ |
695 | return EINVAL; | 697 | return XD3_INTERNAL; |
696 | #endif | 698 | #endif |
697 | 699 | ||
698 | #if SECONDARY_DJW | 700 | #if SECONDARY_DJW |
@@ -718,7 +720,7 @@ static const xd3_sec_type djw_sec_type = | |||
718 | #define IF_DJW(x) | 720 | #define IF_DJW(x) |
719 | #define DJW_CASE(s) \ | 721 | #define DJW_CASE(s) \ |
720 | s->msg = "unavailable secondary compressor: DJW Static Huffman"; \ | 722 | s->msg = "unavailable secondary compressor: DJW Static Huffman"; \ |
721 | return EINVAL; | 723 | return XD3_INTERNAL; |
722 | #endif | 724 | #endif |
723 | 725 | ||
724 | /******************************************************************************************/ | 726 | /******************************************************************************************/ |
@@ -1337,7 +1339,7 @@ xd3_apply_table_string (xd3_stream *stream, const uint8_t *code_string) | |||
1337 | if (*code_string > XD3_CPY) | 1339 | if (*code_string > XD3_CPY) |
1338 | { | 1340 | { |
1339 | stream->msg = "invalid code-table opcode"; | 1341 | stream->msg = "invalid code-table opcode"; |
1340 | return EINVAL; | 1342 | return XD3_INTERNAL; |
1341 | } | 1343 | } |
1342 | code_table[i].type1 = *code_string++; | 1344 | code_table[i].type1 = *code_string++; |
1343 | break; | 1345 | break; |
@@ -1345,7 +1347,7 @@ xd3_apply_table_string (xd3_stream *stream, const uint8_t *code_string) | |||
1345 | if (*code_string > XD3_CPY) | 1347 | if (*code_string > XD3_CPY) |
1346 | { | 1348 | { |
1347 | stream->msg = "invalid code-table opcode"; | 1349 | stream->msg = "invalid code-table opcode"; |
1348 | return EINVAL; | 1350 | return XD3_INTERNAL; |
1349 | } | 1351 | } |
1350 | code_table[i].type2 = *code_string++; | 1352 | code_table[i].type2 = *code_string++; |
1351 | break; | 1353 | break; |
@@ -1353,7 +1355,7 @@ xd3_apply_table_string (xd3_stream *stream, const uint8_t *code_string) | |||
1353 | if (*code_string != 0 && code_table[i].type1 == XD3_NOOP) | 1355 | if (*code_string != 0 && code_table[i].type1 == XD3_NOOP) |
1354 | { | 1356 | { |
1355 | stream->msg = "invalid code-table size"; | 1357 | stream->msg = "invalid code-table size"; |
1356 | return EINVAL; | 1358 | return XD3_INTERNAL; |
1357 | } | 1359 | } |
1358 | code_table[i].size1 = *code_string++; | 1360 | code_table[i].size1 = *code_string++; |
1359 | break; | 1361 | break; |
@@ -1361,7 +1363,7 @@ xd3_apply_table_string (xd3_stream *stream, const uint8_t *code_string) | |||
1361 | if (*code_string != 0 && code_table[i].type2 == XD3_NOOP) | 1363 | if (*code_string != 0 && code_table[i].type2 == XD3_NOOP) |
1362 | { | 1364 | { |
1363 | stream->msg = "invalid code-table size"; | 1365 | stream->msg = "invalid code-table size"; |
1364 | return EINVAL; | 1366 | return XD3_INTERNAL; |
1365 | } | 1367 | } |
1366 | code_table[i].size2 = *code_string++; | 1368 | code_table[i].size2 = *code_string++; |
1367 | break; | 1369 | break; |
@@ -1369,12 +1371,12 @@ xd3_apply_table_string (xd3_stream *stream, const uint8_t *code_string) | |||
1369 | if (*code_string >= modes) | 1371 | if (*code_string >= modes) |
1370 | { | 1372 | { |
1371 | stream->msg = "invalid code-table mode"; | 1373 | stream->msg = "invalid code-table mode"; |
1372 | return EINVAL; | 1374 | return XD3_INTERNAL; |
1373 | } | 1375 | } |
1374 | if (*code_string != 0 && code_table[i].type1 != XD3_CPY) | 1376 | if (*code_string != 0 && code_table[i].type1 != XD3_CPY) |
1375 | { | 1377 | { |
1376 | stream->msg = "invalid code-table mode"; | 1378 | stream->msg = "invalid code-table mode"; |
1377 | return EINVAL; | 1379 | return XD3_INTERNAL; |
1378 | } | 1380 | } |
1379 | code_table[i].type1 += *code_string++; | 1381 | code_table[i].type1 += *code_string++; |
1380 | break; | 1382 | break; |
@@ -1382,12 +1384,12 @@ xd3_apply_table_string (xd3_stream *stream, const uint8_t *code_string) | |||
1382 | if (*code_string >= modes) | 1384 | if (*code_string >= modes) |
1383 | { | 1385 | { |
1384 | stream->msg = "invalid code-table mode"; | 1386 | stream->msg = "invalid code-table mode"; |
1385 | return EINVAL; | 1387 | return XD3_INTERNAL; |
1386 | } | 1388 | } |
1387 | if (*code_string != 0 && code_table[i].type2 != XD3_CPY) | 1389 | if (*code_string != 0 && code_table[i].type2 != XD3_CPY) |
1388 | { | 1390 | { |
1389 | stream->msg = "invalid code-table mode"; | 1391 | stream->msg = "invalid code-table mode"; |
1390 | return EINVAL; | 1392 | return XD3_INTERNAL; |
1391 | } | 1393 | } |
1392 | code_table[i].type2 += *code_string++; | 1394 | code_table[i].type2 += *code_string++; |
1393 | break; | 1395 | break; |
@@ -1432,7 +1434,7 @@ xd3_apply_table_encoding (xd3_stream *in_stream, const uint8_t *data, usize_t si | |||
1432 | if (code_size != sizeof (code_string)) | 1434 | if (code_size != sizeof (code_string)) |
1433 | { | 1435 | { |
1434 | stream.msg = "corrupt code-table encoding"; | 1436 | stream.msg = "corrupt code-table encoding"; |
1435 | ret = EINVAL; | 1437 | ret = XD3_INTERNAL; |
1436 | goto fail; | 1438 | goto fail; |
1437 | } | 1439 | } |
1438 | 1440 | ||
@@ -1566,7 +1568,7 @@ xd3_check_pow2 (usize_t value, usize_t *logof) | |||
1566 | } | 1568 | } |
1567 | } | 1569 | } |
1568 | 1570 | ||
1569 | return EINVAL; | 1571 | return XD3_INTERNAL; |
1570 | } | 1572 | } |
1571 | 1573 | ||
1572 | static usize_t | 1574 | static usize_t |
@@ -1862,7 +1864,7 @@ xd3_emit_bytes (xd3_stream *stream, | |||
1862 | if (PART & OFLOW) \ | 1864 | if (PART & OFLOW) \ |
1863 | { \ | 1865 | { \ |
1864 | stream->msg = "overflow in decode_integer"; \ | 1866 | stream->msg = "overflow in decode_integer"; \ |
1865 | return EINVAL; \ | 1867 | return XD3_INTERNAL; \ |
1866 | } \ | 1868 | } \ |
1867 | \ | 1869 | \ |
1868 | PART = (PART << 7) | (next & 127); \ | 1870 | PART = (PART << 7) | (next & 127); \ |
@@ -1888,13 +1890,13 @@ xd3_emit_bytes (xd3_stream *stream, | |||
1888 | if (inp == max) \ | 1890 | if (inp == max) \ |
1889 | { \ | 1891 | { \ |
1890 | stream->msg = "end-of-input in read_integer"; \ | 1892 | stream->msg = "end-of-input in read_integer"; \ |
1891 | return EINVAL; \ | 1893 | return XD3_INTERNAL; \ |
1892 | } \ | 1894 | } \ |
1893 | \ | 1895 | \ |
1894 | if (val & OFLOW) \ | 1896 | if (val & OFLOW) \ |
1895 | { \ | 1897 | { \ |
1896 | stream->msg = "overflow in read_intger"; \ | 1898 | stream->msg = "overflow in read_intger"; \ |
1897 | return EINVAL; \ | 1899 | return XD3_INTERNAL; \ |
1898 | } \ | 1900 | } \ |
1899 | \ | 1901 | \ |
1900 | next = (*inp++); \ | 1902 | next = (*inp++); \ |
@@ -2171,7 +2173,7 @@ xd3_decode_address (xd3_stream *stream, usize_t here, uint mode, const uint8_t * | |||
2171 | if (*inpp == max) | 2173 | if (*inpp == max) |
2172 | { | 2174 | { |
2173 | stream->msg = "address underflow"; | 2175 | stream->msg = "address underflow"; |
2174 | return EINVAL; | 2176 | return XD3_INTERNAL; |
2175 | } | 2177 | } |
2176 | 2178 | ||
2177 | mode -= same_start; | 2179 | mode -= same_start; |
@@ -2484,7 +2486,7 @@ xd3_config_stream(xd3_stream *stream, | |||
2484 | (ret = xd3_check_pow2(XD3_ALLOCSIZE, NULL))) | 2486 | (ret = xd3_check_pow2(XD3_ALLOCSIZE, NULL))) |
2485 | { | 2487 | { |
2486 | stream->msg = "incorrect compilation: wrong integer sizes"; | 2488 | stream->msg = "incorrect compilation: wrong integer sizes"; |
2487 | return EINVAL; | 2489 | return XD3_INTERNAL; |
2488 | } | 2490 | } |
2489 | 2491 | ||
2490 | /* Check/set secondary compressor. */ | 2492 | /* Check/set secondary compressor. */ |
@@ -2494,7 +2496,7 @@ xd3_config_stream(xd3_stream *stream, | |||
2494 | if (stream->flags & XD3_SEC_OTHER) | 2496 | if (stream->flags & XD3_SEC_OTHER) |
2495 | { | 2497 | { |
2496 | stream->msg = "XD3_SEC flags require a secondary compressor type"; | 2498 | stream->msg = "XD3_SEC flags require a secondary compressor type"; |
2497 | return EINVAL; | 2499 | return XD3_INTERNAL; |
2498 | } | 2500 | } |
2499 | break; | 2501 | break; |
2500 | case XD3_SEC_FGK: | 2502 | case XD3_SEC_FGK: |
@@ -2503,7 +2505,7 @@ xd3_config_stream(xd3_stream *stream, | |||
2503 | DJW_CASE (stream); | 2505 | DJW_CASE (stream); |
2504 | default: | 2506 | default: |
2505 | stream->msg = "too many secondary compressor types set"; | 2507 | stream->msg = "too many secondary compressor types set"; |
2506 | return EINVAL; | 2508 | return XD3_INTERNAL; |
2507 | } | 2509 | } |
2508 | 2510 | ||
2509 | /* Check/set encoder code table. */ | 2511 | /* Check/set encoder code table. */ |
@@ -2521,7 +2523,7 @@ xd3_config_stream(xd3_stream *stream, | |||
2521 | #endif | 2523 | #endif |
2522 | default: | 2524 | default: |
2523 | stream->msg = "alternate code table support was not compiled"; | 2525 | stream->msg = "alternate code table support was not compiled"; |
2524 | return EINVAL; | 2526 | return XD3_INTERNAL; |
2525 | } | 2527 | } |
2526 | 2528 | ||
2527 | /* Check sprevsz */ | 2529 | /* Check sprevsz */ |
@@ -2534,7 +2536,7 @@ xd3_config_stream(xd3_stream *stream, | |||
2534 | if ((ret = xd3_check_pow2 (stream->sprevsz, NULL))) | 2536 | if ((ret = xd3_check_pow2 (stream->sprevsz, NULL))) |
2535 | { | 2537 | { |
2536 | stream->msg = "sprevsz is required to be a power of two"; | 2538 | stream->msg = "sprevsz is required to be a power of two"; |
2537 | return EINVAL; | 2539 | return XD3_INTERNAL; |
2538 | } | 2540 | } |
2539 | 2541 | ||
2540 | stream->sprevmask = stream->sprevsz - 1; | 2542 | stream->sprevmask = stream->sprevsz - 1; |
@@ -2557,7 +2559,7 @@ xd3_config_stream(xd3_stream *stream, | |||
2557 | config->srcwin_maxsz < stream->srcwin_size) | 2559 | config->srcwin_maxsz < stream->srcwin_size) |
2558 | { | 2560 | { |
2559 | stream->msg = "invalid soft string-match config"; | 2561 | stream->msg = "invalid soft string-match config"; |
2560 | return EINVAL; | 2562 | return XD3_INTERNAL; |
2561 | } | 2563 | } |
2562 | break;) | 2564 | break;) |
2563 | 2565 | ||
@@ -2566,7 +2568,7 @@ xd3_config_stream(xd3_stream *stream, | |||
2566 | IF_BUILD_FAST(case XD3_SMATCH_FAST: smatcher = & __smatcher_fast; break;) | 2568 | IF_BUILD_FAST(case XD3_SMATCH_FAST: smatcher = & __smatcher_fast; break;) |
2567 | default: | 2569 | default: |
2568 | stream->msg = "invalid string match config type"; | 2570 | stream->msg = "invalid string match config type"; |
2569 | return EINVAL; | 2571 | return XD3_INTERNAL; |
2570 | } | 2572 | } |
2571 | 2573 | ||
2572 | stream->string_match = smatcher->string_match; | 2574 | stream->string_match = smatcher->string_match; |
@@ -2600,7 +2602,7 @@ xd3_getblk (xd3_stream *stream/*, xd3_source *source*/, xoff_t blkno) | |||
2600 | if (blkno >= source->blocks) | 2602 | if (blkno >= source->blocks) |
2601 | { | 2603 | { |
2602 | stream->msg = "source file too short"; | 2604 | stream->msg = "source file too short"; |
2603 | return EINVAL; | 2605 | return XD3_INTERNAL; |
2604 | } | 2606 | } |
2605 | 2607 | ||
2606 | if (blkno != source->curblkno || source->curblk == NULL) | 2608 | if (blkno != source->curblkno || source->curblk == NULL) |
@@ -2626,7 +2628,7 @@ xd3_getblk (xd3_stream *stream/*, xd3_source *source*/, xoff_t blkno) | |||
2626 | if (source->onblk != xd3_bytes_on_srcblk (source, blkno)) | 2628 | if (source->onblk != xd3_bytes_on_srcblk (source, blkno)) |
2627 | { | 2629 | { |
2628 | stream->msg = "getblk returned short block"; | 2630 | stream->msg = "getblk returned short block"; |
2629 | return EINVAL; | 2631 | return XD3_INTERNAL; |
2630 | } | 2632 | } |
2631 | 2633 | ||
2632 | return 0; | 2634 | return 0; |
@@ -2673,7 +2675,7 @@ xd3_close_stream (xd3_stream *stream) | |||
2673 | if (stream->enc_state != ENC_INPUT || stream->avail_in != 0) | 2675 | if (stream->enc_state != ENC_INPUT || stream->avail_in != 0) |
2674 | { | 2676 | { |
2675 | stream->msg = "encoding is incomplete"; | 2677 | stream->msg = "encoding is incomplete"; |
2676 | return EINVAL; | 2678 | return XD3_INTERNAL; |
2677 | } | 2679 | } |
2678 | } | 2680 | } |
2679 | else | 2681 | else |
@@ -2690,7 +2692,7 @@ xd3_close_stream (xd3_stream *stream) | |||
2690 | default: | 2692 | default: |
2691 | /* If decoding, should be ready for the next window. */ | 2693 | /* If decoding, should be ready for the next window. */ |
2692 | stream->msg = "EOF in decode"; | 2694 | stream->msg = "EOF in decode"; |
2693 | return EINVAL; | 2695 | return XD3_INTERNAL; |
2694 | } | 2696 | } |
2695 | } | 2697 | } |
2696 | 2698 | ||
@@ -2709,7 +2711,7 @@ xd3_get_appheader (xd3_stream *stream, | |||
2709 | if (stream->dec_state < DEC_WININD) | 2711 | if (stream->dec_state < DEC_WININD) |
2710 | { | 2712 | { |
2711 | stream->msg = "application header not available"; | 2713 | stream->msg = "application header not available"; |
2712 | return EINVAL; | 2714 | return XD3_INTERNAL; |
2713 | } | 2715 | } |
2714 | 2716 | ||
2715 | (*data) = stream->dec_appheader; | 2717 | (*data) = stream->dec_appheader; |
@@ -3640,7 +3642,7 @@ xd3_encode_input (xd3_stream *stream) | |||
3640 | if (stream->dec_state != 0) | 3642 | if (stream->dec_state != 0) |
3641 | { | 3643 | { |
3642 | stream->msg = "encoder/decoder transition"; | 3644 | stream->msg = "encoder/decoder transition"; |
3643 | return EINVAL; | 3645 | return XD3_INTERNAL; |
3644 | } | 3646 | } |
3645 | 3647 | ||
3646 | switch (stream->enc_state) | 3648 | switch (stream->enc_state) |
@@ -3781,7 +3783,7 @@ xd3_encode_input (xd3_stream *stream) | |||
3781 | if (stream->avail_out != 0) | 3783 | if (stream->avail_out != 0) |
3782 | { | 3784 | { |
3783 | stream->msg = "missed call to consume output"; | 3785 | stream->msg = "missed call to consume output"; |
3784 | return EINVAL; | 3786 | return XD3_INTERNAL; |
3785 | } | 3787 | } |
3786 | 3788 | ||
3787 | /* Continue outputting one buffer at a time, until the next is NULL. */ | 3789 | /* Continue outputting one buffer at a time, until the next is NULL. */ |
@@ -3813,7 +3815,7 @@ xd3_encode_input (xd3_stream *stream) | |||
3813 | 3815 | ||
3814 | default: | 3816 | default: |
3815 | stream->msg = "invalid state"; | 3817 | stream->msg = "invalid state"; |
3816 | return EINVAL; | 3818 | return XD3_INTERNAL; |
3817 | } | 3819 | } |
3818 | } | 3820 | } |
3819 | #endif /* XD3_ENCODER */ | 3821 | #endif /* XD3_ENCODER */ |
@@ -3853,7 +3855,7 @@ xd3_process_completely (xd3_stream *stream, | |||
3853 | case XD3_GETSRCBLK: | 3855 | case XD3_GETSRCBLK: |
3854 | { | 3856 | { |
3855 | stream->msg = "stream requires source input"; | 3857 | stream->msg = "stream requires source input"; |
3856 | return EINVAL; | 3858 | return XD3_INTERNAL; |
3857 | } | 3859 | } |
3858 | case 0: /* there is no plain "success" return for xd3_encode/decode */ | 3860 | case 0: /* there is no plain "success" return for xd3_encode/decode */ |
3859 | XD3_ASSERT (ret != 0); | 3861 | XD3_ASSERT (ret != 0); |
@@ -3947,7 +3949,7 @@ xd3_decode_setup_buffers (xd3_stream *stream) | |||
3947 | if (stream->dec_cpyoff < stream->dec_laststart) | 3949 | if (stream->dec_cpyoff < stream->dec_laststart) |
3948 | { | 3950 | { |
3949 | stream->msg = "unsupported VCD_TARGET offset"; | 3951 | stream->msg = "unsupported VCD_TARGET offset"; |
3950 | return EINVAL; | 3952 | return XD3_INTERNAL; |
3951 | } | 3953 | } |
3952 | 3954 | ||
3953 | /* See if the two windows are the same. This indicates the first time VCD_TARGET is | 3955 | /* See if the two windows are the same. This indicates the first time VCD_TARGET is |
@@ -4113,7 +4115,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
4113 | 4115 | ||
4114 | & inst->size))) | 4116 | & inst->size))) |
4115 | { | 4117 | { |
4116 | return EINVAL; | 4118 | return XD3_INTERNAL; |
4117 | } | 4119 | } |
4118 | 4120 | ||
4119 | /* For copy instructions, read address. */ | 4121 | /* For copy instructions, read address. */ |
@@ -4143,7 +4145,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
4143 | if (inst->addr >= stream->dec_position) | 4145 | if (inst->addr >= stream->dec_position) |
4144 | { | 4146 | { |
4145 | stream->msg = "address too large"; | 4147 | stream->msg = "address too large"; |
4146 | return EINVAL; | 4148 | return XD3_INTERNAL; |
4147 | } | 4149 | } |
4148 | 4150 | ||
4149 | /* Check: a VCD_TARGET or VCD_SOURCE copy cannot exceed the remaining buffer space | 4151 | /* Check: a VCD_TARGET or VCD_SOURCE copy cannot exceed the remaining buffer space |
@@ -4151,7 +4153,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
4151 | if (inst->addr < stream->dec_cpylen && inst->addr + inst->size > stream->dec_cpylen) | 4153 | if (inst->addr < stream->dec_cpylen && inst->addr + inst->size > stream->dec_cpylen) |
4152 | { | 4154 | { |
4153 | stream->msg = "size too large"; | 4155 | stream->msg = "size too large"; |
4154 | return EINVAL; | 4156 | return XD3_INTERNAL; |
4155 | } | 4157 | } |
4156 | } | 4158 | } |
4157 | else | 4159 | else |
@@ -4183,7 +4185,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
4183 | if (stream->dec_position + inst->size > stream->dec_maxpos) | 4185 | if (stream->dec_position + inst->size > stream->dec_maxpos) |
4184 | { | 4186 | { |
4185 | stream->msg = "size too large"; | 4187 | stream->msg = "size too large"; |
4186 | return EINVAL; | 4188 | return XD3_INTERNAL; |
4187 | } | 4189 | } |
4188 | 4190 | ||
4189 | stream->dec_position += inst->size; | 4191 | stream->dec_position += inst->size; |
@@ -4200,7 +4202,7 @@ xd3_decode_instruction (xd3_stream *stream) | |||
4200 | if (stream->inst_sect.buf == stream->inst_sect.buf_max) | 4202 | if (stream->inst_sect.buf == stream->inst_sect.buf_max) |
4201 | { | 4203 | { |
4202 | stream->msg = "instruction underflow"; | 4204 | stream->msg = "instruction underflow"; |
4203 | return EINVAL; | 4205 | return XD3_INTERNAL; |
4204 | } | 4206 | } |
4205 | 4207 | ||
4206 | inst = &stream->code_table[*stream->inst_sect.buf++]; | 4208 | inst = &stream->code_table[*stream->inst_sect.buf++]; |
@@ -4241,7 +4243,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
4241 | if (stream->data_sect.buf == stream->data_sect.buf_max) | 4243 | if (stream->data_sect.buf == stream->data_sect.buf_max) |
4242 | { | 4244 | { |
4243 | stream->msg = "data underflow"; | 4245 | stream->msg = "data underflow"; |
4244 | return EINVAL; | 4246 | return XD3_INTERNAL; |
4245 | } | 4247 | } |
4246 | 4248 | ||
4247 | /* TUNE: Probably want to eliminate memset/memcpy here */ | 4249 | /* TUNE: Probably want to eliminate memset/memcpy here */ |
@@ -4260,7 +4262,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
4260 | if (stream->data_sect.buf + take > stream->data_sect.buf_max) | 4262 | if (stream->data_sect.buf + take > stream->data_sect.buf_max) |
4261 | { | 4263 | { |
4262 | stream->msg = "data underflow"; | 4264 | stream->msg = "data underflow"; |
4263 | return EINVAL; | 4265 | return XD3_INTERNAL; |
4264 | } | 4266 | } |
4265 | 4267 | ||
4266 | memcpy (stream->next_out + stream->avail_out, | 4268 | memcpy (stream->next_out + stream->avail_out, |
@@ -4318,6 +4320,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
4318 | if ((ret = xd3_getblk (stream, block))) | 4320 | if ((ret = xd3_getblk (stream, block))) |
4319 | { | 4321 | { |
4320 | /* could be a XD3_GETSRCBLK failure. */ | 4322 | /* could be a XD3_GETSRCBLK failure. */ |
4323 | XD3_ASSERT(ret != XD3_TOOFARBACK); | ||
4321 | return ret; | 4324 | return ret; |
4322 | } | 4325 | } |
4323 | 4326 | ||
@@ -4328,7 +4331,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
4328 | if ((source->onblk != blksize) && (blkoff + take > source->onblk)) | 4331 | if ((source->onblk != blksize) && (blkoff + take > source->onblk)) |
4329 | { | 4332 | { |
4330 | stream->msg = "source file too short"; | 4333 | stream->msg = "source file too short"; |
4331 | return EINVAL; | 4334 | return XD3_INTERNAL; |
4332 | 4335 | ||
4333 | } | 4336 | } |
4334 | 4337 | ||
@@ -4451,7 +4454,7 @@ xd3_decode_sections (xd3_stream *stream) | |||
4451 | { | 4454 | { |
4452 | default: | 4455 | default: |
4453 | stream->msg = "internal error"; | 4456 | stream->msg = "internal error"; |
4454 | return EINVAL; | 4457 | return XD3_INTERNAL; |
4455 | 4458 | ||
4456 | case DEC_DATA: | 4459 | case DEC_DATA: |
4457 | if ((ret = xd3_decode_section (stream, & stream->data_sect, DEC_INST, copy))) { return ret; } | 4460 | if ((ret = xd3_decode_section (stream, & stream->data_sect, DEC_INST, copy))) { return ret; } |
@@ -4527,19 +4530,19 @@ xd3_decode_emit (xd3_stream *stream) | |||
4527 | { | 4530 | { |
4528 | IF_DEBUG1 (P(RINT "AVAIL_OUT(%d) != DEC_TGTLEN(%d)\n", stream->avail_out, stream->dec_tgtlen)); | 4531 | IF_DEBUG1 (P(RINT "AVAIL_OUT(%d) != DEC_TGTLEN(%d)\n", stream->avail_out, stream->dec_tgtlen)); |
4529 | stream->msg = "wrong window length"; | 4532 | stream->msg = "wrong window length"; |
4530 | return EINVAL; | 4533 | return XD3_INTERNAL; |
4531 | } | 4534 | } |
4532 | 4535 | ||
4533 | if (stream->data_sect.buf != stream->data_sect.buf_max) | 4536 | if (stream->data_sect.buf != stream->data_sect.buf_max) |
4534 | { | 4537 | { |
4535 | stream->msg = "extra data section"; | 4538 | stream->msg = "extra data section"; |
4536 | return EINVAL; | 4539 | return XD3_INTERNAL; |
4537 | } | 4540 | } |
4538 | 4541 | ||
4539 | if (stream->addr_sect.buf != stream->addr_sect.buf_max) | 4542 | if (stream->addr_sect.buf != stream->addr_sect.buf_max) |
4540 | { | 4543 | { |
4541 | stream->msg = "extra address section"; | 4544 | stream->msg = "extra address section"; |
4542 | return EINVAL; | 4545 | return XD3_INTERNAL; |
4543 | } | 4546 | } |
4544 | 4547 | ||
4545 | /* OPT: Should cksum computation be combined with the above loop? */ | 4548 | /* OPT: Should cksum computation be combined with the above loop? */ |
@@ -4551,7 +4554,7 @@ xd3_decode_emit (xd3_stream *stream) | |||
4551 | if (a32 != stream->dec_adler32) | 4554 | if (a32 != stream->dec_adler32) |
4552 | { | 4555 | { |
4553 | stream->msg = "target window checksum mismatch"; | 4556 | stream->msg = "target window checksum mismatch"; |
4554 | return EINVAL; | 4557 | return XD3_INTERNAL; |
4555 | } | 4558 | } |
4556 | } | 4559 | } |
4557 | 4560 | ||
@@ -4567,7 +4570,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4567 | if (stream->enc_state != 0) | 4570 | if (stream->enc_state != 0) |
4568 | { | 4571 | { |
4569 | stream->msg = "encoder/decoder transition"; | 4572 | stream->msg = "encoder/decoder transition"; |
4570 | return EINVAL; | 4573 | return XD3_INTERNAL; |
4571 | } | 4574 | } |
4572 | 4575 | ||
4573 | #define BYTE_CASE(expr,x,nstate) \ | 4576 | #define BYTE_CASE(expr,x,nstate) \ |
@@ -4605,13 +4608,13 @@ xd3_decode_input (xd3_stream *stream) | |||
4605 | stream->dec_magic[2] != VCDIFF_MAGIC3) | 4608 | stream->dec_magic[2] != VCDIFF_MAGIC3) |
4606 | { | 4609 | { |
4607 | stream->msg = "not a VCDIFF input"; | 4610 | stream->msg = "not a VCDIFF input"; |
4608 | return EINVAL; | 4611 | return XD3_INTERNAL; |
4609 | } | 4612 | } |
4610 | 4613 | ||
4611 | if (stream->dec_magic[3] != 0) | 4614 | if (stream->dec_magic[3] != 0) |
4612 | { | 4615 | { |
4613 | stream->msg = "VCDIFF input version > 0 is not supported"; | 4616 | stream->msg = "VCDIFF input version > 0 is not supported"; |
4614 | return EINVAL; | 4617 | return XD3_INTERNAL; |
4615 | } | 4618 | } |
4616 | 4619 | ||
4617 | stream->dec_state = DEC_HDRIND; | 4620 | stream->dec_state = DEC_HDRIND; |
@@ -4623,7 +4626,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4623 | if ((stream->dec_hdr_ind & VCD_INVHDR) != 0) | 4626 | if ((stream->dec_hdr_ind & VCD_INVHDR) != 0) |
4624 | { | 4627 | { |
4625 | stream->msg = "unrecognized header indicator bits set"; | 4628 | stream->msg = "unrecognized header indicator bits set"; |
4626 | return EINVAL; | 4629 | return XD3_INTERNAL; |
4627 | } | 4630 | } |
4628 | 4631 | ||
4629 | stream->dec_state = DEC_SECONDID; | 4632 | stream->dec_state = DEC_SECONDID; |
@@ -4643,7 +4646,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4643 | DJW_CASE (stream); | 4646 | DJW_CASE (stream); |
4644 | default: | 4647 | default: |
4645 | stream->msg = "unknown secondary compressor ID"; | 4648 | stream->msg = "unknown secondary compressor ID"; |
4646 | return EINVAL; | 4649 | return XD3_INTERNAL; |
4647 | } | 4650 | } |
4648 | } | 4651 | } |
4649 | 4652 | ||
@@ -4730,7 +4733,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4730 | if (XOFF_T_OVERFLOW (stream->dec_winstart, stream->dec_tgtlen)) | 4733 | if (XOFF_T_OVERFLOW (stream->dec_winstart, stream->dec_tgtlen)) |
4731 | { | 4734 | { |
4732 | stream->msg = "decoder file offset overflow"; | 4735 | stream->msg = "decoder file offset overflow"; |
4733 | return EINVAL; | 4736 | return XD3_INTERNAL; |
4734 | } | 4737 | } |
4735 | 4738 | ||
4736 | stream->dec_winstart += stream->dec_tgtlen; | 4739 | stream->dec_winstart += stream->dec_tgtlen; |
@@ -4738,7 +4741,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4738 | if ((stream->dec_win_ind & VCD_INVWIN) != 0) | 4741 | if ((stream->dec_win_ind & VCD_INVWIN) != 0) |
4739 | { | 4742 | { |
4740 | stream->msg = "unrecognized window indicator bits set"; | 4743 | stream->msg = "unrecognized window indicator bits set"; |
4741 | return EINVAL; | 4744 | return XD3_INTERNAL; |
4742 | } | 4745 | } |
4743 | 4746 | ||
4744 | if ((ret = xd3_decode_init_window (stream))) { return ret; } | 4747 | if ((ret = xd3_decode_init_window (stream))) { return ret; } |
@@ -4765,7 +4768,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4765 | if (XOFF_T_OVERFLOW (stream->dec_cpyoff, stream->dec_cpylen)) | 4768 | if (XOFF_T_OVERFLOW (stream->dec_cpyoff, stream->dec_cpylen)) |
4766 | { | 4769 | { |
4767 | stream->msg = "decoder copy window overflows a file offset"; | 4770 | stream->msg = "decoder copy window overflows a file offset"; |
4768 | return EINVAL; | 4771 | return XD3_INTERNAL; |
4769 | } | 4772 | } |
4770 | 4773 | ||
4771 | /* Check copy window bounds: VCD_TARGET window may not exceed current position. */ | 4774 | /* Check copy window bounds: VCD_TARGET window may not exceed current position. */ |
@@ -4773,7 +4776,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4773 | (stream->dec_cpyoff + (xoff_t) stream->dec_cpylen > stream->dec_winstart)) | 4776 | (stream->dec_cpyoff + (xoff_t) stream->dec_cpylen > stream->dec_winstart)) |
4774 | { | 4777 | { |
4775 | stream->msg = "VCD_TARGET window out of bounds"; | 4778 | stream->msg = "VCD_TARGET window out of bounds"; |
4776 | return EINVAL; | 4779 | return XD3_INTERNAL; |
4777 | } | 4780 | } |
4778 | 4781 | ||
4779 | case DEC_ENCLEN: | 4782 | case DEC_ENCLEN: |
@@ -4789,14 +4792,14 @@ xd3_decode_input (xd3_stream *stream) | |||
4789 | if (USIZE_T_OVERFLOW (stream->dec_cpylen, stream->dec_tgtlen)) | 4792 | if (USIZE_T_OVERFLOW (stream->dec_cpylen, stream->dec_tgtlen)) |
4790 | { | 4793 | { |
4791 | stream->msg = "decoder target window overflows a usize_t"; | 4794 | stream->msg = "decoder target window overflows a usize_t"; |
4792 | return EINVAL; | 4795 | return XD3_INTERNAL; |
4793 | } | 4796 | } |
4794 | 4797 | ||
4795 | /* Check for malicious files. */ | 4798 | /* Check for malicious files. */ |
4796 | if (stream->dec_tgtlen > XD3_HARDMAXWINSIZE) | 4799 | if (stream->dec_tgtlen > XD3_HARDMAXWINSIZE) |
4797 | { | 4800 | { |
4798 | stream->msg = "hard window size exceeded"; | 4801 | stream->msg = "hard window size exceeded"; |
4799 | return EINVAL; | 4802 | return XD3_INTERNAL; |
4800 | } | 4803 | } |
4801 | 4804 | ||
4802 | stream->dec_maxpos = stream->dec_cpylen + stream->dec_tgtlen; | 4805 | stream->dec_maxpos = stream->dec_cpylen + stream->dec_tgtlen; |
@@ -4808,14 +4811,14 @@ xd3_decode_input (xd3_stream *stream) | |||
4808 | if ((stream->dec_del_ind & VCD_INVDEL) != 0) | 4811 | if ((stream->dec_del_ind & VCD_INVDEL) != 0) |
4809 | { | 4812 | { |
4810 | stream->msg = "unrecognized delta indicator bits set"; | 4813 | stream->msg = "unrecognized delta indicator bits set"; |
4811 | return EINVAL; | 4814 | return XD3_INTERNAL; |
4812 | } | 4815 | } |
4813 | 4816 | ||
4814 | /* Delta indicator is only used with secondary compression. */ | 4817 | /* Delta indicator is only used with secondary compression. */ |
4815 | if ((stream->dec_del_ind != 0) && (stream->sec_type == NULL)) | 4818 | if ((stream->dec_del_ind != 0) && (stream->sec_type == NULL)) |
4816 | { | 4819 | { |
4817 | stream->msg = "invalid delta indicator bits set"; | 4820 | stream->msg = "invalid delta indicator bits set"; |
4818 | return EINVAL; | 4821 | return XD3_INTERNAL; |
4819 | } | 4822 | } |
4820 | 4823 | ||
4821 | /* Section lengths */ | 4824 | /* Section lengths */ |
@@ -4856,7 +4859,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4856 | if (stream->dec_enclen != enclen_check) | 4859 | if (stream->dec_enclen != enclen_check) |
4857 | { | 4860 | { |
4858 | stream->msg = "incorrect encoding length (redundent)"; | 4861 | stream->msg = "incorrect encoding length (redundent)"; |
4859 | return EINVAL; | 4862 | return XD3_INTERNAL; |
4860 | } | 4863 | } |
4861 | } | 4864 | } |
4862 | 4865 | ||
@@ -4882,7 +4885,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4882 | if (src == NULL) | 4885 | if (src == NULL) |
4883 | { | 4886 | { |
4884 | stream->msg = "source input required"; | 4887 | stream->msg = "source input required"; |
4885 | return EINVAL; | 4888 | return XD3_INTERNAL; |
4886 | } | 4889 | } |
4887 | 4890 | ||
4888 | src->cpyoff_blocks = stream->dec_cpyoff / src->blksize; | 4891 | src->cpyoff_blocks = stream->dec_cpyoff / src->blksize; |
@@ -4925,7 +4928,7 @@ xd3_decode_input (xd3_stream *stream) | |||
4925 | 4928 | ||
4926 | default: | 4929 | default: |
4927 | stream->msg = "invalid state"; | 4930 | stream->msg = "invalid state"; |
4928 | return EINVAL; | 4931 | return XD3_INTERNAL; |
4929 | } | 4932 | } |
4930 | } | 4933 | } |
4931 | 4934 | ||
@@ -4998,8 +5001,7 @@ xd3_string_match_init (xd3_stream *stream) | |||
4998 | static int | 5001 | static int |
4999 | xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | 5002 | xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) |
5000 | { | 5003 | { |
5001 | // The input offset at which the source should ideally be scanned | 5004 | xoff_t logical_input_cksum_pos; |
5002 | xoff_t logical_input_cksum_pos = stream->total_in + pos_in + stream->srcwin_size; | ||
5003 | 5005 | ||
5004 | if (stream->srcwin_cksum_pos >= stream->src->size) | 5006 | if (stream->srcwin_cksum_pos >= stream->src->size) |
5005 | { | 5007 | { |
@@ -5007,27 +5009,32 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5007 | return 0; | 5009 | return 0; |
5008 | } | 5010 | } |
5009 | 5011 | ||
5012 | /* Begin by advancing at twice the input rate, up to half the maximum window size. */ | ||
5013 | logical_input_cksum_pos = min((stream->total_in + pos_in) * 2, | ||
5014 | (stream->total_in + pos_in) + (stream->srcwin_maxsz / 2)); | ||
5015 | |||
5016 | /* If srcwin_cksum_pos is already greater, wait until the difference is met. */ | ||
5010 | if (stream->srcwin_cksum_pos > logical_input_cksum_pos) | 5017 | if (stream->srcwin_cksum_pos > logical_input_cksum_pos) |
5011 | { | 5018 | { |
5012 | *next_move_point = stream->srcwin_cksum_pos - logical_input_cksum_pos; | 5019 | *next_move_point = pos_in + |
5020 | (usize_t)(stream->srcwin_cksum_pos - logical_input_cksum_pos); | ||
5013 | return 0; | 5021 | return 0; |
5014 | } | 5022 | } |
5015 | 5023 | ||
5016 | IF_DEBUG1 (P(RINT "[move_p1] size=%d T=%"Q"d S=%"Q"d\n", stream->srcwin_size, | 5024 | /* If the stream has matched beyond the srcwin_cksum_pos (good), we shouldn't |
5017 | stream->total_in + pos_in, stream->srcwin_cksum_pos)); | 5025 | * begin reading so far back. */ |
5018 | 5026 | int diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; | |
5019 | *next_move_point = pos_in + stream->srcwin_size; | ||
5020 | 5027 | ||
5021 | if (stream->srcwin_cksum_pos == 0) | 5028 | if (diff > stream->srcwin_size) |
5022 | { | 5029 | { |
5023 | // Two windows to start with | 5030 | stream->srcwin_cksum_pos = stream->total_in + pos_in - stream->srcwin_size; |
5024 | logical_input_cksum_pos += stream->srcwin_size; | 5031 | diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; |
5025 | } | 5032 | } |
5026 | else | 5033 | |
5034 | if (diff < stream->srcwin_size) | ||
5027 | { | 5035 | { |
5028 | // Otherwise double and add | 5036 | /* Advance a minimum of srcwin_size bytes */ |
5029 | stream->srcwin_size = min(stream->srcwin_maxsz, stream->srcwin_size * 2); | 5037 | logical_input_cksum_pos = stream->srcwin_cksum_pos + stream->srcwin_size; |
5030 | logical_input_cksum_pos += stream->srcwin_size; | ||
5031 | } | 5038 | } |
5032 | 5039 | ||
5033 | while (stream->srcwin_cksum_pos < logical_input_cksum_pos && | 5040 | while (stream->srcwin_cksum_pos < logical_input_cksum_pos && |
@@ -5038,6 +5045,9 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5038 | usize_t onblk = xd3_bytes_on_srcblk (stream->src, blkno); | 5045 | usize_t onblk = xd3_bytes_on_srcblk (stream->src, blkno); |
5039 | int ret; | 5046 | int ret; |
5040 | 5047 | ||
5048 | diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; | ||
5049 | onblk = min(onblk, blkoff + diff); | ||
5050 | |||
5041 | if (blkoff + stream->large_look >= onblk) | 5051 | if (blkoff + stream->large_look >= onblk) |
5042 | { | 5052 | { |
5043 | /* Next block */ | 5053 | /* Next block */ |
@@ -5045,16 +5055,20 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5045 | continue; | 5055 | continue; |
5046 | } | 5056 | } |
5047 | 5057 | ||
5058 | IF_DEBUG1 (P(RINT "[move_p1] T=%"Q"u S=%"Q"u\n", | ||
5059 | stream->total_in + pos_in, | ||
5060 | stream->srcwin_cksum_pos)); | ||
5061 | |||
5048 | if ((ret = xd3_getblk (stream, blkno))) | 5062 | if ((ret = xd3_getblk (stream, blkno))) |
5049 | { | 5063 | { |
5064 | if (ret == XD3_TOOFARBACK) | ||
5065 | { | ||
5066 | ret = XD3_INTERNAL; | ||
5067 | } | ||
5050 | return ret; | 5068 | return ret; |
5051 | } | 5069 | } |
5052 | 5070 | ||
5053 | usize_t diff = logical_input_cksum_pos - stream->srcwin_cksum_pos; | 5071 | while (blkoff + stream->large_look < onblk) |
5054 | |||
5055 | onblk = min(onblk, diff + blkoff + stream->large_look); | ||
5056 | |||
5057 | while (blkoff + stream->large_look <= onblk) | ||
5058 | { | 5072 | { |
5059 | uint32_t cksum = xd3_lcksum (stream->src->curblk + blkoff, stream->large_look); | 5073 | uint32_t cksum = xd3_lcksum (stream->src->curblk + blkoff, stream->large_look); |
5060 | usize_t hval = xd3_checksum_hash (& stream->large_hash, cksum); | 5074 | usize_t hval = xd3_checksum_hash (& stream->large_hash, cksum); |
@@ -5065,10 +5079,14 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5065 | stream->srcwin_cksum_pos += stream->large_step; | 5079 | stream->srcwin_cksum_pos += stream->large_step; |
5066 | IF_DEBUG (stream->large_ckcnt += 1); | 5080 | IF_DEBUG (stream->large_ckcnt += 1); |
5067 | } | 5081 | } |
5068 | } | ||
5069 | 5082 | ||
5070 | IF_DEBUG1 (P(RINT "[move_p2] size=%d T=%"Q"d S=%"Q"d next_move=%d\n", stream->srcwin_size, | 5083 | IF_DEBUG1 (P(RINT "[move_p2] T=%"Q"u S=%"Q"u\n", |
5071 | stream->total_in + pos_in, stream->srcwin_cksum_pos, *next_move_point)); | 5084 | stream->total_in + pos_in, |
5085 | stream->srcwin_cksum_pos)); | ||
5086 | |||
5087 | } | ||
5088 | *next_move_point = pos_in + | ||
5089 | (usize_t)(stream->srcwin_cksum_pos - logical_input_cksum_pos); | ||
5072 | 5090 | ||
5073 | return 0; | 5091 | return 0; |
5074 | } | 5092 | } |
@@ -5082,10 +5100,6 @@ xd3_srcwin_setup (xd3_stream *stream) | |||
5082 | xd3_source *src = stream->src; | 5100 | xd3_source *src = stream->src; |
5083 | xoff_t length; | 5101 | xoff_t length; |
5084 | 5102 | ||
5085 | IF_DEBUG1 (P(RINT "[srcwin setup:%"Q"u] iopt buffer %s\n", | ||
5086 | stream->current_window, | ||
5087 | stream->enc_state < ENC_FLUSH ? "overflow" : "fit")); | ||
5088 | |||
5089 | /* Check the undecided state. */ | 5103 | /* Check the undecided state. */ |
5090 | XD3_ASSERT (src->srclen == 0 && src->srcbase == 0); | 5104 | XD3_ASSERT (src->srclen == 0 && src->srcbase == 0); |
5091 | 5105 | ||
@@ -5108,7 +5122,7 @@ xd3_srcwin_setup (xd3_stream *stream) | |||
5108 | if (length > (xoff_t) USIZE_T_MAX) | 5122 | if (length > (xoff_t) USIZE_T_MAX) |
5109 | { | 5123 | { |
5110 | stream->msg = "source window length overflow (not 64bit)"; | 5124 | stream->msg = "source window length overflow (not 64bit)"; |
5111 | return EINVAL; | 5125 | return XD3_INTERNAL; |
5112 | } | 5126 | } |
5113 | 5127 | ||
5114 | /* If ENC_FLUSH, then we know the exact source window to use because no more copies can | 5128 | /* If ENC_FLUSH, then we know the exact source window to use because no more copies can |
@@ -5133,10 +5147,6 @@ xd3_srcwin_setup (xd3_stream *stream) | |||
5133 | 5147 | ||
5134 | XD3_ASSERT (src->srclen); | 5148 | XD3_ASSERT (src->srclen); |
5135 | done: | 5149 | done: |
5136 | IF_DEBUG1 (P(RINT "[srcwin setup:%"Q"u] base %"Q"u size %u\n", | ||
5137 | stream->current_window, | ||
5138 | src->srcbase, | ||
5139 | src->srclen)); | ||
5140 | /* Set the taroff. This convenience variable is used even when stream->src == NULL. */ | 5150 | /* Set the taroff. This convenience variable is used even when stream->src == NULL. */ |
5141 | stream->taroff = src->srclen; | 5151 | stream->taroff = src->srclen; |
5142 | return 0; | 5152 | return 0; |
@@ -5152,28 +5162,12 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos) | |||
5152 | { | 5162 | { |
5153 | xd3_source *src = stream->src; | 5163 | xd3_source *src = stream->src; |
5154 | usize_t greedy_or_not; | 5164 | usize_t greedy_or_not; |
5155 | xoff_t farthest_src; | ||
5156 | 5165 | ||
5157 | stream->match_maxback = 0; | 5166 | stream->match_maxback = 0; |
5158 | stream->match_maxfwd = 0; | 5167 | stream->match_maxfwd = 0; |
5159 | stream->match_back = 0; | 5168 | stream->match_back = 0; |
5160 | stream->match_fwd = 0; | 5169 | stream->match_fwd = 0; |
5161 | 5170 | ||
5162 | farthest_src = max(stream->srcwin_cksum_pos, srcpos); | ||
5163 | |||
5164 | XD3_ASSERT (stream->srcwin_maxsz > src->blksize); | ||
5165 | |||
5166 | /* This prevents the encoder from seeking back more than srcwin_maxsz. Using | ||
5167 | * srcwin_maxsz is incorrect. TODO: Possibly an new option here, how far back to | ||
5168 | * seek? */ | ||
5169 | if (max_in == 0 || | ||
5170 | farthest_src - srcpos > stream->srcwin_maxsz - src->blksize) | ||
5171 | { | ||
5172 | goto bad; // TODO! Note: this prevents catching the TODO/bug below | ||
5173 | } | ||
5174 | |||
5175 | /* TODO: check for boundary crossing */ | ||
5176 | |||
5177 | /* Going backwards, the 1.5-pass algorithm allows some already-matched input may be | 5171 | /* Going backwards, the 1.5-pass algorithm allows some already-matched input may be |
5178 | * covered by a longer source match. The greedy algorithm does not allow this. */ | 5172 | * covered by a longer source match. The greedy algorithm does not allow this. */ |
5179 | if (stream->flags & XD3_BEGREEDY) | 5173 | if (stream->flags & XD3_BEGREEDY) |
@@ -5299,6 +5293,12 @@ xd3_source_extend_match (xd3_stream *stream) | |||
5299 | 5293 | ||
5300 | if ((ret = xd3_getblk (stream, tryblk))) | 5294 | if ((ret = xd3_getblk (stream, tryblk))) |
5301 | { | 5295 | { |
5296 | /* if search went too far back, continue forward. */ | ||
5297 | if (ret == XD3_TOOFARBACK) | ||
5298 | { | ||
5299 | break; | ||
5300 | } | ||
5301 | |||
5302 | /* could be a XD3_GETSRCBLK failure. */ | 5302 | /* could be a XD3_GETSRCBLK failure. */ |
5303 | return ret; | 5303 | return ret; |
5304 | } | 5304 | } |
@@ -5334,6 +5334,13 @@ xd3_source_extend_match (xd3_stream *stream) | |||
5334 | { | 5334 | { |
5335 | if ((ret = xd3_getblk (stream, tryblk))) | 5335 | if ((ret = xd3_getblk (stream, tryblk))) |
5336 | { | 5336 | { |
5337 | /* if search went too far back, continue forward. */ | ||
5338 | if (ret == XD3_TOOFARBACK) | ||
5339 | { | ||
5340 | break; | ||
5341 | } | ||
5342 | |||
5343 | /* could be a XD3_GETSRCBLK failure. */ | ||
5337 | return ret; | 5344 | return ret; |
5338 | } | 5345 | } |
5339 | 5346 | ||
@@ -5753,12 +5760,6 @@ XD3_TEMPLATE(xd3_string_match_) (xd3_stream *stream) | |||
5753 | /* If there is not enough input remaining for any kind of match, skip it. */ | 5760 | /* If there is not enough input remaining for any kind of match, skip it. */ |
5754 | if (pos_in + SLOOK > max_in) { goto loopnomore; } | 5761 | if (pos_in + SLOOK > max_in) { goto loopnomore; } |
5755 | 5762 | ||
5756 | IF_DEBUG1 ({ | ||
5757 | static int x = 0; | ||
5758 | P(RINT "[string match:%d] pos_in %d; \n", | ||
5759 | x++, pos_in); | ||
5760 | }); | ||
5761 | |||
5762 | /* Now reset the incremental loop state: */ | 5763 | /* Now reset the incremental loop state: */ |
5763 | 5764 | ||
5764 | /* The min_match variable is updated to avoid matching the same lazy match over and over | 5765 | /* The min_match variable is updated to avoid matching the same lazy match over and over |
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index a35c9b0..eb11141 100755 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h | |||
@@ -47,7 +47,7 @@ | |||
47 | /* The source window starts with only a few checksums, then doubles up to | 47 | /* The source window starts with only a few checksums, then doubles up to |
48 | * XD3_DEFAULT_MAX_CKSUM_ADVANCE. */ | 48 | * XD3_DEFAULT_MAX_CKSUM_ADVANCE. */ |
49 | #ifndef XD3_DEFAULT_START_CKSUM_ADVANCE | 49 | #ifndef XD3_DEFAULT_START_CKSUM_ADVANCE |
50 | #define XD3_DEFAULT_START_CKSUM_ADVANCE 1024 | 50 | #define XD3_DEFAULT_START_CKSUM_ADVANCE (1U << 14) |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | /* TODO: There is no command-line flag to set this value. */ | 53 | /* TODO: There is no command-line flag to set this value. */ |
@@ -295,6 +295,8 @@ typedef enum { | |||
295 | XD3_WINSTART = -17707, /* notification: returned before a window is processed, giving a | 295 | XD3_WINSTART = -17707, /* notification: returned before a window is processed, giving a |
296 | * chance to XD3_SKIP_WINDOW or not XD3_SKIP_EMIT that window. */ | 296 | * chance to XD3_SKIP_WINDOW or not XD3_SKIP_EMIT that window. */ |
297 | XD3_WINFINISH = -17708, /* notification: returned after encode/decode & output for a window */ | 297 | XD3_WINFINISH = -17708, /* notification: returned after encode/decode & output for a window */ |
298 | XD3_TOOFARBACK = -17709, /* (encoder only) may be returned by getblk() if the block is too old */ | ||
299 | XD3_INTERNAL = -17710, /* internal error */ | ||
298 | 300 | ||
299 | } xd3_rvalues; | 301 | } xd3_rvalues; |
300 | 302 | ||