1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
Description: change type of count of bytes from 'long' to 'unsigned long long'
According to bug #692214 there is an overflow when trying to process
10000000000 (>2.147.483.647) bytes. The error occurs after about 30min.
As there is a type 'unsigned long long' in C99 now, I use this type to
lengthen the time before the overflow will be reached. The affected computer
should reach it after 50000days now.
I am open for other suggestions.
Author: Thorsten Alteholz <debian@alteholz.de>
Index: ent/ent.c
===================================================================
--- ent.orig/ent.c 2015-06-13 16:45:14.776915604 +0200
+++ ent/ent.c 2015-06-13 16:45:14.768915624 +0200
@@ -100,8 +100,8 @@
int main(int argc, char *argv[])
{
int i, oc, opt;
- long ccount[256]; /* Bins to count occurrences of values */
- long totalc = 0; /* Total character count */
+ unsigned long long ccount[256];/* Bins to count occurrences of values */
+ unsigned long long totalc = 0; /* Total character count */
char *samp;
double montepi, chip,
scc, ent, mean, chisq;
@@ -208,7 +208,7 @@
if (terse) {
printf("0,File-%ss,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation\n",
binary ? "bit" : "byte");
- printf("1,%ld,%f,%f,%f,%f,%f\n",
+ printf("1,%lld,%f,%f,%f,%f,%f\n",
totalc, ent, chisq, mean, montepi, scc);
}
@@ -227,11 +227,11 @@
}
for (i = 0; i < (binary ? 2 : 256); i++) {
if (terse) {
- printf("3,%d,%ld,%f\n", i,
+ printf("3,%d,%lld,%f\n", i,
ccount[i], ((double) ccount[i] / totalc));
} else {
if (ccount[i] > 0) {
- printf("%3d %c %10ld %f\n", i,
+ printf("%3d %c %10lld %f\n", i,
/* The following expression shows ISO 8859-1
Latin1 characters and blanks out other codes.
The test for ISO space replaces the ISO
@@ -246,7 +246,7 @@
}
}
if (!terse) {
- printf("\nTotal: %10ld %f\n\n", totalc, 1.0);
+ printf("\nTotal: %10lld %f\n\n", totalc, 1.0);
}
}
@@ -255,11 +255,11 @@
if (!terse) {
printf("Entropy = %f bits per %s.\n", ent, samp);
printf("\nOptimum compression would reduce the size\n");
- printf("of this %ld %s file by %d percent.\n\n", totalc, samp,
+ printf("of this %lld %s file by %d percent.\n\n", totalc, samp,
(short) ((100 * ((binary ? 1 : 8) - ent) /
(binary ? 1.0 : 8.0))));
printf(
- "Chi square distribution for %ld samples is %1.2f, and randomly\n",
+ "Chi square distribution for %lld samples is %1.2f, and randomly\n",
totalc, chisq);
if (chip < 0.0001) {
printf("would exceed this value less than 0.01 percent of the times.\n\n");
Index: ent/randtest.c
===================================================================
--- ent.orig/randtest.c 2015-06-13 16:45:14.776915604 +0200
+++ ent/randtest.c 2015-06-13 16:45:14.768915624 +0200
@@ -15,8 +15,8 @@
static int binary = FALSE; /* Treat input as a bitstream */
-static long ccount[256], /* Bins to count occurrences of values */
- totalc = 0; /* Total bytes counted */
+static unsigned long long ccount[256],/* Bins to count occurrences of values */
+ totalc = 0; /* Total bytes counted */
static double prob[256]; /* Probabilities per bin for entropy */
/* RT_LOG2 -- Calculate log to the base 2 */
|