summaryrefslogtreecommitdiff
path: root/xdelta3
diff options
context:
space:
mode:
authorJosh MacDonald <josh.macdonald@gmail.com>2016-01-05 00:12:13 -0800
committerJosh MacDonald <josh.macdonald@gmail.com>2016-01-05 00:12:13 -0800
commit00895d7c9d6a0cd8b86243c62eecdd7a2bdd981b (patch)
treedbaf88c2d23cd4b23a6832d99614dee3f76add05 /xdelta3
parentf9f0e902b6f3a0f5eead5ac06aaf81eca3d25950 (diff)
-Wformat fixes
Diffstat (limited to 'xdelta3')
-rw-r--r--xdelta3/Makefile.am6
-rw-r--r--xdelta3/testing/regtest.cc6
-rw-r--r--xdelta3/xdelta3-blkcache.h6
-rw-r--r--xdelta3/xdelta3-decode.h17
-rw-r--r--xdelta3/xdelta3-djw.h28
-rw-r--r--xdelta3/xdelta3-internal.h35
-rw-r--r--xdelta3/xdelta3-main.h4
-rw-r--r--xdelta3/xdelta3-second.h6
-rw-r--r--xdelta3/xdelta3.c92
-rw-r--r--xdelta3/xdelta3.h45
10 files changed, 114 insertions, 131 deletions
diff --git a/xdelta3/Makefile.am b/xdelta3/Makefile.am
index 056b200..6e2b8bb 100644
--- a/xdelta3/Makefile.am
+++ b/xdelta3/Makefile.am
@@ -79,7 +79,7 @@ endif
79#common_CFLAGS += -O2 79#common_CFLAGS += -O2
80 80
81# For additional debugging, add -DXD3_DEBUG=1, 2, 3, ... 81# For additional debugging, add -DXD3_DEBUG=1, 2, 3, ...
82xdelta3_CFLAGS = $(C_WFLAGS) $(common_CFLAGS) -DXD3_DEBUG=0 82xdelta3_CFLAGS = $(C_WFLAGS) $(common_CFLAGS) -DXD3_DEBUG=9
83xdelta3_LDADD = -lm 83xdelta3_LDADD = -lm
84 84
85xdelta3decode_CFLAGS = \ 85xdelta3decode_CFLAGS = \
@@ -95,9 +95,9 @@ xdelta3decode_CFLAGS = \
95 -DVCDIFF_TOOLS=0 95 -DVCDIFF_TOOLS=0
96 96
97xdelta3regtest_CXXFLAGS = \ 97xdelta3regtest_CXXFLAGS = \
98 $(CXX_WFLAGS) $(common_CFLAGS) -DNOT_MAIN=1 -DXD3_DEBUG=1 98 $(CXX_WFLAGS) $(common_CFLAGS) -DNOT_MAIN=1 -DXD3_DEBUG=9
99xdelta3regtest_CFLAGS = \ 99xdelta3regtest_CFLAGS = \
100 $(C_WFLAGS) $(common_CFLAGS) -DNOT_MAIN=1 -DXD3_DEBUG=1 100 $(C_WFLAGS) $(common_CFLAGS) -DNOT_MAIN=1 -DXD3_DEBUG=9
101xdelta3regtest_LDADD = -lm 101xdelta3regtest_LDADD = -lm
102 102
103xdelta3checksum_CXXFLAGS = \ 103xdelta3checksum_CXXFLAGS = \
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc
index e5895e0..dd2ab8d 100644
--- a/xdelta3/testing/regtest.cc
+++ b/xdelta3/testing/regtest.cc
@@ -102,11 +102,11 @@ public:
102 102
103 xoff_t blks = target_iterator.Blocks(); 103 xoff_t blks = target_iterator.Blocks();
104 104
105 IF_DEBUG2(XPR(NTR "target in %s: %" Q "u..%" Q "u %" Q "u(%" Q "u) " 105 IF_DEBUG2(XPR(NTR "target in %s: %" Q "u[%" Z "u] %" Q "u(%" Q "u) "
106 "verified %" Q "u\n", 106 "verified %" Q "u\n",
107 encoding ? "encoding" : "decoding", 107 encoding ? "encoding" : "decoding",
108 target_iterator.Offset(), 108 target_iterator.Offset(),
109 target_iterator.Offset() + target_block.Size(), 109 target_block.Size(),
110 target_iterator.Blkno(), 110 target_iterator.Blkno(),
111 blks, 111 blks,
112 verified_bytes)); 112 verified_bytes));
@@ -816,7 +816,7 @@ void TestSmallStride() {
816 InMemoryEncodeDecode(spec0, spec1, &block, options); 816 InMemoryEncodeDecode(spec0, spec1, &block, options);
817 Delta delta(block); 817 Delta delta(block);
818 818
819 IF_DEBUG1(DP(RINT "[stride=%d] changes=%u adds=%" Q "u\n", 819 IF_DEBUG1(DP(RINT "[stride=%d] changes=%" W "u adds=%" Q "u\n",
820 s, changes, delta.AddedBytes())); 820 s, changes, delta.AddedBytes()));
821 double allowance = Constants::BLOCK_SIZE < 8192 || s < 30 ? 3.0 : 1.1; 821 double allowance = Constants::BLOCK_SIZE < 8192 || s < 30 ? 3.0 : 1.1;
822 CHECK_GE(allowance * changes, (double)delta.AddedBytes()); 822 CHECK_GE(allowance * changes, (double)delta.AddedBytes());
diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h
index 20a2a4a..36a5c90 100644
--- a/xdelta3/xdelta3-blkcache.h
+++ b/xdelta3/xdelta3-blkcache.h
@@ -312,12 +312,12 @@ main_getblk_lru (xd3_source *source, xoff_t blkno,
312 main_blklru_list_remove (blru); 312 main_blklru_list_remove (blru);
313 main_blklru_list_push_back (& lru_list, blru); 313 main_blklru_list_push_back (& lru_list, blru);
314 (*blrup) = blru; 314 (*blrup) = blru;
315 IF_DEBUG1 (DP(RINT "[getblk_lru] HIT blkno = %"Z"u lru_size=%d\n", 315 IF_DEBUG1 (DP(RINT "[getblk_lru] HIT blkno = %"Q"u lru_size=%"W"u\n",
316 blkno, lru_size)); 316 blkno, lru_size));
317 return 0; 317 return 0;
318 } 318 }
319 } 319 }
320 IF_DEBUG1 (DP(RINT "[getblk_lru] MISS blkno = %"Z"u lru_size=%d\n", 320 IF_DEBUG1 (DP(RINT "[getblk_lru] MISS blkno = %"Q"u lru_size=%"W"u\n",
321 blkno, lru_size)); 321 blkno, lru_size));
322 } 322 }
323 323
@@ -446,7 +446,7 @@ main_read_seek_source (xd3_stream *stream,
446 sfile->source_position += nread; 446 sfile->source_position += nread;
447 blru->size = nread; 447 blru->size = nread;
448 448
449 IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q" size %u\n", 449 IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q"u size %"W"u\n",
450 skip_blkno, blru->size)); 450 skip_blkno, blru->size));
451 451
452 XD3_ASSERT (sfile->source_position <= pos); 452 XD3_ASSERT (sfile->source_position <= pos);
diff --git a/xdelta3/xdelta3-decode.h b/xdelta3/xdelta3-decode.h
index bce5956..4e33189 100644
--- a/xdelta3/xdelta3-decode.h
+++ b/xdelta3/xdelta3-decode.h
@@ -162,7 +162,7 @@ xd3_decode_allocate (xd3_stream *stream,
162 uint8_t **buf_ptr, 162 uint8_t **buf_ptr,
163 usize_t *buf_alloc) 163 usize_t *buf_alloc)
164{ 164{
165 IF_DEBUG2 (DP(RINT "[xd3_decode_allocate] size %u alloc %u\n", 165 IF_DEBUG2 (DP(RINT "[xd3_decode_allocate] size %"W"u alloc %"W"u\n",
166 size, *buf_alloc)); 166 size, *buf_alloc));
167 167
168 if (*buf_ptr != NULL && *buf_alloc < size) 168 if (*buf_ptr != NULL && *buf_alloc < size)
@@ -207,7 +207,7 @@ 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", 210 IF_DEBUG1 (DP(RINT "[xd3_decode_section] zerocopy %"W"u @ %"W"u avail %"W"u\n",
211 sect_take, section->pos, stream->avail_in)); 211 sect_take, section->pos, stream->avail_in));
212 } 212 }
213 else 213 else
@@ -232,7 +232,7 @@ xd3_decode_section (xd3_stream *stream,
232 section->buf = section->copied1; 232 section->buf = section->copied1;
233 } 233 }
234 234
235 IF_DEBUG2 (DP(RINT "[xd3_decode_section] take %u @ %u [need %u] avail %u\n", 235 IF_DEBUG2 (DP(RINT "[xd3_decode_section] take %"W"u @ %"W"u [need %"W"u] avail %"W"u\n",
236 sect_take, section->pos, sect_need, stream->avail_in)); 236 sect_take, section->pos, sect_need, stream->avail_in));
237 XD3_ASSERT (section->pos + sect_take <= section->alloc1); 237 XD3_ASSERT (section->pos + sect_take <= section->alloc1);
238 238
@@ -250,7 +250,8 @@ xd3_decode_section (xd3_stream *stream,
250 250
251 if (section->pos < section->size) 251 if (section->pos < section->size)
252 { 252 {
253 IF_DEBUG1 (DP(RINT "[xd3_decode_section] further input required %u\n", section->size - section->pos)); 253 IF_DEBUG1 (DP(RINT "[xd3_decode_section] further input required %"W"u\n",
254 section->size - section->pos));
254 stream->msg = "further input required"; 255 stream->msg = "further input required";
255 return XD3_INPUT; 256 return XD3_INPUT;
256 } 257 }
@@ -772,7 +773,7 @@ xd3_decode_emit (xd3_stream *stream)
772 773
773 if (stream->avail_out != stream->dec_tgtlen) 774 if (stream->avail_out != stream->dec_tgtlen)
774 { 775 {
775 IF_DEBUG2 (DP(RINT "AVAIL_OUT(%d) != DEC_TGTLEN(%d)\n", 776 IF_DEBUG2 (DP(RINT "AVAIL_OUT(%"W"u) != DEC_TGTLEN(%"W"u)\n",
776 stream->avail_out, stream->dec_tgtlen)); 777 stream->avail_out, stream->dec_tgtlen));
777 stream->msg = "wrong window length"; 778 stream->msg = "wrong window length";
778 return XD3_INVALID_INPUT; 779 return XD3_INVALID_INPUT;
@@ -1009,7 +1010,7 @@ xd3_decode_input (xd3_stream *stream)
1009 1010
1010 stream->dec_state = DEC_CPYLEN; 1011 stream->dec_state = DEC_CPYLEN;
1011 1012
1012 IF_DEBUG2 (DP(RINT "--------- TARGET WINDOW %"Q" -----------\n", 1013 IF_DEBUG2 (DP(RINT "--------- TARGET WINDOW %"Q"u -----------\n",
1013 stream->current_window)); 1014 stream->current_window));
1014 } 1015 }
1015 1016
@@ -1168,8 +1169,8 @@ xd3_decode_input (xd3_stream *stream)
1168 IF_DEBUG2(DP(RINT 1169 IF_DEBUG2(DP(RINT
1169 "[decode_cpyoff] %"Q"u " 1170 "[decode_cpyoff] %"Q"u "
1170 "cpyblkno %"Q"u " 1171 "cpyblkno %"Q"u "
1171 "cpyblkoff %u " 1172 "cpyblkoff %"W"u "
1172 "blksize %u\n", 1173 "blksize %"W"u\n",
1173 stream->dec_cpyoff, 1174 stream->dec_cpyoff,
1174 src->cpyoff_blocks, 1175 src->cpyoff_blocks,
1175 src->cpyoff_blkoff, 1176 src->cpyoff_blkoff,
diff --git a/xdelta3/xdelta3-djw.h b/xdelta3/xdelta3-djw.h
index 414702a..a4c7e51 100644
--- a/xdelta3/xdelta3-djw.h
+++ b/xdelta3/xdelta3-djw.h
@@ -318,7 +318,7 @@ heap_check (usize_t *heap, djw_heapen *ents, usize_t heap_last)
318 /* Heap property: child not less than parent */ 318 /* Heap property: child not less than parent */
319 XD3_ASSERT (! heap_less (& ents[heap[i]], & ents[heap[i/2]])); 319 XD3_ASSERT (! heap_less (& ents[heap[i]], & ents[heap[i/2]]));
320 320
321 IF_DEBUG2 (DP(RINT "heap[%d] = %u\n", i, ents[heap[i]].freq)); 321 IF_DEBUG2 (DP(RINT "heap[%"W"u] = %u\n", i, ents[heap[i]].freq));
322 } 322 }
323} 323}
324#endif 324#endif
@@ -404,7 +404,7 @@ djw_build_prefix (const djw_weight *freq, uint8_t *clen, usize_t asize, usize_t
404 for (i = 0; i < asize; i += 1) 404 for (i = 0; i < asize; i += 1)
405 { 405 {
406 ents[i+1].freq = freq[i]; 406 ents[i+1].freq = freq[i];
407 IF_DEBUG2 (DP(RINT "ents[%d] = freq[%d] = %d\n", 407 IF_DEBUG2 (DP(RINT "ents[%"W"i] = freq[%"W"u] = %d\n",
408 i+1, i, freq[i])); 408 i+1, i, freq[i]));
409 } 409 }
410 410
@@ -483,7 +483,7 @@ djw_build_prefix (const djw_weight *freq, uint8_t *clen, usize_t asize, usize_t
483 } 483 }
484 484
485 /* clen is 0-origin, unlike ents. */ 485 /* clen is 0-origin, unlike ents. */
486 IF_DEBUG2 (DP(RINT "clen[%d] = %d\n", i-1, b)); 486 IF_DEBUG2 (DP(RINT "clen[%"W"u] = %"W"u\n", i-1, b));
487 clen[i-1] = b; 487 clen[i-1] = b;
488 } 488 }
489 489
@@ -493,7 +493,7 @@ djw_build_prefix (const djw_weight *freq, uint8_t *clen, usize_t asize, usize_t
493 { 493 {
494 IF_DEBUG2 (if (first_bits != total_bits) 494 IF_DEBUG2 (if (first_bits != total_bits)
495 { 495 {
496 DP(RINT "code length overflow changed %"Z" bits\n", 496 DP(RINT "code length overflow changed %"W"u bits\n",
497 total_bits - first_bits); 497 total_bits - first_bits);
498 }); 498 });
499 return total_bits; 499 return total_bits;
@@ -547,7 +547,7 @@ djw_build_codes (usize_t *codes, const uint8_t *clen, usize_t asize, usize_t abs
547 IF_DEBUG2 ({ 547 IF_DEBUG2 ({
548 for (i = 0; i < asize; i += 1) 548 for (i = 0; i < asize; i += 1)
549 { 549 {
550 DP(RINT "code[%d] = %u\n", i, codes[i]); 550 DP(RINT "code[%"W"u] = %"W"u\n", i, codes[i]);
551 } 551 }
552 }); 552 });
553} 553}
@@ -1021,7 +1021,7 @@ xd3_encode_huff (xd3_stream *stream,
1021 * testing group behavior, so don't mess things up. */ 1021 * testing group behavior, so don't mess things up. */
1022 if (goal == 0 && !cfg->inefficient) 1022 if (goal == 0 && !cfg->inefficient)
1023 { 1023 {
1024 IF_DEBUG2 (DP(RINT "too many groups (%u), dropping one\n", 1024 IF_DEBUG2 (DP(RINT "too many groups (%"W"u), dropping one\n",
1025 groups)); 1025 groups));
1026 groups -= 1; 1026 groups -= 1;
1027 goto regroup; 1027 goto regroup;
@@ -1035,8 +1035,8 @@ xd3_encode_huff (xd3_stream *stream,
1035 sum += real_freq[sym2++]; 1035 sum += real_freq[sym2++];
1036 } 1036 }
1037 1037
1038 IF_DEBUG2(DP(RINT "group %u has symbols %u..%u (%u non-zero) " 1038 IF_DEBUG2(DP(RINT "group %"W"u has symbols %"W"u..%"W"u (%"W"u non-zero) "
1039 "(%u/%u = %.3f)\n", 1039 "(%u/%"W"u = %.3f)\n",
1040 gp, sym1, sym2, nz, sum, 1040 gp, sym1, sym2, nz, sum,
1041 input_bytes, sum / (double)input_bytes);); 1041 input_bytes, sum / (double)input_bytes););
1042 1042
@@ -1165,21 +1165,21 @@ xd3_encode_huff (xd3_stream *stream,
1165 if (evolve_zero[i]) { output_bits -= evolve_clen[gp][i]; } 1165 if (evolve_zero[i]) { output_bits -= evolve_clen[gp][i]; }
1166 } 1166 }
1167 1167
1168 IF_DEBUG2 (DP(RINT "evolve_zero reduced %u bits in group %u\n", 1168 IF_DEBUG2 (DP(RINT "evolve_zero reduced %"W"u bits in group %"W"u\n",
1169 save_total - output_bits, gp)); 1169 save_total - output_bits, gp));
1170 } 1170 }
1171 } 1171 }
1172 1172
1173 IF_DEBUG2( 1173 IF_DEBUG2(
1174 DP(RINT "pass %u total bits: %u group uses: ", niter, output_bits); 1174 DP(RINT "pass %"W"u total bits: %"W"u group uses: ", niter, output_bits);
1175 for (gp = 0; gp < groups; gp += 1) { DP(RINT "%u ", gcount[gp]); } 1175 for (gp = 0; gp < groups; gp += 1) { DP(RINT "%"W"u ", gcount[gp]); }
1176 DP(RINT "\n"); 1176 DP(RINT "\n");
1177 ); 1177 );
1178 1178
1179 /* End iteration. */ 1179 /* End iteration. */
1180 1180
1181 IF_DEBUG2 (if (niter > 1 && best_bits < output_bits) { 1181 IF_DEBUG2 (if (niter > 1 && best_bits < output_bits) {
1182 DP(RINT "iteration lost %u bits\n", output_bits - best_bits); }); 1182 DP(RINT "iteration lost %"W"u bits\n", output_bits - best_bits); });
1183 1183
1184 if (niter == 1 || (niter < DJW_MAX_ITER && 1184 if (niter == 1 || (niter < DJW_MAX_ITER &&
1185 (best_bits - output_bits) >= DJW_MIN_IMPROVEMENT)) 1185 (best_bits - output_bits) >= DJW_MIN_IMPROVEMENT))
@@ -1194,7 +1194,7 @@ xd3_encode_huff (xd3_stream *stream,
1194 goto nosecond; 1194 goto nosecond;
1195 } 1195 }
1196 1196
1197 IF_DEBUG2 (DP(RINT "djw compression: %u -> %0.3f\n", 1197 IF_DEBUG2 (DP(RINT "djw compression: %"W"u -> %0.3f\n",
1198 input_bytes, output_bits / 8.0)); 1198 input_bytes, output_bits / 8.0));
1199 1199
1200 /* Encode: prefix */ 1200 /* Encode: prefix */
@@ -1471,7 +1471,7 @@ djw_decode_symbol (xd3_stream *stream,
1471 1471
1472 if (offset <= max_sym) 1472 if (offset <= max_sym)
1473 { 1473 {
1474 IF_DEBUG2 (DP(RINT "(j) %u ", code)); 1474 IF_DEBUG2 (DP(RINT "(j) %"W"u ", code));
1475 *sym = inorder[offset]; 1475 *sym = inorder[offset];
1476 return 0; 1476 return 0;
1477 } 1477 }
diff --git a/xdelta3/xdelta3-internal.h b/xdelta3/xdelta3-internal.h
index e0c561f..ed5ca2a 100644
--- a/xdelta3/xdelta3-internal.h
+++ b/xdelta3/xdelta3-internal.h
@@ -136,41 +136,6 @@ struct _main_file
136 int seek_failed; /* after seek fails once, try FIFO */ 136 int seek_failed; /* after seek fails once, try FIFO */
137}; 137};
138 138
139#ifdef _WIN32
140#define vsnprintf_func _vsnprintf
141#define snprintf_func _snprintf
142#else
143#define vsnprintf_func vsnprintf
144#define snprintf_func snprintf
145#endif
146#define short_sprintf(sb,fmt,...) \
147 snprintf_func((sb).buf,sizeof((sb).buf),fmt,__VA_ARGS__)
148
149/* Type used for short snprintf calls. */
150typedef struct {
151 char buf[48];
152} shortbuf;
153
154/* Prior to SVN 303 this function was only defined in DJGPP and WIN32
155 * environments and other platforms would use the builtin snprintf()
156 * with an arrangement of macros below. In OS X 10.6, Apple made
157 * snprintf() a macro, which defeated those macros (since snprintf
158 * would be evaluated before its argument macros were expanded,
159 * therefore always define xsnprintf_func. */
160#ifndef PRINTF_ATTRIBUTE
161#define PRINTF_ATTRIBUTE(x,y) __attribute__ ((__format__ (__printf__, x, y)))
162#endif
163
164/* Underlying xprintf() */
165int xsnprintf_func (char *str, size_t n, const char *fmt, ...)
166 PRINTF_ATTRIBUTE(3,4);
167
168/* XPR(NT "", ...) (used by main) prefixes an "xdelta3: " to the output. */
169void xprintf(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
170#define XPR xprintf
171#define NT "xdelta3: "
172#define NTR ""
173
174#ifndef UINT32_MAX 139#ifndef UINT32_MAX
175#define UINT32_MAX 4294967295U 140#define UINT32_MAX 4294967295U
176#endif 141#endif
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 69330ca..d1a848a 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -1084,7 +1084,7 @@ main_file_write (main_file *ofile, uint8_t *buf, usize_t size, const char *msg)
1084{ 1084{
1085 int ret = 0; 1085 int ret = 0;
1086 1086
1087 IF_DEBUG1(DP(RINT "[main] write %u\n bytes", size)); 1087 IF_DEBUG1(DP(RINT "[main] write %"W"u\n bytes", size));
1088 1088
1089#if XD3_STDIO 1089#if XD3_STDIO
1090 usize_t result; 1090 usize_t result;
@@ -1155,7 +1155,7 @@ main_write_output (xd3_stream* stream, main_file *ofile)
1155{ 1155{
1156 int ret; 1156 int ret;
1157 1157
1158 IF_DEBUG1(DP(RINT "[main] write(%s) %u\n bytes", ofile->filename, stream->avail_out)); 1158 IF_DEBUG1(DP(RINT "[main] write(%s) %"W"u\n bytes", ofile->filename, stream->avail_out));
1159 1159
1160 if (option_no_output) 1160 if (option_no_output)
1161 { 1161 {
diff --git a/xdelta3/xdelta3-second.h b/xdelta3/xdelta3-second.h
index 899902e..2e3ccd3 100644
--- a/xdelta3/xdelta3-second.h
+++ b/xdelta3/xdelta3-second.h
@@ -68,7 +68,7 @@ static inline int xd3_decode_bits (xd3_stream *stream,
68 68
69 done: 69 done:
70 70
71 IF_DEBUG2 (DP(RINT "(d) %u ", value)); 71 IF_DEBUG2 (DP(RINT "(d) %"W"u ", value));
72 72
73 (*valuep) = value; 73 (*valuep) = value;
74 return 0; 74 return 0;
@@ -238,7 +238,7 @@ static inline int xd3_encode_bits (xd3_stream *stream,
238 } 238 }
239 while (mask != 1); 239 while (mask != 1);
240 240
241 IF_DEBUG2 (DP(RINT "(e) %u ", value)); 241 IF_DEBUG2 (DP(RINT "(e) %"W"u ", value));
242 242
243 return 0; 243 return 0;
244} 244}
@@ -300,7 +300,7 @@ xd3_encode_secondary (xd3_stream *stream,
300 { 300 {
301 if (comp_size < orig_size) 301 if (comp_size < orig_size)
302 { 302 {
303 IF_DEBUG1(DP(RINT "[encode_secondary] saved %u bytes: %u -> %u (%0.2f%%)\n", 303 IF_DEBUG1(DP(RINT "[encode_secondary] saved %"W"u bytes: %"W"u -> %"W"u (%0.2f%%)\n",
304 orig_size - comp_size, orig_size, comp_size, 304 orig_size - comp_size, orig_size, comp_size,
305 100.0 * (double) comp_size / (double) orig_size)); 305 100.0 * (double) comp_size / (double) orig_size));
306 } 306 }
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index b0c9b30..294a05a 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -1424,8 +1424,8 @@ xd3_alloc (xd3_stream *stream,
1424 if (a != NULL) 1424 if (a != NULL)
1425 { 1425 {
1426 IF_DEBUG (stream->alloc_cnt += 1); 1426 IF_DEBUG (stream->alloc_cnt += 1);
1427 IF_DEBUG2 (DP(RINT "[stream %p malloc] size %u ptr %p\n", 1427 IF_DEBUG2 (DP(RINT "[stream %p malloc] size %"W"u ptr %p\n",
1428 stream, elts * size, a)); 1428 (void*)stream, elts * size, a));
1429 } 1429 }
1430 else 1430 else
1431 { 1431 {
@@ -1444,7 +1444,7 @@ xd3_free (xd3_stream *stream,
1444 IF_DEBUG (stream->free_cnt += 1); 1444 IF_DEBUG (stream->free_cnt += 1);
1445 XD3_ASSERT (stream->free_cnt <= stream->alloc_cnt); 1445 XD3_ASSERT (stream->free_cnt <= stream->alloc_cnt);
1446 IF_DEBUG2 (DP(RINT "[stream %p free] %p\n", 1446 IF_DEBUG2 (DP(RINT "[stream %p free] %p\n",
1447 stream, ptr)); 1447 (void*)stream, ptr));
1448 stream->free (stream->opaque, ptr); 1448 stream->free (stream->opaque, ptr);
1449 } 1449 }
1450} 1450}
@@ -1889,7 +1889,7 @@ xd3_getblk (xd3_stream *stream, xoff_t blkno)
1889 } 1889 }
1890 1890
1891 IF_DEBUG2 (DP(RINT "[getblk] read source block %"Q"u onblk " 1891 IF_DEBUG2 (DP(RINT "[getblk] read source block %"Q"u onblk "
1892 "%u blksize %u max_blkno %"Q"u\n", blkno, source->onblk, 1892 "%"W"u blksize %"W"u max_blkno %"Q"u\n", blkno, source->onblk,
1893 source->blksize, source->max_blkno)); 1893 source->blksize, source->max_blkno));
1894 } 1894 }
1895 1895
@@ -1906,7 +1906,7 @@ xd3_getblk (xd3_stream *stream, xoff_t blkno)
1906 } 1906 }
1907 else if (!source->eof_known) 1907 else if (!source->eof_known)
1908 { 1908 {
1909 IF_DEBUG1 (DP(RINT "[getblk] eof block has %d bytes; " 1909 IF_DEBUG1 (DP(RINT "[getblk] eof block has %"W"u bytes; "
1910 "source length known %"Q"u\n", 1910 "source length known %"Q"u\n",
1911 xd3_bytes_on_srcblk (source, blkno), 1911 xd3_bytes_on_srcblk (source, blkno),
1912 xd3_source_eof (source))); 1912 xd3_source_eof (source)));
@@ -1945,7 +1945,7 @@ xd3_set_source (xd3_stream *stream,
1945 { 1945 {
1946 src->blksize = xd3_pow2_roundup(src->blksize); 1946 src->blksize = xd3_pow2_roundup(src->blksize);
1947 xd3_check_pow2 (src->blksize, &shiftby); 1947 xd3_check_pow2 (src->blksize, &shiftby);
1948 IF_DEBUG1 (DP(RINT "raising src_blksz to %u\n", src->blksize)); 1948 IF_DEBUG1 (DP(RINT "raising src_blksz to %"W"u\n", src->blksize));
1949 } 1949 }
1950 1950
1951 src->shiftby = shiftby; 1951 src->shiftby = shiftby;
@@ -1954,7 +1954,7 @@ xd3_set_source (xd3_stream *stream,
1954 if (xd3_check_pow2 (src->max_winsize, NULL) != 0) 1954 if (xd3_check_pow2 (src->max_winsize, NULL) != 0)
1955 { 1955 {
1956 src->max_winsize = xd3_xoff_roundup(src->max_winsize); 1956 src->max_winsize = xd3_xoff_roundup(src->max_winsize);
1957 IF_DEBUG1 (DP(RINT "raising src_maxsize to %u\n", src->blksize)); 1957 IF_DEBUG1 (DP(RINT "raising src_maxsize to %"W"u\n", src->blksize));
1958 } 1958 }
1959 src->max_winsize = xd3_max (src->max_winsize, XD3_ALLOCSIZE); 1959 src->max_winsize = xd3_max (src->max_winsize, XD3_ALLOCSIZE);
1960 return 0; 1960 return 0;
@@ -1968,7 +1968,7 @@ xd3_set_source_and_size (xd3_stream *stream,
1968 if (ret == 0) 1968 if (ret == 0)
1969 { 1969 {
1970 stream->src->eof_known = 1; 1970 stream->src->eof_known = 1;
1971 IF_DEBUG2 (DP(RINT "[set source] size known %"Q"\n", 1971 IF_DEBUG2 (DP(RINT "[set source] size known %"Q"u\n",
1972 source_size)); 1972 source_size));
1973 xd3_blksize_div(source_size, 1973 xd3_blksize_div(source_size,
1974 stream->src, 1974 stream->src,
@@ -2180,7 +2180,7 @@ xd3_iopt_finish_encoding (xd3_stream *stream, xd3_rinst *inst)
2180 2180
2181 IF_DEBUG2 ({ 2181 IF_DEBUG2 ({
2182 static int cnt; 2182 static int cnt;
2183 DP(RINT "[iopt copy:%d] pos %"Q"-%"Q" addr %"Q"-%"Q" size %u\n", 2183 DP(RINT "[iopt copy:%d] pos %"Q"u-%"Q"u addr %"Q"u-%"Q"u size %"W"u\n",
2184 cnt++, 2184 cnt++,
2185 stream->total_in + inst->pos, 2185 stream->total_in + inst->pos,
2186 stream->total_in + inst->pos + inst->size, 2186 stream->total_in + inst->pos + inst->size,
@@ -2197,7 +2197,7 @@ xd3_iopt_finish_encoding (xd3_stream *stream, xd3_rinst *inst)
2197 2197
2198 IF_DEBUG2 ({ 2198 IF_DEBUG2 ({
2199 static int cnt; 2199 static int cnt;
2200 DP(RINT "[iopt run:%d] pos %"Q" size %u\n", cnt++, stream->total_in + inst->pos, inst->size); 2200 DP(RINT "[iopt run:%d] pos %"Q"u size %"W"u\n", cnt++, stream->total_in + inst->pos, inst->size);
2201 }); 2201 });
2202 break; 2202 break;
2203 } 2203 }
@@ -2211,7 +2211,7 @@ xd3_iopt_finish_encoding (xd3_stream *stream, xd3_rinst *inst)
2211 2211
2212 IF_DEBUG2 ({ 2212 IF_DEBUG2 ({
2213 static int cnt; 2213 static int cnt;
2214 DP(RINT "[iopt add:%d] pos %"Q" size %u\n", cnt++, stream->total_in + inst->pos, inst->size); 2214 DP(RINT "[iopt add:%d] pos %"Q"u size %"W"u\n", cnt++, stream->total_in + inst->pos, inst->size);
2215 }); 2215 });
2216 2216
2217 break; 2217 break;
@@ -2593,11 +2593,11 @@ xd3_emit_single (xd3_stream *stream, xd3_rinst *single, uint8_t code)
2593 int has_size = stream->code_table[code].size1 == 0; 2593 int has_size = stream->code_table[code].size1 == 0;
2594 int ret; 2594 int ret;
2595 2595
2596 IF_DEBUG2 (DP(RINT "[emit1] %u %s (%u) code %u\n", 2596 IF_DEBUG2 (DP(RINT "[emit1] %"W"u %s (%"W"u) code %u\n",
2597 single->pos, 2597 single->pos,
2598 xd3_rtype_to_string ((xd3_rtype) single->type, 0), 2598 xd3_rtype_to_string ((xd3_rtype) single->type, 0),
2599 single->size, 2599 single->size,
2600 code)); 2600 code));
2601 2601
2602 if ((ret = xd3_emit_byte (stream, & INST_TAIL (stream), code))) 2602 if ((ret = xd3_emit_byte (stream, & INST_TAIL (stream), code)))
2603 { 2603 {
@@ -2631,13 +2631,13 @@ xd3_emit_double (xd3_stream *stream, xd3_rinst *first,
2631 return ret; 2631 return ret;
2632 } 2632 }
2633 2633
2634 IF_DEBUG2 (DP(RINT "[emit2]: %u %s (%u) %s (%u) code %u\n", 2634 IF_DEBUG2 (DP(RINT "[emit2]: %"W"u %s (%"W"u) %s (%"W"u) code %u\n",
2635 first->pos, 2635 first->pos,
2636 xd3_rtype_to_string ((xd3_rtype) first->type, 0), 2636 xd3_rtype_to_string ((xd3_rtype) first->type, 0),
2637 first->size, 2637 first->size,
2638 xd3_rtype_to_string ((xd3_rtype) second->type, 0), 2638 xd3_rtype_to_string ((xd3_rtype) second->type, 0),
2639 second->size, 2639 second->size,
2640 code)); 2640 code));
2641 2641
2642 return 0; 2642 return 0;
2643} 2643}
@@ -2869,7 +2869,8 @@ xd3_encode_buffer_leftover (xd3_stream *stream)
2869 XD3_ASSERT (stream->buf_avail == 0); 2869 XD3_ASSERT (stream->buf_avail == 0);
2870 XD3_ASSERT (stream->buf_leftavail < stream->winsize); 2870 XD3_ASSERT (stream->buf_leftavail < stream->winsize);
2871 2871
2872 IF_DEBUG2 (DP(RINT "[leftover] previous %u avail %u\n", stream->buf_leftavail, stream->avail_in)); 2872 IF_DEBUG2 (DP(RINT "[leftover] previous %"W"u avail %"W"u\n",
2873 stream->buf_leftavail, stream->avail_in));
2873 2874
2874 memcpy (stream->buf_in, stream->buf_leftover, stream->buf_leftavail); 2875 memcpy (stream->buf_in, stream->buf_leftover, stream->buf_leftavail);
2875 2876
@@ -2894,12 +2895,12 @@ xd3_encode_buffer_leftover (xd3_stream *stream)
2894 else if ((stream->buf_avail < stream->winsize) && !(stream->flags & XD3_FLUSH)) 2895 else if ((stream->buf_avail < stream->winsize) && !(stream->flags & XD3_FLUSH))
2895 { 2896 {
2896 /* Buffer has space */ 2897 /* Buffer has space */
2897 IF_DEBUG2 (DP(RINT "[leftover] emptied %u\n", take)); 2898 IF_DEBUG2 (DP(RINT "[leftover] emptied %"W"u\n", take));
2898 return XD3_INPUT; 2899 return XD3_INPUT;
2899 } 2900 }
2900 2901
2901 /* Use the buffer: */ 2902 /* Use the buffer: */
2902 IF_DEBUG2 (DP(RINT "[leftover] take %u remaining %u\n", take, stream->buf_leftavail)); 2903 IF_DEBUG2 (DP(RINT "[leftover] take %"W"u remaining %"W"u\n", take, stream->buf_leftavail));
2903 stream->next_in = stream->buf_in; 2904 stream->next_in = stream->buf_in;
2904 stream->avail_in = stream->buf_avail; 2905 stream->avail_in = stream->buf_avail;
2905 stream->buf_avail = 0; 2906 stream->buf_avail = 0;
@@ -3124,13 +3125,13 @@ xd3_encode_input (xd3_stream *stream)
3124 3125
3125 stream->enc_state = ENC_SEARCH; 3126 stream->enc_state = ENC_SEARCH;
3126 3127
3127 IF_DEBUG2 (DP(RINT "[WINSTART:%"Q"] input bytes %u offset %"Q"\n", 3128 IF_DEBUG2 (DP(RINT "[WINSTART:%"Q"u] input bytes %"W"u offset %"Q"u\n",
3128 stream->current_window, stream->avail_in, 3129 stream->current_window, stream->avail_in,
3129 stream->total_in)); 3130 stream->total_in));
3130 return XD3_WINSTART; 3131 return XD3_WINSTART;
3131 3132
3132 case ENC_SEARCH: 3133 case ENC_SEARCH:
3133 IF_DEBUG2 (DP(RINT "[SEARCH] match_state %d avail_in %u %s\n", 3134 IF_DEBUG2 (DP(RINT "[SEARCH] match_state %d avail_in %"W"u %s\n",
3134 stream->match_state, stream->avail_in, 3135 stream->match_state, stream->avail_in,
3135 stream->src ? "source" : "no source")); 3136 stream->src ? "source" : "no source"));
3136 3137
@@ -3266,7 +3267,7 @@ xd3_encode_input (xd3_stream *stream)
3266 stream->total_in += stream->avail_in; 3267 stream->total_in += stream->avail_in;
3267 stream->enc_state = ENC_POSTWIN; 3268 stream->enc_state = ENC_POSTWIN;
3268 3269
3269 IF_DEBUG2 (DP(RINT "[WINFINISH:%"Q"] in=%"Q"\n", 3270 IF_DEBUG2 (DP(RINT "[WINFINISH:%"Q"u] in=%"Q"u\n",
3270 stream->current_window, 3271 stream->current_window,
3271 stream->total_in)); 3272 stream->total_in));
3272 return XD3_WINFINISH; 3273 return XD3_WINFINISH;
@@ -3669,7 +3670,7 @@ xd3_srcwin_setup (xd3_stream *stream)
3669 * for the second block. */ 3670 * for the second block. */
3670 src->srclen = xd3_min (src->srclen, xd3_source_eof(src) - src->srcbase); 3671 src->srclen = xd3_min (src->srclen, xd3_source_eof(src) - src->srcbase);
3671 } 3672 }
3672 IF_DEBUG1 (DP(RINT "[srcwin_setup_constrained] base %"Q"u len %u\n", 3673 IF_DEBUG1 (DP(RINT "[srcwin_setup_constrained] base %"Q"u len %"W"u\n",
3673 src->srcbase, src->srclen)); 3674 src->srcbase, src->srclen));
3674 3675
3675 XD3_ASSERT (src->srclen); 3676 XD3_ASSERT (src->srclen);
@@ -3786,8 +3787,8 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos)
3786 } 3787 }
3787 3788
3788 IF_DEBUG2(DP(RINT 3789 IF_DEBUG2(DP(RINT
3789 "[match_setup] srcpos %"Q" (tgtpos %"Q") " 3790 "[match_setup] srcpos %"Q"u (tgtpos %"Q"u) "
3790 "unrestricted maxback %u maxfwd %u\n", 3791 "unrestricted maxback %"W"u maxfwd %"W"u\n",
3791 srcpos, 3792 srcpos,
3792 stream->total_in + stream->input_position, 3793 stream->total_in + stream->input_position,
3793 stream->match_maxback, 3794 stream->match_maxback,
@@ -3823,7 +3824,7 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos)
3823 3824
3824 IF_DEBUG2(DP(RINT 3825 IF_DEBUG2(DP(RINT
3825 "[match_setup] srcpos %"Q"u (tgtpos %"Q"u) " 3826 "[match_setup] srcpos %"Q"u (tgtpos %"Q"u) "
3826 "restricted maxback %u maxfwd %u\n", 3827 "restricted maxback %"W"u maxfwd %"W"u\n",
3827 srcpos, 3828 srcpos,
3828 stream->total_in + stream->input_position, 3829 stream->total_in + stream->input_position,
3829 stream->match_maxback, 3830 stream->match_maxback,
@@ -3902,7 +3903,7 @@ xd3_source_extend_match (xd3_stream *stream)
3902 usize_t tryrem; /* tryrem is the number of matchable bytes */ 3903 usize_t tryrem; /* tryrem is the number of matchable bytes */
3903 usize_t matched; 3904 usize_t matched;
3904 3905
3905 IF_DEBUG2(DP(RINT "[extend match] srcpos %"Q"\n", 3906 IF_DEBUG2(DP(RINT "[extend match] srcpos %"Q"u\n",
3906 stream->match_srcpos)); 3907 stream->match_srcpos));
3907 3908
3908 XD3_ASSERT (src != NULL); 3909 XD3_ASSERT (src != NULL);
@@ -3930,7 +3931,7 @@ xd3_source_extend_match (xd3_stream *stream)
3930 { 3931 {
3931 if (ret == XD3_TOOFARBACK) 3932 if (ret == XD3_TOOFARBACK)
3932 { 3933 {
3933 IF_DEBUG2(DP(RINT "[maxback] %"Q"u TOOFARBACK: %u INP %"Q"u CKSUM %"Q"u\n", 3934 IF_DEBUG2(DP(RINT "[maxback] %"Q"u TOOFARBACK: %"W"u INP %"Q"u CKSUM %"Q"u\n",
3934 tryblk, stream->match_back, 3935 tryblk, stream->match_back,
3935 stream->total_in + stream->input_position, 3936 stream->total_in + stream->input_position,
3936 stream->srcwin_cksum_pos)); 3937 stream->srcwin_cksum_pos));
@@ -3952,7 +3953,7 @@ xd3_source_extend_match (xd3_stream *stream)
3952 3953
3953 tryrem = xd3_min (tryoff, stream->match_maxback - stream->match_back); 3954 tryrem = xd3_min (tryoff, stream->match_maxback - stream->match_back);
3954 3955
3955 IF_DEBUG2(DP(RINT "[maxback] maxback %u trysrc %"Q"/%u tgt %u tryrem %u\n", 3956 IF_DEBUG2(DP(RINT "[maxback] maxback %"W"u trysrc %"Q"u/%"W"u tgt %"W"u tryrem %"W"u\n",
3956 stream->match_maxback, tryblk, tryoff, streamoff, tryrem)); 3957 stream->match_maxback, tryblk, tryoff, streamoff, tryrem));
3957 3958
3958 /* TODO: This code can be optimized similar to xd3_match_forward() */ 3959 /* TODO: This code can be optimized similar to xd3_match_forward() */
@@ -3991,7 +3992,7 @@ xd3_source_extend_match (xd3_stream *stream)
3991 { 3992 {
3992 if (ret == XD3_TOOFARBACK) 3993 if (ret == XD3_TOOFARBACK)
3993 { 3994 {
3994 IF_DEBUG2(DP(RINT "[maxfwd] %"Q"u TOOFARBACK: %u INP %"Q"u CKSUM %"Q"u\n", 3995 IF_DEBUG2(DP(RINT "[maxfwd] %"Q"u TOOFARBACK: %"W"u INP %"Q"u CKSUM %"Q"u\n",
3995 tryblk, stream->match_fwd, 3996 tryblk, stream->match_fwd,
3996 stream->total_in + stream->input_position, 3997 stream->total_in + stream->input_position,
3997 stream->srcwin_cksum_pos)); 3998 stream->srcwin_cksum_pos));
@@ -4030,7 +4031,7 @@ xd3_source_extend_match (xd3_stream *stream)
4030 donefwd: 4031 donefwd:
4031 stream->match_state = MATCH_SEARCHING; 4032 stream->match_state = MATCH_SEARCHING;
4032 4033
4033 IF_DEBUG2(DP(RINT "[extend match] input %"Q"u srcpos %"Q"u len %u\n", 4034 IF_DEBUG2(DP(RINT "[extend match] input %"Q"u srcpos %"Q"u len %"W"u\n",
4034 stream->input_position + stream->total_in, 4035 stream->input_position + stream->total_in,
4035 stream->match_srcpos, 4036 stream->match_srcpos,
4036 stream->match_fwd)); 4037 stream->match_fwd));
@@ -4086,15 +4087,14 @@ xd3_source_extend_match (xd3_stream *stream)
4086 4087
4087 IF_DEBUG2 ({ 4088 IF_DEBUG2 ({
4088 static int x = 0; 4089 static int x = 0;
4089 DP(RINT "[source match:%d] length %u <inp %"Q"u %"Q"u> <src %"Q"u %"Q"u> (%s) [ %u bytes ]\n", 4090 DP(RINT "[source match:%d] length %"W"u <inp %"Q"u %"Q"u> <src %"Q"u %"Q"u> (%s)\n",
4090 x++, 4091 x++,
4091 match_length, 4092 match_length,
4092 stream->total_in + target_position, 4093 stream->total_in + target_position,
4093 stream->total_in + target_position + match_length, 4094 stream->total_in + target_position + match_length,
4094 match_position, 4095 match_position,
4095 match_position + match_length, 4096 match_position + match_length,
4096 (stream->total_in + target_position == match_position) ? "same" : "diff", 4097 (stream->total_in + target_position == match_position) ? "same" : "diff");
4097 match_length);
4098 }); 4098 });
4099 4099
4100 if ((ret = xd3_found_match (stream, 4100 if ((ret = xd3_found_match (stream,
@@ -4192,7 +4192,7 @@ xd3_smatch (xd3_stream *stream,
4192 4192
4193 again: 4193 again:
4194 4194
4195 IF_DEBUG2 (DP(RINT "smatch at base=%u inp=%u cksum=%u\n", base, 4195 IF_DEBUG2 (DP(RINT "smatch at base=%"W"u inp=%"W"u cksum=%"W"u\n", base,
4196 stream->input_position, scksum)); 4196 stream->input_position, scksum));
4197 4197
4198 /* For small matches, we can always go to the end-of-input because 4198 /* For small matches, we can always go to the end-of-input because
@@ -4432,7 +4432,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point)
4432 if (blkpos < (ssize_t) stream->smatcher.large_look) 4432 if (blkpos < (ssize_t) stream->smatcher.large_look)
4433 { 4433 {
4434 stream->srcwin_cksum_pos = (blkno + 1) * stream->src->blksize; 4434 stream->srcwin_cksum_pos = (blkno + 1) * stream->src->blksize;
4435 IF_DEBUG2 (DP(RINT "[srcwin_move_point] continue (end-of-block): %"Q"u\n", blkpos)); 4435 IF_DEBUG2 (DP(RINT "[srcwin_move_point] continue (end-of-block): %"Z"d\n", blkpos));
4436 continue; 4436 continue;
4437 } 4437 }
4438 4438
@@ -4473,7 +4473,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point)
4473 4473
4474 IF_DEBUG1 (DP(RINT 4474 IF_DEBUG1 (DP(RINT
4475 "[srcwin_move_point] exited loop T=%"Q"u " 4475 "[srcwin_move_point] exited loop T=%"Q"u "
4476 "S=%"Q" EOF=%"Q" %s\n", 4476 "S=%"Q"u EOF=%"Q"u %s\n",
4477 stream->total_in + stream->input_position, 4477 stream->total_in + stream->input_position,
4478 stream->srcwin_cksum_pos, 4478 stream->srcwin_cksum_pos,
4479 xd3_source_eof (stream->src), 4479 xd3_source_eof (stream->src),
@@ -4502,7 +4502,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point)
4502 4502
4503 IF_DEBUG2 (DP(RINT 4503 IF_DEBUG2 (DP(RINT
4504 "[srcwin_move_point] finished T=%"Q"u " 4504 "[srcwin_move_point] finished T=%"Q"u "
4505 "S=%"Q"u L=%"Q"u EOF=%"Q"u %s again in %u\n", 4505 "S=%"Q"u L=%"Q"u EOF=%"Q"u %s again in %"W"u\n",
4506 stream->total_in + stream->input_position, 4506 stream->total_in + stream->input_position,
4507 stream->srcwin_cksum_pos, 4507 stream->srcwin_cksum_pos,
4508 target_cksum_pos, 4508 target_cksum_pos,
@@ -4568,7 +4568,7 @@ XD3_TEMPLATE(xd3_string_match_) (xd3_stream *stream)
4568 usize_t match_offset = 0; 4568 usize_t match_offset = 0;
4569 usize_t next_move_point = 0; 4569 usize_t next_move_point = 0;
4570 4570
4571 IF_DEBUG2(DP(RINT "[string_match] initial entry %u\n", stream->input_position)); 4571 IF_DEBUG2(DP(RINT "[string_match] initial entry %"W"u\n", stream->input_position));
4572 4572
4573 /* If there will be no compression due to settings or short input, 4573 /* If there will be no compression due to settings or short input,
4574 * skip it entirely. */ 4574 * skip it entirely. */
@@ -4581,7 +4581,7 @@ XD3_TEMPLATE(xd3_string_match_) (xd3_stream *stream)
4581 * needs to be reset. */ 4581 * needs to be reset. */
4582 restartloop: 4582 restartloop:
4583 4583
4584 IF_DEBUG2(DP(RINT "[string_match] restartloop %u\n", stream->input_position)); 4584 IF_DEBUG2(DP(RINT "[string_match] restartloop %"W"u\n", stream->input_position));
4585 4585
4586 /* If there is not enough input remaining for any kind of match, 4586 /* If there is not enough input remaining for any kind of match,
4587 skip it. */ 4587 skip it. */
@@ -4754,8 +4754,8 @@ XD3_TEMPLATE(xd3_string_match_) (xd3_stream *stream)
4754 { 4754 {
4755 IF_DEBUG2 ({ 4755 IF_DEBUG2 ({
4756 static int x = 0; 4756 static int x = 0;
4757 DP(RINT "[target match:%d] <inp %u %u> <cpy %u %u> " 4757 DP(RINT "[target match:%d] <inp %"W"u %"W"u> <cpy %"W"u %"W"u> "
4758 "(-%d) [ %u bytes ]\n", 4758 "(-%"W"d) [ %"W"u bytes ]\n",
4759 x++, 4759 x++,
4760 stream->input_position, 4760 stream->input_position,
4761 stream->input_position + match_length, 4761 stream->input_position + match_length,
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index e440f70..2046fe5 100644
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -328,12 +328,6 @@ typedef uint32_t usize_t;
328#include <stdio.h> 328#include <stdio.h>
329#endif 329#endif
330 330
331/* XPRINT. Debug output and VCDIFF_TOOLS functions report to stderr.
332 * I have used an irregular style to abbreviate [fprintf(stderr, "] as
333 * [DP(RINT "]. */
334#define DP fprintf
335#define RINT stderr,
336
337typedef struct _xd3_stream xd3_stream; 331typedef struct _xd3_stream xd3_stream;
338typedef struct _xd3_source xd3_source; 332typedef struct _xd3_source xd3_source;
339typedef struct _xd3_hash_cfg xd3_hash_cfg; 333typedef struct _xd3_hash_cfg xd3_hash_cfg;
@@ -372,16 +366,40 @@ typedef int (xd3_getblk_func) (xd3_stream *stream,
372 xd3_source *source, 366 xd3_source *source,
373 xoff_t blkno); 367 xoff_t blkno);
374 368
375/* These are internal functions to delay construction of encoding
376 * tables and support alternate code tables. See the comments & code
377 * enabled by GENERIC_ENCODE_TABLES. */
378
379typedef const xd3_dinst* (xd3_code_table_func) (void); 369typedef const xd3_dinst* (xd3_code_table_func) (void);
380typedef int (xd3_comp_table_func) (xd3_stream *stream,
381 const uint8_t **data,
382 usize_t *size);
383 370
384 371
372#ifdef _WIN32
373#define vsnprintf_func _vsnprintf
374#define snprintf_func _snprintf
375#else
376#define vsnprintf_func vsnprintf
377#define snprintf_func snprintf
378#endif
379#define short_sprintf(sb,fmt,...) \
380 snprintf_func((sb).buf,sizeof((sb).buf),fmt,__VA_ARGS__)
381
382/* Type used for short snprintf calls. */
383typedef struct {
384 char buf[48];
385} shortbuf;
386
387#ifndef PRINTF_ATTRIBUTE
388#define PRINTF_ATTRIBUTE(x,y) __attribute__ ((__format__ (__printf__, x, y)))
389#endif
390
391/* Underlying xprintf() */
392int xsnprintf_func (char *str, size_t n, const char *fmt, ...)
393 PRINTF_ATTRIBUTE(3,4);
394
395/* XPR(NT "", ...) (used by main) prefixes an "xdelta3: " to the output. */
396void xprintf(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
397#define XPR xprintf
398#define NT "xdelta3: "
399#define NTR ""
400/* DP(RINT ...) */
401#define DP xprintf
402#define RINT ""
385 403
386#if XD3_DEBUG 404#if XD3_DEBUG
387#define XD3_ASSERT(x) \ 405#define XD3_ASSERT(x) \
@@ -1048,7 +1066,6 @@ struct _xd3_stream
1048 xd3_desect data_sect; 1066 xd3_desect data_sect;
1049 1067
1050 xd3_code_table_func *code_table_func; 1068 xd3_code_table_func *code_table_func;
1051 xd3_comp_table_func *comp_table_func;
1052 const xd3_dinst *code_table; 1069 const xd3_dinst *code_table;
1053 const xd3_code_table_desc *code_table_desc; 1070 const xd3_code_table_desc *code_table_desc;
1054 xd3_dinst *code_table_alloc; 1071 xd3_dinst *code_table_alloc;