From 1fc4168b81f565feab409b92ccb61c57a1c550eb Mon Sep 17 00:00:00 2001 From: DLL125 <134442578+DLL125@users.noreply.github.com> Date: Thu, 25 May 2023 12:52:53 +0200 Subject: Update Libzip to latest 1.9.2 (#1071) * Libzip 1.9.2 Updated Libzip to latest version 1.9.2 and changed version number in the config.h from 1.7.3 to 1.9.2. Not sure if anything else needs to be tweaked :) * Modified Libzip to work with Visual studio * Update README.md Update libzip copyright. * Added the missing files. I've added the missing files zipconf.h and config.h, I've missed those sorry for that! --- src/Common/libzip/zip_string.c | 86 +++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'src/Common/libzip/zip_string.c') diff --git a/src/Common/libzip/zip_string.c b/src/Common/libzip/zip_string.c index 122721d8..570a8fac 100644 --- a/src/Common/libzip/zip_string.c +++ b/src/Common/libzip/zip_string.c @@ -1,9 +1,9 @@ /* zip_string.c -- string handling (with encoding) - Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner + Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. - The authors can be contacted at + The authors can be contacted at Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -45,7 +45,7 @@ _zip_string_crc32(const zip_string_t *s) { crc = (zip_uint32_t)crc32(0L, Z_NULL, 0); if (s != NULL) - crc = (zip_uint32_t)crc32(crc, s->raw, s->length); + crc = (zip_uint32_t)crc32(crc, s->raw, s->length); return crc; } @@ -54,10 +54,10 @@ _zip_string_crc32(const zip_string_t *s) { int _zip_string_equal(const zip_string_t *a, const zip_string_t *b) { if (a == NULL || b == NULL) - return a == b; + return a == b; if (a->length != b->length) - return 0; + return 0; /* TODO: encoding */ @@ -68,7 +68,7 @@ _zip_string_equal(const zip_string_t *a, const zip_string_t *b) { void _zip_string_free(zip_string_t *s) { if (s == NULL) - return; + return; free(s->raw); free(s->converted); @@ -81,29 +81,29 @@ _zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip static const zip_uint8_t empty[1] = ""; if (string == NULL) { - if (lenp) - *lenp = 0; - return empty; + if (lenp) + *lenp = 0; + return empty; } if ((flags & ZIP_FL_ENC_RAW) == 0) { - /* start guessing */ - if (string->encoding == ZIP_ENCODING_UNKNOWN) - _zip_guess_encoding(string, ZIP_ENCODING_UNKNOWN); - - if (((flags & ZIP_FL_ENC_STRICT) && string->encoding != ZIP_ENCODING_ASCII && string->encoding != ZIP_ENCODING_UTF8_KNOWN) || (string->encoding == ZIP_ENCODING_CP437)) { - if (string->converted == NULL) { - if ((string->converted = _zip_cp437_to_utf8(string->raw, string->length, &string->converted_length, error)) == NULL) - return NULL; - } - if (lenp) - *lenp = string->converted_length; - return string->converted; - } + /* start guessing */ + if (string->encoding == ZIP_ENCODING_UNKNOWN) + _zip_guess_encoding(string, ZIP_ENCODING_UNKNOWN); + + if (((flags & ZIP_FL_ENC_STRICT) && string->encoding != ZIP_ENCODING_ASCII && string->encoding != ZIP_ENCODING_UTF8_KNOWN) || (string->encoding == ZIP_ENCODING_CP437)) { + if (string->converted == NULL) { + if ((string->converted = _zip_cp437_to_utf8(string->raw, string->length, &string->converted_length, error)) == NULL) + return NULL; + } + if (lenp) + *lenp = string->converted_length; + return string->converted; + } } if (lenp) - *lenp = string->length; + *lenp = string->length; return string->raw; } @@ -111,7 +111,7 @@ _zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip zip_uint16_t _zip_string_length(const zip_string_t *s) { if (s == NULL) - return 0; + return 0; return s->length; } @@ -123,31 +123,31 @@ _zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, zip_encoding_type_t expected_encoding; if (length == 0) - return NULL; + return NULL; switch (flags & ZIP_FL_ENCODING_ALL) { case ZIP_FL_ENC_GUESS: - expected_encoding = ZIP_ENCODING_UNKNOWN; - break; + expected_encoding = ZIP_ENCODING_UNKNOWN; + break; case ZIP_FL_ENC_UTF_8: - expected_encoding = ZIP_ENCODING_UTF8_KNOWN; - break; + expected_encoding = ZIP_ENCODING_UTF8_KNOWN; + break; case ZIP_FL_ENC_CP437: - expected_encoding = ZIP_ENCODING_CP437; - break; + expected_encoding = ZIP_ENCODING_CP437; + break; default: - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; } if ((s = (zip_string_t *)malloc(sizeof(*s))) == NULL) { - zip_error_set(error, ZIP_ER_MEMORY, 0); - return NULL; + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; } if ((s->raw = (zip_uint8_t *)malloc((size_t)length + 1)) == NULL) { - free(s); - return NULL; + free(s); + return NULL; } memcpy(s->raw, raw, length); @@ -158,11 +158,11 @@ _zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, s->converted_length = 0; if (expected_encoding != ZIP_ENCODING_UNKNOWN) { - if (_zip_guess_encoding(s, expected_encoding) == ZIP_ENCODING_ERROR) { - _zip_string_free(s); - zip_error_set(error, ZIP_ER_INVAL, 0); - return NULL; - } + if (_zip_guess_encoding(s, expected_encoding) == ZIP_ENCODING_ERROR) { + _zip_string_free(s); + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } } return s; @@ -172,7 +172,7 @@ _zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, int _zip_string_write(zip_t *za, const zip_string_t *s) { if (s == NULL) - return 0; + return 0; return _zip_write(za, s->raw, s->length); } -- cgit v1.2.3