summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/bench/zlib_bench.cc33
-rw-r--r--contrib/minizip/miniunz.c13
-rw-r--r--contrib/minizip/minizip.c7
-rw-r--r--contrib/minizip/minizip.md9
-rw-r--r--contrib/tests/infcover.cc4
5 files changed, 43 insertions, 23 deletions
diff --git a/contrib/bench/zlib_bench.cc b/contrib/bench/zlib_bench.cc
index bd06ad3..252560e 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) {
+void zlib_file(const char* name, const zlib_wrapper type, int width) {
/*
* Read the file data.
*/
@@ -283,9 +283,9 @@ void zlib_file(const char* name, const zlib_wrapper type) {
double inflate_rate_max = length * repeats / mega_byte / utime[0];
// type, block size, compression ratio, etc
- 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);
+ 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);
// compress / uncompress median (max) rates
printf(" comp %5.1f (%5.1f) MB/s uncomp %5.1f (%5.1f) MB/s\n",
@@ -300,16 +300,20 @@ 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;
}
-const char* options = "gzip|zlib|raw [--compression 0:9] [--huffman|--rle]";
+void get_field_width(int argc, char* argv[], int& value) {
+ value = atoi(argv[argn++]);
+}
void usage_exit(const char* program) {
- printf("usage: %s %s files...", program, options);
+ static auto* options =
+ "gzip|zlib|raw [--compression 0:9] [--huffman|--rle] [--field width]";
+ printf("usage: %s %s files ...\n", program, options);
exit(1);
}
@@ -324,10 +328,14 @@ 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")) {
@@ -339,8 +347,11 @@ 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);
+ zlib_file(argv[argn++], type, file_size_field_width);
return 0;
}
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c
index 3d65401..08737f6 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__))
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID_API__))
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
@@ -27,7 +27,7 @@
#endif
#endif
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
// 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,6 +45,7 @@
#include <time.h>
#include <errno.h>
#include <fcntl.h>
+#include <sys/stat.h>
#ifdef _WIN32
# include <direct.h>
@@ -97,7 +98,7 @@ void change_file_date(filename,dosdate,tmu_date)
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
#else
-#ifdef unix || __APPLE__
+#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
@@ -125,11 +126,9 @@ int mymkdir(dirname)
const char* dirname;
{
int ret=0;
-#ifdef _WIN32
+#if defined(_WIN32)
ret = _mkdir(dirname);
-#elif unix
- ret = mkdir (dirname,0775);
-#elif __APPLE__
+#elif defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
ret = mkdir (dirname,0775);
#endif
return ret;
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c
index 4288962..b794953 100644
--- a/contrib/minizip/minizip.c
+++ b/contrib/minizip/minizip.c
@@ -12,8 +12,7 @@
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
*/
-
-#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
+#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) && (!defined(__ANDROID_API__))
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
@@ -28,7 +27,7 @@
#endif
#endif
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
// 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)
@@ -94,7 +93,7 @@ uLong filetime(f, tmzip, dt)
return ret;
}
#else
-#ifdef unix || __APPLE__
+#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
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
new file mode 100644
index 0000000..9f15dd2
--- /dev/null
+++ b/contrib/minizip/minizip.md
@@ -0,0 +1,9 @@
+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 c5300a5..16dd744 100644
--- a/contrib/tests/infcover.cc
+++ b/contrib/tests/infcover.cc
@@ -395,7 +395,9 @@ void cover_support(void)
mem_setup(&strm);
strm.avail_in = 0;
strm.next_in = Z_NULL;
- ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream));
+ char versioncpy[] = ZLIB_VERSION;
+ versioncpy[0] -= 1;
+ ret = inflateInit_(&strm, versioncpy, (int)sizeof(z_stream));
assert(ret == Z_VERSION_ERROR);
mem_done(&strm, "wrong version");