Commit Graph

380 Commits

Author SHA1 Message Date
Nyq
fd55960854
Update miniz_zip.c to prevent compilation warning when compiling for Windows in straight C mode
Summary:
Added conditional macro definition to prevent MSVC compiler warning C5105 when compiling for Windows in straight C mode

Details:
Since version 3.0.0 miniz_zip.c includes windows.h header file when compiling for Windows using MSVC. However, when compiling miniz_zip.c using MSVC17 in straight-C mode (no C++), this inclusion causes warning C5105:

winbase.h(9531,5): warning C5105: macro expansion producing 'defined' has undefined behavior

This warning is not produced when compiling in C++ mode.

In order to prevent the warning, any straight-C code that wants to include windows.h should make an additional define before including:
#ifndef __cplusplus
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 0
#endif
#include <windows.h>
2023-08-15 05:39:55 -04:00
Nyq
b0af33a61b
Update miniz_tdef.c to enable compiling in forced-C++ mode
Summary:
Merged definition of static const mz_uint s_tdefl_num_probes[11] with its declaration to avoid compilation error when compiling in forced-C++mode

Details:
When miniz_tdef.c is compiled in C++ mode (either by forcing the compiler to treat the input as C++ or by renaming the file into miniz.cpp), MSVC17 produces the following error:
```
miniz_tdef.cpp(2113,22): error C2086: 'const mz_uint s_tdefl_num_probes[11]': redefinition
miniz_tdef.cpp(1254,22): message : see declaration of 's_tdefl_num_probes'
```
This happens because in miniz_tdef.c we have the following:

```
/*Line 606:*/ static const mz_uint s_tdefl_num_probes[11];
/*Line 1465:*/ static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
```
While miniz_tdef.c is a C source file and not C++, sometimes it is used in C++ projects where settings are such that mixed C/C++ compilation is not allowed and all input source files are treated as forced C++. So there would be no harm to make a small adjustment so that the source code is conformant with both C and C++ requirements.

There are two ways it can be done:
Option 1: change line 606 from `static const mz_uint s_tdefl_num_probes[11];` to `extern const mz_uint s_tdefl_num_probes[11];`
Option2: eliminate line 1465 entirely and move line 2113 into line 1254 so that the code looks like this:
```
/*Line 606:*/ static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
/*Line 1465:*/ //Nothing here
```
Either option works for both C and C++ and really there is no harm in simply moving the full definition up like in option B and avoid duplication.

This change implements option B.
2023-08-15 04:50:07 -04:00
Martin Raiber
9ae305f6e1
Merge pull request #268 from jpcha2/master
Ensure correct integer promotion when adding
2023-04-12 21:10:11 +02:00
Martin Raiber
d9d197c926
Merge pull request #270 from J5lx/mingw32-unicode
Fix Unicode paths on MinGW32
2023-04-12 21:07:54 +02:00
Jakob Gahde
654bf8bdeb
Fix Unicode paths on MinGW32 2023-02-14 07:10:06 +01:00
jpcha2
fe6330e1d8
Update miniz_tinfl.c
Additional parameter checks
2023-01-17 12:25:12 +03:00
jpcha2
f259216256
Merge pull request #1 from jpcha2/jpcha2-patch-1-int64-promotion-order
Update miniz_zip.c
2023-01-17 11:52:16 +03:00
jpcha2
f0709ed3f5
Update miniz_zip.c
Code Quality (Avoid Integer Overflow): Ensure correct order of integer size promotion when doing additions by placing the mz_uint64 value first or explicitly casting the first value to mz_uint64.
2023-01-17 11:49:41 +03:00
Martin Raiber
293d4db1b7
Increment version 2023-01-15 12:55:58 +01:00
Martin Raiber
12680974d1
Increment version 2023-01-15 12:55:30 +01:00
Martin Raiber
ad8dedc1b3
Update ChangeLog.md 2023-01-15 12:52:28 +01:00
Martin Raiber
08c03ff478
Merge pull request #264 from jpcha2/patch-1
Update miniz_zip.c
2023-01-15 12:51:17 +01:00
Fabian Greffrath
2ec92b4852 Fix missing large file support warning on 64-bit Linux
Pragmatic approach: Treat Linux on x86_64 the same as Mac OS X and FreeBSD,
i.e. as a Unix-like 64-bit operating system with know large file support.

