Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation on MSVC 2008 #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/zopfli/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ void ZopfliCalculateEntropy(const size_t* count, size_t n, double* bitlengths) {
for (i = 0; i < n; ++i) {
sum += count[i];
}
log2sum = (sum == 0 ? log(n) : log(sum)) * kInvLog2;
log2sum = (sum == 0 ? log((double)n) : log((double)sum)) * kInvLog2;
for (i = 0; i < n; ++i) {
/* When the count of the symbol is 0, but its cost is requested anyway, it
means the symbol will appear at least once anyway, so give it the cost as if
its count is 1.*/
if (count[i] == 0) bitlengths[i] = log2sum;
else bitlengths[i] = log2sum - log(count[i]) * kInvLog2;
else bitlengths[i] = log2sum - log((double)count[i]) * kInvLog2;
/* Depending on compiler and architecture, the above subtraction of two
floating point numbers may give a negative result very close to zero
instead of zero (e.g. -5.973954e-17 with gcc 4.1.2 on Ubuntu 11.4). Clamp
Expand Down
2 changes: 1 addition & 1 deletion src/zopfli/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Set it to 0 to disable master blocks.
/*
Used to initialize costs for example
*/
#define ZOPFLI_LARGE_FLOAT 1e30
#define ZOPFLI_LARGE_FLOAT 1e30f

/*
For longest match cache. max 256. Uses huge amounts of memory but makes it
Expand Down
1 change: 1 addition & 0 deletions src/zopfli/zopfli_bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ decompressor.

/* Windows workaround for stdout output. */
#if _WIN32
#include <io.h>
#include <fcntl.h>
#endif

Expand Down