Move variable declarations earlier, to help old compilers.
From Khaled Mardam-Bey.
diff --git a/THANKS b/THANKS
index 4699063..e53c53b 100644
--- a/THANKS
+++ b/THANKS
@@ -54,6 +54,7 @@
Julien Schueller <schueller@phimeca.com>
kensington <kensington@gentoo.org>
Keith Jones <keith@keithjjones.com>
+Khaled Mardam-Bey
Kohei Yoshida <kohei.yoshida@gmail.com>
Leith Bade <leith@mapbox.com>
Lubomir I. Ivanov <neolit123@gmail.com>
diff --git a/lib/zip_source_file_win32_named.c b/lib/zip_source_file_win32_named.c
index aa91f93..a2a44c8 100644
--- a/lib/zip_source_file_win32_named.c
+++ b/lib/zip_source_file_win32_named.c
@@ -65,13 +65,14 @@
static zip_int64_t
_zip_win32_named_op_commit_write(zip_source_file_context_t *ctx) {
zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata;
+ DWORD attributes;
if (!CloseHandle((HANDLE)ctx->fout)) {
zip_error_set(&ctx->error, ZIP_ER_WRITE, _zip_win32_error_to_errno(GetLastError()));
return -1;
}
- DWORD attributes = file_ops->get_file_attributes(ctx->tmpname);
+ attributes = file_ops->get_file_attributes(ctx->tmpname);
if (attributes == INVALID_FILE_ATTRIBUTES) {
zip_error_set(&ctx->error, ZIP_ER_RENAME, _zip_win32_error_to_errno(GetLastError()));
return -1;
@@ -248,6 +249,7 @@
DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE;
DWORD creation_disposition = OPEN_EXISTING;
DWORD file_attributes = FILE_ATTRIBUTE_NORMAL;
+ HANDLE h;
if (temporary) {
access = GENERIC_READ | GENERIC_WRITE;
@@ -256,7 +258,7 @@
file_attributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY;
}
- HANDLE h = file_ops->create_file(name, access, share_mode, security_attributes, creation_disposition, file_attributes, NULL);
+ h = file_ops->create_file(name, access, share_mode, security_attributes, creation_disposition, file_attributes, NULL);
if (h == INVALID_HANDLE_VALUE) {
zip_error_set(&ctx->error, ZIP_ER_OPEN, _zip_win32_error_to_errno(GetLastError()));
diff --git a/lib/zip_source_pkware_decode.c b/lib/zip_source_pkware_decode.c
index 28a4eed..a1c9e3a 100644
--- a/lib/zip_source_pkware_decode.c
+++ b/lib/zip_source_pkware_decode.c
@@ -82,6 +82,7 @@
zip_uint8_t header[ZIP_CRYPTO_PKWARE_HEADERLEN];
struct zip_stat st;
zip_int64_t n;
+ bool ok = false;
if ((n = zip_source_read(src, header, ZIP_CRYPTO_PKWARE_HEADERLEN)) < 0) {
_zip_error_set_from_source(&ctx->error, src);
@@ -105,8 +106,6 @@
* CRC - old PKWare way
*/
- bool ok = false;
-
if (st.valid & ZIP_STAT_MTIME) {
unsigned short dostime, dosdate;
_zip_u2d_time(st.mtime, &dostime, &dosdate);