Fixes #257
2022-12-14 10:12:10 +01:00
jpcha2
78e9404362
Update miniz_zip.c
Bugfix: MultiByteToWideChar() is being called with a byte count instead of a character count. This will cause a buffer overrun.
2022-11-21 04:36:20 +03:00
Martin Raiber
963a27a112
Increment version 2022-11-06 13:47:54 +01:00
Martin Raiber
2363190ebf
Increment version 2022-11-06 13:47:03 +01:00
Martin Raiber
7265019066
Update changelog 2022-11-06 13:43:12 +01:00
Martin Raiber
83341a5605
Merge pull request #263 from nekonomicon/match_dist
Fix variable declaration.
2022-11-06 13:42:00 +01:00
Martin Raiber
39622ead92
Test compile with MINIZ_USE_UNALIGNED_LOADS_AND_STORES=1 2022-11-06 12:40:00 +01:00
Andrey Akhmichin
ab052e6e58
Fix variable declaration. 2022-11-06 14:55:25 +05:00
Martin
39f65158c7 Update changelog 2022-10-23 18:40:45 +02:00
Martin Raiber
ca0cdfc52d
Merge pull request #252 from JonLiu1993/vcpkg-instructions
Add vcpkg installation instructions
2022-08-25 22:03:10 +02:00
Martin Raiber
7b9bcf7f94
Merge pull request #234 from gtreshchev/bit-shift-fix
Bit shift fix
2022-08-25 22:02:34 +02:00
Martin Raiber
92ab73ac32
Merge pull request #236 from Dialga/patch-1
Fix callback typo
2022-08-25 22:02:06 +02:00
Martin Raiber
78ef92043c
Merge pull request #237 from jodavaho/dev/fix_shadow_warning
Fix for n shadows variable
2022-08-25 22:01:46 +02:00
Martin Raiber
11f77193b7
Merge pull request #241 from systoolz/patch-1
missing const in declaration
2022-08-25 21:59:05 +02:00
Martin Raiber
4a8dc21d9d
Merge pull request #238 from kobrineli/fix-overflow
Fix integer overflow in header corruption check.
2022-08-25 21:58:37 +02:00
Martin Raiber
725b8df44c
Merge pull request #239 from MatthewGentoo/cmake--pkgconfig
pkg-config tweaks
2022-08-25 21:58:04 +02:00
Martin Raiber
8cdf426109
Merge branch 'master' into cmake--pkgconfig 2022-08-25 21:57:56 +02:00
Martin Raiber
680454c21e
Merge pull request #247 from davidebeatrici/miniz.pc.ib-include-dir-fix
miniz.pc.in: fix include path not containing the "miniz" suffix
2022-08-25 21:57:01 +02:00
Jonliu1993
a203b9a0d4 Add vcpkg installation instructions 2022-08-25 16:21:22 +08:00
Davide Beatrici
d4ad2bf51e miniz.pc.in: fix include path not containing the "miniz" suffix 2022-08-02 19:25:10 +02:00
Martin Raiber
be92575500
Merge pull request #240 from AMDmi3/freebsd
Fix compatibility with FreeBSD and improve readability in miniz_zip.c
2022-07-09 13:00:58 +02:00
systoolz
a2b5326d86
missing const in declaration 2022-06-10 22:17:21 +07:00
Dmitry Marakasov
de0a4d2444 Use stdio functions without 64 suffix on FreeBSD
FreeBSD neither has nor needs suffixed functions
2022-06-08 20:36:46 +03:00
Dmitry Marakasov
482c77e661 Add blank lines between if blocks in miniz_zip.c for readability 2022-06-08 20:32:54 +03:00
Matthew Smith
37ea28133d
build: Set pkgconfig includedir to miniz directory
Allows users to include <miniz.h> instead of <miniz/miniz.h> which
seems to be the intended behaviour.
2022-06-04 09:31:06 +01:00
Matthew Smith
9cd715b3b1
build: Install .pc file in correct directory
/usr/share/pkgconfig should be used for architecture independent
libraries (e.g. data or scripts), while an architecture dependent
directory like /usr/lib64/pkgconfig should be used for native
binaries.

Co-authored-by: Sam James <sam@gentoo.org>
2022-06-04 09:22:37 +01:00
Eli Kobrin
a9d7f80cc6 Fix integer overflow in header corruption check. 2022-05-20 16:30:30 +03:00
Josh Vander Hook
8db69b6b59 Fix for n shadows variable 2022-05-19 11:24:55 -07:00
Georgy Treshchev
c610f58a57 Replacing "1ULL" with "(size_t)1" 2022-05-16 19:47:54 +04:00
Dialga
e1e7f70e59
Fix callback typo 2022-05-17 01:37:04 +12:00
Martin Raiber
76b3a87285
Update ChangeLog.md 2022-05-08 16:53:32 +02:00
Martin Raiber
5c9c89509c
Merge pull request #231 from nedelec/master
Fixed alignment problems on MacOS
2022-05-08 16:48:02 +02:00
Martin Raiber
719967dc82
Merge pull request #225 from randy408/zlib_flevel
deflate: write zlib FLEVEL based on compression level
2022-05-08 16:46:36 +02:00
Martin Raiber
18bc504331
Merge pull request #224 from Dialga/patch-1
Add switch case for MZ_ZIP_TOTAL_ERRORS
2022-05-08 16:44:03 +02:00
Martin Raiber
144c351f34
Update miniz_tdef.c
Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com>
2022-05-06 21:30:08 +02:00
Martin Raiber
bc77ea1017
Update miniz_tdef.c
Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com>
2022-05-06 21:30:02 +02:00
Randy
7c459c8a05
Update miniz_tdef.c
Co-authored-by: Alexander Borsuk <170263+biodranik@users.noreply.github.com>
2022-05-06 05:01:09 +02:00
Georgy Treshchev
118b2e3d34 Bit shift fix 2022-05-01 11:33:43 +04:00