diff options
author | Josh MacDonald <josh.macdonald@gmail.com> | 2015-09-29 23:56:19 -0700 |
---|---|---|
committer | Josh MacDonald <josh.macdonald@gmail.com> | 2015-09-29 23:56:19 -0700 |
commit | f63acfe3692478b983df1473bc1e7a1df3397b7f (patch) | |
tree | 7d6b42074cbb49e697b4536b5f2434f5eb4fd756 /xdelta3/xdelta3-main.h | |
parent | 1e7f716f0854ad67df9a77341a829c84e4e6b1e5 (diff) | |
parent | c6493c5a57e1edc95fa27123e86fe14c3695f284 (diff) |
Merge from HEAD
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r-- | xdelta3/xdelta3-main.h | 115 |
1 files changed, 56 insertions, 59 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 1871f14..8d36ebc 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* xdelta3 - delta compression tools and library | 1 | /* xdelta3 - delta compression tools and library |
2 | * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, | 2 | * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
3 | * 2009, 2010, 2011, 2012, 2013 Joshua P. MacDonald | 3 | * 2009, 2010, 2011, 2012, 2013, 2014, 2015 Joshua P. MacDonald |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
@@ -84,12 +84,6 @@ xsnprintf_func (char *str, size_t n, const char *fmt, ...) | |||
84 | return ret; | 84 | return ret; |
85 | } | 85 | } |
86 | 86 | ||
87 | /* If none are set, default to posix. */ | ||
88 | #if (XD3_POSIX + XD3_STDIO + XD3_WIN32) == 0 | ||
89 | #undef XD3_POSIX | ||
90 | #define XD3_POSIX 1 | ||
91 | #endif | ||
92 | |||
93 | /* Handle externally-compressed inputs. */ | 87 | /* Handle externally-compressed inputs. */ |
94 | #ifndef EXTERNAL_COMPRESSION | 88 | #ifndef EXTERNAL_COMPRESSION |
95 | #define EXTERNAL_COMPRESSION 1 | 89 | #define EXTERNAL_COMPRESSION 1 |
@@ -353,8 +347,8 @@ xprintf (const char *fmt, ...) | |||
353 | static int | 347 | static int |
354 | main_version (void) | 348 | main_version (void) |
355 | { | 349 | { |
356 | /* $Format: " XPR(NTR \"Xdelta version $Xdelta3Version$, Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, Joshua MacDonald\\n\");" $ */ | 350 | /* $Format: " XPR(NTR \"Xdelta version $Xdelta3Version$, Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, Joshua MacDonald\\n\");" $ */ |
357 | XPR(NTR "Xdelta version 3.0.8, Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Joshua MacDonald\n"); | 351 | XPR(NTR "Xdelta version 3.0.10, Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Joshua MacDonald\n"); |
358 | XPR(NTR "Xdelta comes with ABSOLUTELY NO WARRANTY.\n"); | 352 | XPR(NTR "Xdelta comes with ABSOLUTELY NO WARRANTY.\n"); |
359 | XPR(NTR "This is free software, and you are welcome to redistribute it\n"); | 353 | XPR(NTR "This is free software, and you are welcome to redistribute it\n"); |
360 | XPR(NTR "under certain conditions; see \"COPYING\" for details.\n"); | 354 | XPR(NTR "under certain conditions; see \"COPYING\" for details.\n"); |
@@ -389,6 +383,8 @@ main_config (void) | |||
389 | XPR(NTR "XD3_HARDMAXWINSIZE=%d\n", XD3_HARDMAXWINSIZE); | 383 | XPR(NTR "XD3_HARDMAXWINSIZE=%d\n", XD3_HARDMAXWINSIZE); |
390 | XPR(NTR "sizeof(void*)=%d\n", (int)sizeof(void*)); | 384 | XPR(NTR "sizeof(void*)=%d\n", (int)sizeof(void*)); |
391 | XPR(NTR "sizeof(int)=%d\n", (int)sizeof(int)); | 385 | XPR(NTR "sizeof(int)=%d\n", (int)sizeof(int)); |
386 | XPR(NTR "sizeof(long)=%d\n", (int)sizeof(long)); | ||
387 | XPR(NTR "sizeof(long long)=%d\n", (int)sizeof(long long)); | ||
392 | XPR(NTR "sizeof(size_t)=%d\n", (int)sizeof(size_t)); | 388 | XPR(NTR "sizeof(size_t)=%d\n", (int)sizeof(size_t)); |
393 | XPR(NTR "sizeof(uint32_t)=%d\n", (int)sizeof(uint32_t)); | 389 | XPR(NTR "sizeof(uint32_t)=%d\n", (int)sizeof(uint32_t)); |
394 | XPR(NTR "sizeof(uint64_t)=%d\n", (int)sizeof(uint64_t)); | 390 | XPR(NTR "sizeof(uint64_t)=%d\n", (int)sizeof(uint64_t)); |
@@ -608,7 +604,7 @@ main_format_bcnt (xoff_t r, shortbuf *buf) | |||
608 | 604 | ||
609 | if (r >= 100 && r < 1000) | 605 | if (r >= 100 && r < 1000) |
610 | { | 606 | { |
611 | short_sprintf (*buf, "%"Q" %s", r, fmts[i]); | 607 | short_sprintf (*buf, "%"Q"u %s", r, fmts[i]); |
612 | return buf->buf; | 608 | return buf->buf; |
613 | } | 609 | } |
614 | 610 | ||
@@ -671,14 +667,14 @@ main_strtoxoff (const char* s, xoff_t *xo, char which) | |||
671 | XD3_ASSERT(s && *s != 0); | 667 | XD3_ASSERT(s && *s != 0); |
672 | 668 | ||
673 | { | 669 | { |
674 | #if SIZEOF_XOFF_T == SIZEOF_LONG_LONG | 670 | #if SIZEOF_XOFF_T == SIZEOF_UNSIGNED_LONG_LONG |
675 | unsigned long long xx = strtoull (s, &e, 0); | 671 | unsigned long long xx = strtoull (s, &e, 0); |
676 | unsigned long long bad = ULLONG_MAX; | 672 | unsigned long long bad = ULLONG_MAX; |
677 | #elif SIZEOF_XOFF_T <= SIZEOF_LONG | 673 | #elif SIZEOF_XOFF_T <= SIZEOF_UNSIGNED_LONG |
678 | unsigned long xx = strtoul (s, &e, 0); | 674 | unsigned long xx = strtoul (s, &e, 0); |
679 | unsigned long long bad = ULONG_MAX; | 675 | unsigned long long bad = ULONG_MAX; |
680 | #else | 676 | #else |
681 | /* Something wrong with SIZEOF_XOFF_T, SIZEOF_LONG, etc. */ | 677 | /* Something wrong with SIZEOF_XOFF_T, SIZEOF_UNSIGNED_LONG, etc. */ |
682 | #endif | 678 | #endif |
683 | 679 | ||
684 | if (xx == bad) | 680 | if (xx == bad) |
@@ -711,12 +707,12 @@ main_atoux (const char* arg, xoff_t *xo, xoff_t low, | |||
711 | 707 | ||
712 | if (x < low) | 708 | if (x < low) |
713 | { | 709 | { |
714 | XPR(NT "-%c: minimum value: %"Q"\n", which, low); | 710 | XPR(NT "-%c: minimum value: %"Q"u\n", which, low); |
715 | return EXIT_FAILURE; | 711 | return EXIT_FAILURE; |
716 | } | 712 | } |
717 | if (high != 0 && x > high) | 713 | if (high != 0 && x > high) |
718 | { | 714 | { |
719 | XPR(NT "-%c: maximum value: %"Q"\n", which, high); | 715 | XPR(NT "-%c: maximum value: %"Q"u\n", which, high); |
720 | return EXIT_FAILURE; | 716 | return EXIT_FAILURE; |
721 | } | 717 | } |
722 | (*xo) = x; | 718 | (*xo) = x; |
@@ -979,7 +975,7 @@ xd3_posix_io (int fd, uint8_t *buf, size_t size, | |||
979 | 975 | ||
980 | while (nproc < size) | 976 | while (nproc < size) |
981 | { | 977 | { |
982 | size_t tryread = min(size - nproc, 1U << 30); | 978 | size_t tryread = xd3_min(size - nproc, 1U << 30); |
983 | ssize_t result = (*func) (fd, buf + nproc, tryread); | 979 | ssize_t result = (*func) (fd, buf + nproc, tryread); |
984 | 980 | ||
985 | if (result < 0) | 981 | if (result < 0) |
@@ -1072,7 +1068,7 @@ main_file_read (main_file *ifile, | |||
1072 | } | 1068 | } |
1073 | else | 1069 | else |
1074 | { | 1070 | { |
1075 | if (option_verbose > 4) { XPR(NT "read %s: %zu bytes\n", | 1071 | if (option_verbose > 4) { XPR(NT "read %s: %"Z"u bytes\n", |
1076 | ifile->filename, (*nread)); } | 1072 | ifile->filename, (*nread)); } |
1077 | ifile->nread += (*nread); | 1073 | ifile->nread += (*nread); |
1078 | } | 1074 | } |
@@ -1106,7 +1102,7 @@ main_file_write (main_file *ofile, uint8_t *buf, usize_t size, const char *msg) | |||
1106 | } | 1102 | } |
1107 | else | 1103 | else |
1108 | { | 1104 | { |
1109 | if (option_verbose > 5) { XPR(NT "write %s: %"Z" bytes\n", | 1105 | if (option_verbose > 5) { XPR(NT "write %s: %"Z"u bytes\n", |
1110 | ofile->filename, size); } | 1106 | ofile->filename, size); } |
1111 | ofile->nwrite += size; | 1107 | ofile->nwrite += size; |
1112 | } | 1108 | } |
@@ -1247,9 +1243,10 @@ main_set_secondary_flags (xd3_config *config) | |||
1247 | VCDIFF TOOLS | 1243 | VCDIFF TOOLS |
1248 | *****************************************************************/ | 1244 | *****************************************************************/ |
1249 | 1245 | ||
1250 | #if VCDIFF_TOOLS | ||
1251 | #include "xdelta3-merge.h" | 1246 | #include "xdelta3-merge.h" |
1252 | 1247 | ||
1248 | #if VCDIFF_TOOLS | ||
1249 | |||
1253 | /* The following macros let VCDIFF print using main_file_write(), | 1250 | /* The following macros let VCDIFF print using main_file_write(), |
1254 | * for example: | 1251 | * for example: |
1255 | * | 1252 | * |
@@ -1291,7 +1288,7 @@ main_print_window (xd3_stream* stream, main_file *xfile) | |||
1291 | 1288 | ||
1292 | if ((ret = xd3_decode_instruction (stream))) | 1289 | if ((ret = xd3_decode_instruction (stream))) |
1293 | { | 1290 | { |
1294 | XPR(NT "instruction decode error at %"Q": %s\n", | 1291 | XPR(NT "instruction decode error at %"Q"u: %s\n", |
1295 | stream->dec_winstart + size, stream->msg); | 1292 | stream->dec_winstart + size, stream->msg); |
1296 | return ret; | 1293 | return ret; |
1297 | } | 1294 | } |
@@ -1299,7 +1296,7 @@ main_print_window (xd3_stream* stream, main_file *xfile) | |||
1299 | addr_bytes = (usize_t)(stream->addr_sect.buf - addr_before); | 1296 | addr_bytes = (usize_t)(stream->addr_sect.buf - addr_before); |
1300 | inst_bytes = (usize_t)(stream->inst_sect.buf - inst_before); | 1297 | inst_bytes = (usize_t)(stream->inst_sect.buf - inst_before); |
1301 | 1298 | ||
1302 | VC(UT " %06"Q" %03"Z" %s %6"Z, | 1299 | VC(UT " %06"Q"u %03"Z"u %s %6"Z"u", |
1303 | stream->dec_winstart + size, | 1300 | stream->dec_winstart + size, |
1304 | option_print_cpymode ? code : 0, | 1301 | option_print_cpymode ? code : 0, |
1305 | xd3_rtype_to_string ((xd3_rtype) stream->dec_current1.type, | 1302 | xd3_rtype_to_string ((xd3_rtype) stream->dec_current1.type, |
@@ -1312,12 +1309,12 @@ main_print_window (xd3_stream* stream, main_file *xfile) | |||
1312 | { | 1309 | { |
1313 | if (stream->dec_current1.addr >= stream->dec_cpylen) | 1310 | if (stream->dec_current1.addr >= stream->dec_cpylen) |
1314 | { | 1311 | { |
1315 | VC(UT " T@%-6"Z, | 1312 | VC(UT " T@%-6"Z"u", |
1316 | stream->dec_current1.addr - stream->dec_cpylen)VE; | 1313 | stream->dec_current1.addr - stream->dec_cpylen)VE; |
1317 | } | 1314 | } |
1318 | else | 1315 | else |
1319 | { | 1316 | { |
1320 | VC(UT " S@%-6"Q, | 1317 | VC(UT " S@%-6"Q"u", |
1321 | stream->dec_cpyoff + stream->dec_current1.addr)VE; | 1318 | stream->dec_cpyoff + stream->dec_current1.addr)VE; |
1322 | } | 1319 | } |
1323 | } | 1320 | } |
@@ -1331,7 +1328,7 @@ main_print_window (xd3_stream* stream, main_file *xfile) | |||
1331 | 1328 | ||
1332 | if (stream->dec_current2.type != XD3_NOOP) | 1329 | if (stream->dec_current2.type != XD3_NOOP) |
1333 | { | 1330 | { |
1334 | VC(UT " %s %6"Z, | 1331 | VC(UT " %s %6"Z"u", |
1335 | xd3_rtype_to_string ((xd3_rtype) stream->dec_current2.type, | 1332 | xd3_rtype_to_string ((xd3_rtype) stream->dec_current2.type, |
1336 | option_print_cpymode), | 1333 | option_print_cpymode), |
1337 | stream->dec_current2.size)VE; | 1334 | stream->dec_current2.size)VE; |
@@ -1340,12 +1337,12 @@ main_print_window (xd3_stream* stream, main_file *xfile) | |||
1340 | { | 1337 | { |
1341 | if (stream->dec_current2.addr >= stream->dec_cpylen) | 1338 | if (stream->dec_current2.addr >= stream->dec_cpylen) |
1342 | { | 1339 | { |
1343 | VC(UT " T@%-6"Z, | 1340 | VC(UT " T@%-6"Z"u", |
1344 | stream->dec_current2.addr - stream->dec_cpylen)VE; | 1341 | stream->dec_current2.addr - stream->dec_cpylen)VE; |
1345 | } | 1342 | } |
1346 | else | 1343 | else |
1347 | { | 1344 | { |
1348 | VC(UT " S@%-6"Q"", | 1345 | VC(UT " S@%-6"Q"u", |
1349 | stream->dec_cpyoff + stream->dec_current2.addr)VE; | 1346 | stream->dec_cpyoff + stream->dec_current2.addr)VE; |
1350 | } | 1347 | } |
1351 | } | 1348 | } |
@@ -1360,7 +1357,7 @@ main_print_window (xd3_stream* stream, main_file *xfile) | |||
1360 | (stream->dec_current1.type >= XD3_CPY || | 1357 | (stream->dec_current1.type >= XD3_CPY || |
1361 | stream->dec_current2.type >= XD3_CPY)) | 1358 | stream->dec_current2.type >= XD3_CPY)) |
1362 | { | 1359 | { |
1363 | VC(UT " %06"Q" (inefficiency) %"Z" encoded as %"Z" bytes\n", | 1360 | VC(UT " %06"Q"u (inefficiency) %"Z"u encoded as %"Z"u bytes\n", |
1364 | stream->dec_winstart + size_before, | 1361 | stream->dec_winstart + size_before, |
1365 | size - size_before, | 1362 | size - size_before, |
1366 | addr_bytes + inst_bytes)VE; | 1363 | addr_bytes + inst_bytes)VE; |
@@ -1428,7 +1425,7 @@ main_print_func (xd3_stream* stream, main_file *xfile) | |||
1428 | if (stream->dec_winstart == 0) | 1425 | if (stream->dec_winstart == 0) |
1429 | { | 1426 | { |
1430 | VC(UT "VCDIFF version: 0\n")VE; | 1427 | VC(UT "VCDIFF version: 0\n")VE; |
1431 | VC(UT "VCDIFF header size: %"Z"\n", | 1428 | VC(UT "VCDIFF header size: %"Z"u\n", |
1432 | stream->dec_hdrsize)VE; | 1429 | stream->dec_hdrsize)VE; |
1433 | VC(UT "VCDIFF header indicator: ")VE; | 1430 | VC(UT "VCDIFF header indicator: ")VE; |
1434 | if ((stream->dec_hdr_ind & VCD_SECONDARY) != 0) | 1431 | if ((stream->dec_hdr_ind & VCD_SECONDARY) != 0) |
@@ -1483,7 +1480,7 @@ main_print_func (xd3_stream* stream, main_file *xfile) | |||
1483 | VC(UT "\n")VE; | 1480 | VC(UT "\n")VE; |
1484 | } | 1481 | } |
1485 | 1482 | ||
1486 | VC(UT "VCDIFF window number: %"Q"\n", stream->current_window)VE; | 1483 | VC(UT "VCDIFF window number: %"Q"u\n", stream->current_window)VE; |
1487 | VC(UT "VCDIFF window indicator: ")VE; | 1484 | VC(UT "VCDIFF window indicator: ")VE; |
1488 | if ((stream->dec_win_ind & VCD_SOURCE) != 0) VC(UT "VCD_SOURCE ")VE; | 1485 | if ((stream->dec_win_ind & VCD_SOURCE) != 0) VC(UT "VCD_SOURCE ")VE; |
1489 | if ((stream->dec_win_ind & VCD_TARGET) != 0) VC(UT "VCD_TARGET ")VE; | 1486 | if ((stream->dec_win_ind & VCD_TARGET) != 0) VC(UT "VCD_TARGET ")VE; |
@@ -1509,27 +1506,27 @@ main_print_func (xd3_stream* stream, main_file *xfile) | |||
1509 | 1506 | ||
1510 | if (stream->dec_winstart != 0) | 1507 | if (stream->dec_winstart != 0) |
1511 | { | 1508 | { |
1512 | VC(UT "VCDIFF window at offset: %"Q"\n", stream->dec_winstart)VE; | 1509 | VC(UT "VCDIFF window at offset: %"Q"u\n", stream->dec_winstart)VE; |
1513 | } | 1510 | } |
1514 | 1511 | ||
1515 | if (SRCORTGT (stream->dec_win_ind)) | 1512 | if (SRCORTGT (stream->dec_win_ind)) |
1516 | { | 1513 | { |
1517 | VC(UT "VCDIFF copy window length: %"Z"\n", | 1514 | VC(UT "VCDIFF copy window length: %"Z"u\n", |
1518 | stream->dec_cpylen)VE; | 1515 | stream->dec_cpylen)VE; |
1519 | VC(UT "VCDIFF copy window offset: %"Q"\n", | 1516 | VC(UT "VCDIFF copy window offset: %"Q"u\n", |
1520 | stream->dec_cpyoff)VE; | 1517 | stream->dec_cpyoff)VE; |
1521 | } | 1518 | } |
1522 | 1519 | ||
1523 | VC(UT "VCDIFF delta encoding length: %"Z"\n", | 1520 | VC(UT "VCDIFF delta encoding length: %"Z"u\n", |
1524 | (usize_t)stream->dec_enclen)VE; | 1521 | (usize_t)stream->dec_enclen)VE; |
1525 | VC(UT "VCDIFF target window length: %"Z"\n", | 1522 | VC(UT "VCDIFF target window length: %"Z"u\n", |
1526 | (usize_t)stream->dec_tgtlen)VE; | 1523 | (usize_t)stream->dec_tgtlen)VE; |
1527 | 1524 | ||
1528 | VC(UT "VCDIFF data section length: %"Z"\n", | 1525 | VC(UT "VCDIFF data section length: %"Z"u\n", |
1529 | (usize_t)stream->data_sect.size)VE; | 1526 | (usize_t)stream->data_sect.size)VE; |
1530 | VC(UT "VCDIFF inst section length: %"Z"\n", | 1527 | VC(UT "VCDIFF inst section length: %"Z"u\n", |
1531 | (usize_t)stream->inst_sect.size)VE; | 1528 | (usize_t)stream->inst_sect.size)VE; |
1532 | VC(UT "VCDIFF addr section length: %"Z"\n", | 1529 | VC(UT "VCDIFF addr section length: %"Z"u\n", |
1533 | (usize_t)stream->addr_sect.size)VE; | 1530 | (usize_t)stream->addr_sect.size)VE; |
1534 | 1531 | ||
1535 | ret = 0; | 1532 | ret = 0; |
@@ -1932,7 +1929,7 @@ main_merge_output (xd3_stream *stream, main_file *ofile) | |||
1932 | inst_pos < stream->whole_target.instlen) | 1929 | inst_pos < stream->whole_target.instlen) |
1933 | { | 1930 | { |
1934 | xd3_winst *inst = &stream->whole_target.inst[inst_pos]; | 1931 | xd3_winst *inst = &stream->whole_target.inst[inst_pos]; |
1935 | usize_t take = min(inst->size, window_size - window_pos); | 1932 | usize_t take = xd3_min(inst->size, window_size - window_pos); |
1936 | xoff_t addr; | 1933 | xoff_t addr; |
1937 | 1934 | ||
1938 | switch (inst->type) | 1935 | switch (inst->type) |
@@ -1955,8 +1952,8 @@ main_merge_output (xd3_stream *stream, main_file *ofile) | |||
1955 | if (inst->mode != 0) | 1952 | if (inst->mode != 0) |
1956 | { | 1953 | { |
1957 | if (window_srcset) { | 1954 | if (window_srcset) { |
1958 | window_srcmin = min(window_srcmin, inst->addr); | 1955 | window_srcmin = xd3_min (window_srcmin, inst->addr); |
1959 | window_srcmax = max(window_srcmax, inst->addr + take); | 1956 | window_srcmax = xd3_max (window_srcmax, inst->addr + take); |
1960 | } else { | 1957 | } else { |
1961 | window_srcset = 1; | 1958 | window_srcset = 1; |
1962 | window_srcmin = inst->addr; | 1959 | window_srcmin = inst->addr; |
@@ -2248,7 +2245,7 @@ main_pipe_copier (uint8_t *pipe_buf, | |||
2248 | 2245 | ||
2249 | if (option_verbose && skipped != 0) | 2246 | if (option_verbose && skipped != 0) |
2250 | { | 2247 | { |
2251 | XPR(NT "skipping %"Q" bytes in %s\n", | 2248 | XPR(NT "skipping %"Q"u bytes in %s\n", |
2252 | skipped, ifile->filename); | 2249 | skipped, ifile->filename); |
2253 | } | 2250 | } |
2254 | return 0; | 2251 | return 0; |
@@ -2419,7 +2416,7 @@ main_secondary_decompress_check (main_file *file, | |||
2419 | { | 2416 | { |
2420 | int ret; | 2417 | int ret; |
2421 | usize_t i; | 2418 | usize_t i; |
2422 | usize_t try_read = min (input_size, XD3_ALLOCSIZE); | 2419 | usize_t try_read = xd3_min (input_size, XD3_ALLOCSIZE); |
2423 | size_t check_nread = 0; | 2420 | size_t check_nread = 0; |
2424 | uint8_t check_buf[XD3_ALLOCSIZE]; /* TODO: stack limit */ | 2421 | uint8_t check_buf[XD3_ALLOCSIZE]; /* TODO: stack limit */ |
2425 | const main_extcomp *decompressor = NULL; | 2422 | const main_extcomp *decompressor = NULL; |
@@ -2811,11 +2808,11 @@ main_get_appheader (xd3_stream *stream, main_file *ifile, | |||
2811 | 2808 | ||
2812 | if (appheadsz > 0) | 2809 | if (appheadsz > 0) |
2813 | { | 2810 | { |
2814 | const int kMaxArgs = 4; | ||
2815 | char *start = (char*)apphead; | 2811 | char *start = (char*)apphead; |
2816 | char *slash; | 2812 | char *slash; |
2817 | int place = 0; | 2813 | int place = 0; |
2818 | char *parsed[kMaxArgs]; | 2814 | const int kMaxArgs = 4; |
2815 | char *parsed[4]; | ||
2819 | 2816 | ||
2820 | memset (parsed, 0, sizeof (parsed)); | 2817 | memset (parsed, 0, sizeof (parsed)); |
2821 | 2818 | ||
@@ -2944,10 +2941,10 @@ main_get_winsize (main_file *ifile) { | |||
2944 | 2941 | ||
2945 | if (main_file_stat (ifile, &file_size) == 0) | 2942 | if (main_file_stat (ifile, &file_size) == 0) |
2946 | { | 2943 | { |
2947 | size = (usize_t) min(file_size, (xoff_t) size); | 2944 | size = (usize_t) xd3_min (file_size, (xoff_t) size); |
2948 | } | 2945 | } |
2949 | 2946 | ||
2950 | size = max(size, XD3_ALLOCSIZE); | 2947 | size = xd3_max (size, XD3_ALLOCSIZE); |
2951 | 2948 | ||
2952 | if (option_verbose > 1) | 2949 | if (option_verbose > 1) |
2953 | { | 2950 | { |
@@ -3178,7 +3175,7 @@ main_input (xd3_cmd cmd, | |||
3178 | 3175 | ||
3179 | input_remain = XOFF_T_MAX - input_offset; | 3176 | input_remain = XOFF_T_MAX - input_offset; |
3180 | 3177 | ||
3181 | try_read = (usize_t) min ((xoff_t) config.winsize, input_remain); | 3178 | try_read = (usize_t) xd3_min ((xoff_t) config.winsize, input_remain); |
3182 | 3179 | ||
3183 | if ((ret = main_read_primary_input (ifile, main_bdata, | 3180 | if ((ret = main_read_primary_input (ifile, main_bdata, |
3184 | try_read, & nread))) | 3181 | try_read, & nread))) |
@@ -3289,7 +3286,7 @@ main_input (xd3_cmd cmd, | |||
3289 | /* Warn when no source copies are found */ | 3286 | /* Warn when no source copies are found */ |
3290 | if (option_verbose && ! xd3_encoder_used_source (& stream)) | 3287 | if (option_verbose && ! xd3_encoder_used_source (& stream)) |
3291 | { | 3288 | { |
3292 | XPR(NT "warning: input window %"Q"..%"Q" has " | 3289 | XPR(NT "warning: input window %"Q"u..%"Q"u has " |
3293 | "no source copies\n", | 3290 | "no source copies\n", |
3294 | stream.current_window * winsize, | 3291 | stream.current_window * winsize, |
3295 | (stream.current_window+1) * winsize); | 3292 | (stream.current_window+1) * winsize); |
@@ -3302,8 +3299,8 @@ main_input (xd3_cmd cmd, | |||
3302 | stream.srcwin_decided_early && | 3299 | stream.srcwin_decided_early && |
3303 | stream.i_slots_used > stream.iopt_size) | 3300 | stream.i_slots_used > stream.iopt_size) |
3304 | { | 3301 | { |
3305 | XPR(NT "warning: input position %"Q" overflowed " | 3302 | XPR(NT "warning: input position %"Q"u overflowed " |
3306 | "instruction buffer, needed %"Z" (vs. %"Z"), " | 3303 | "instruction buffer, needed %"Z"u (vs. %"Z"u), " |
3307 | "consider changing -I\n", | 3304 | "consider changing -I\n", |
3308 | stream.current_window * winsize, | 3305 | stream.current_window * winsize, |
3309 | stream.i_slots_used, stream.iopt_size); | 3306 | stream.i_slots_used, stream.iopt_size); |
@@ -3326,7 +3323,7 @@ main_input (xd3_cmd cmd, | |||
3326 | 3323 | ||
3327 | if (option_verbose > 1) | 3324 | if (option_verbose > 1) |
3328 | { | 3325 | { |
3329 | XPR(NT "%"Q": in %s (%s): out %s (%s): " | 3326 | XPR(NT "%"Q"u: in %s (%s): out %s (%s): " |
3330 | "total in %s: out %s: %s: srcpos %s\n", | 3327 | "total in %s: out %s: %s: srcpos %s\n", |
3331 | stream.current_window, | 3328 | stream.current_window, |
3332 | main_format_bcnt (this_read, &rdb), | 3329 | main_format_bcnt (this_read, &rdb), |
@@ -3340,7 +3337,7 @@ main_input (xd3_cmd cmd, | |||
3340 | } | 3337 | } |
3341 | else | 3338 | else |
3342 | { | 3339 | { |
3343 | XPR(NT "%"Q": in %s: out %s: total in %s: " | 3340 | XPR(NT "%"Q"u: in %s: out %s: total in %s: " |
3344 | "out %s: %s\n", | 3341 | "out %s: %s\n", |
3345 | stream.current_window, | 3342 | stream.current_window, |
3346 | main_format_bcnt (this_read, &rdb), | 3343 | main_format_bcnt (this_read, &rdb), |
@@ -3427,21 +3424,21 @@ done: | |||
3427 | if (option_verbose > 1 && cmd == CMD_ENCODE) | 3424 | if (option_verbose > 1 && cmd == CMD_ENCODE) |
3428 | { | 3425 | { |
3429 | XPR(NT "scanner configuration: %s\n", stream.smatcher.name); | 3426 | XPR(NT "scanner configuration: %s\n", stream.smatcher.name); |
3430 | XPR(NT "target hash table size: %"Z"\n", stream.small_hash.size); | 3427 | XPR(NT "target hash table size: %"Z"u\n", stream.small_hash.size); |
3431 | if (sfile != NULL && sfile->filename != NULL) | 3428 | if (sfile != NULL && sfile->filename != NULL) |
3432 | { | 3429 | { |
3433 | XPR(NT "source hash table size: %"Z"\n", stream.large_hash.size); | 3430 | XPR(NT "source hash table size: %"Z"u\n", stream.large_hash.size); |
3434 | } | 3431 | } |
3435 | } | 3432 | } |
3436 | 3433 | ||
3437 | if (option_verbose > 2 && cmd == CMD_ENCODE) | 3434 | if (option_verbose > 2 && cmd == CMD_ENCODE) |
3438 | { | 3435 | { |
3439 | XPR(NT "source copies: %"Q" (%"Q" bytes)\n", | 3436 | XPR(NT "source copies: %"Q"u (%"Q"u bytes)\n", |
3440 | stream.n_scpy, stream.l_scpy); | 3437 | stream.n_scpy, stream.l_scpy); |
3441 | XPR(NT "target copies: %"Q" (%"Q" bytes)\n", | 3438 | XPR(NT "target copies: %"Q"u (%"Q"u bytes)\n", |
3442 | stream.n_tcpy, stream.l_tcpy); | 3439 | stream.n_tcpy, stream.l_tcpy); |
3443 | XPR(NT "adds: %"Q" (%"Q" bytes)\n", stream.n_add, stream.l_add); | 3440 | XPR(NT "adds: %"Q"u (%"Q"u bytes)\n", stream.n_add, stream.l_add); |
3444 | XPR(NT "runs: %"Q" (%"Q" bytes)\n", stream.n_run, stream.l_run); | 3441 | XPR(NT "runs: %"Q"u (%"Q"u bytes)\n", stream.n_run, stream.l_run); |
3445 | } | 3442 | } |
3446 | #endif | 3443 | #endif |
3447 | 3444 | ||
@@ -3453,7 +3450,7 @@ done: | |||
3453 | long end_time = get_millisecs_now (); | 3450 | long end_time = get_millisecs_now (); |
3454 | xoff_t nwrite = ofile != NULL ? ofile->nwrite : 0; | 3451 | xoff_t nwrite = ofile != NULL ? ofile->nwrite : 0; |
3455 | 3452 | ||
3456 | XPR(NT "finished in %s; input %"Q" output %"Q" bytes (%0.2f%%)\n", | 3453 | XPR(NT "finished in %s; input %"Q"u output %"Q"u bytes (%0.2f%%)\n", |
3457 | main_format_millis (end_time - start_time, &tm), | 3454 | main_format_millis (end_time - start_time, &tm), |
3458 | ifile->nread, nwrite, 100.0 * nwrite / ifile->nread); | 3455 | ifile->nread, nwrite, 100.0 * nwrite / ifile->nread); |
3459 | } | 3456 | } |