diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/bench/zlib_bench.cc | 33 | ||||
-rw-r--r-- | contrib/minizip/miniunz.c | 13 | ||||
-rw-r--r-- | contrib/minizip/minizip.c | 7 | ||||
-rw-r--r-- | contrib/minizip/minizip.md | 9 | ||||
-rw-r--r-- | contrib/tests/infcover.cc | 4 |
5 files changed, 23 insertions, 43 deletions
diff --git a/contrib/bench/zlib_bench.cc b/contrib/bench/zlib_bench.cc index 252560e..bd06ad3 100644 --- a/contrib/bench/zlib_bench.cc +++ b/contrib/bench/zlib_bench.cc @@ -193,7 +193,7 @@ void verify_equal(const char* input, size_t size, std::string* output) { exit(3); } -void zlib_file(const char* name, const zlib_wrapper type, int width) { +void zlib_file(const char* name, const zlib_wrapper type) { /* * Read the file data. */ @@ -283,9 +283,9 @@ void zlib_file(const char* name, const zlib_wrapper type, int width) { double inflate_rate_max = length * repeats / mega_byte / utime[0]; // type, block size, compression ratio, etc - printf("%s: [b %dM] bytes %*d -> %*u %4.2f%%", - zlib_wrapper_name(type), block_size / (1 << 20), width, length, width, - unsigned(output_length), output_length * 100.0 / length); + printf("%s: [b %dM] bytes %6d -> %6u %4.1f%%", + zlib_wrapper_name(type), block_size / (1 << 20), length, + static_cast<unsigned>(output_length), output_length * 100.0 / length); // compress / uncompress median (max) rates printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n", @@ -300,20 +300,16 @@ char* get_option(int argc, char* argv[], const char* option) { return nullptr; } -bool get_compression(int argc, char* argv[], int& value) { +bool get_compression(int argc, char* argv[], int* value) { if (argn < argc) - value = isdigit(argv[argn][0]) ? atoi(argv[argn++]) : -1; - return value >= 0 && value <= 9; + *value = isdigit(argv[argn][0]) ? atoi(argv[argn++]) : -1; + return *value >= 0 && *value <= 9; } -void get_field_width(int argc, char* argv[], int& value) { - value = atoi(argv[argn++]); -} +const char* options = "gzip|zlib|raw [--compression 0:9] [--huffman|--rle]"; void usage_exit(const char* program) { - static auto* options = - "gzip|zlib|raw [--compression 0:9] [--huffman|--rle] [--field width]"; - printf("usage: %s %s files ...\n", program, options); + printf("usage: %s %s files...", program, options); exit(1); } @@ -328,14 +324,10 @@ int main(int argc, char* argv[]) { else usage_exit(argv[0]); - int file_size_field_width = 0; - while (argn < argc && argv[argn][0] == '-') { if (get_option(argc, argv, "--compression")) { - if (!get_compression(argc, argv, zlib_compression_level)) + if (!get_compression(argc, argv, &zlib_compression_level)) usage_exit(argv[0]); - } else if (get_option(argc, argv, "--field")) { - get_field_width(argc, argv, file_size_field_width); } else if (get_option(argc, argv, "--huffman")) { zlib_strategy = Z_HUFFMAN_ONLY; } else if (get_option(argc, argv, "--rle")) { @@ -347,11 +339,8 @@ int main(int argc, char* argv[]) { if (argn >= argc) usage_exit(argv[0]); - - if (file_size_field_width < 6) - file_size_field_width = 6; while (argn < argc) - zlib_file(argv[argn++], type, file_size_field_width); + zlib_file(argv[argn++], type); return 0; } diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c index 08737f6..3d65401 100644 --- a/contrib/minizip/miniunz.c +++ b/contrib/minizip/miniunz.c @@ -12,7 +12,7 @@ Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) */ -#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID_API__)) +#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) #ifndef __USE_FILE_OFFSET64 #define __USE_FILE_OFFSET64 #endif @@ -27,7 +27,7 @@ #endif #endif -#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +#ifdef __APPLE__ // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions #define FOPEN_FUNC(filename, mode) fopen(filename, mode) #define FTELLO_FUNC(stream) ftello(stream) @@ -45,7 +45,6 @@ #include <time.h> #include <errno.h> #include <fcntl.h> -#include <sys/stat.h> #ifdef _WIN32 # include <direct.h> @@ -98,7 +97,7 @@ void change_file_date(filename,dosdate,tmu_date) SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); CloseHandle(hFile); #else -#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +#ifdef unix || __APPLE__ struct utimbuf ut; struct tm newdate; newdate.tm_sec = tmu_date.tm_sec; @@ -126,9 +125,11 @@ int mymkdir(dirname) const char* dirname; { int ret=0; -#if defined(_WIN32) +#ifdef _WIN32 ret = _mkdir(dirname); -#elif defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +#elif unix + ret = mkdir (dirname,0775); +#elif __APPLE__ ret = mkdir (dirname,0775); #endif return ret; diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c index b794953..4288962 100644 --- a/contrib/minizip/minizip.c +++ b/contrib/minizip/minizip.c @@ -12,7 +12,8 @@ Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) */ -#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID_API__)) + +#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) #ifndef __USE_FILE_OFFSET64 #define __USE_FILE_OFFSET64 #endif @@ -27,7 +28,7 @@ #endif #endif -#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +#ifdef __APPLE__ // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions #define FOPEN_FUNC(filename, mode) fopen(filename, mode) #define FTELLO_FUNC(stream) ftello(stream) @@ -93,7 +94,7 @@ uLong filetime(f, tmzip, dt) return ret; } #else -#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__) +#ifdef unix || __APPLE__ uLong filetime(f, tmzip, dt) char *f; /* name of file to get info on */ tm_zip *tmzip; /* return value: access, modific. and creation times */ diff --git a/contrib/minizip/minizip.md b/contrib/minizip/minizip.md deleted file mode 100644 index 9f15dd2..0000000 --- a/contrib/minizip/minizip.md +++ /dev/null @@ -1,9 +0,0 @@ -Minizip is a library provided by //third_party/zlib [1]. Its zip and unzip -tools can be built in a developer checkout for testing purposes with: - -```shell - autoninja -C out/Release minizip_bin - autoninja -C out/Release miniunz_bin -``` - -[1] Upstream is https://github.com/madler/zlib/tree/master/contrib/minizip diff --git a/contrib/tests/infcover.cc b/contrib/tests/infcover.cc index 16dd744..c5300a5 100644 --- a/contrib/tests/infcover.cc +++ b/contrib/tests/infcover.cc @@ -395,9 +395,7 @@ void cover_support(void) mem_setup(&strm); strm.avail_in = 0; strm.next_in = Z_NULL; - char versioncpy[] = ZLIB_VERSION; - versioncpy[0] -= 1; - ret = inflateInit_(&strm, versioncpy, (int)sizeof(z_stream)); + ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream)); assert(ret == Z_VERSION_ERROR); mem_done(&strm, "wrong version"); |