svn commit: r510710 - in head/math/diehard: . files

Li-Wen Hsu lwhsu at FreeBSD.org
Sun Sep 1 17:28:03 UTC 2019


Author: lwhsu
Date: Sun Sep  1 17:28:00 2019
New Revision: 510710
URL: https://svnweb.freebsd.org/changeset/ports/510710

Log:
  Add a patch to remove use of gets(3)
  
  PR:		238691
  Submitted by:	Walter Schwarzenfeld <w.schwarzenfeld at utanet.at>
  Reported by:	emaste
  Sponsored by:	The FreeBSD Foundation

Added:
  head/math/diehard/files/patch-cdbday.c   (contents, props changed)
  head/math/diehard/files/patch-cdbinrnk.c   (contents, props changed)
  head/math/diehard/files/patch-cdbitst.c   (contents, props changed)
  head/math/diehard/files/patch-cdoperm5.c   (contents, props changed)
  head/math/diehard/files/patch-cdosum.c   (contents, props changed)
  head/math/diehard/files/patch-cdpark.c   (contents, props changed)
  head/math/diehard/files/patch-cnt1s   (contents, props changed)
  head/math/diehard/files/patch-craptest.c   (contents, props changed)
  head/math/diehard/files/patch-d3sphere.c   (contents, props changed)
Modified:
  head/math/diehard/Makefile
  head/math/diehard/files/patch-cdomso.c
  head/math/diehard/files/patch-diehard.c

Modified: head/math/diehard/Makefile
==============================================================================
--- head/math/diehard/Makefile	Sun Sep  1 16:46:18 2019	(r510709)
+++ head/math/diehard/Makefile	Sun Sep  1 17:28:00 2019	(r510710)
@@ -3,6 +3,7 @@
 
 PORTNAME=	diehard
 PORTVERSION=	0.1
+PORTREVISION=	1
 CATEGORIES=	math
 MASTER_SITES=	http://stat.fsu.edu/pub/diehard/
 DISTNAME=	die-c

Added: head/math/diehard/files/patch-cdbday.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-cdbday.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,31 @@
+--- cdbday.c.orig	2019-08-03 11:00:43 UTC
++++ cdbday.c
+@@ -83,8 +83,8 @@ void bday(char *filename)
+   puts("\t|------------------------------------------------------------ |\n");
+  
+   printf("\t\tRESULTS OF BIRTHDAY SPACINGS TEST FOR %s\n", filename);
+-  printf("\t(no_bdays=%d, no_days/yr=2^%d,",no_bday, no_bits);
+-  printf(" lambda=%.2f, sample size=%d)\n\n", lambda, no_obs);
++  printf("\t(no_bdays=%lu, no_days/yr=2^%lu,",no_bday, no_bits);
++  printf(" lambda=%.2f, sample size=%lu)\n\n", lambda, no_obs);
+   printf("\tBits used\tmean\t\tchisqr\t\tp-value\n");
+ 
+   obs=(counter*)malloc(no_obs*sizeof(counter));
+@@ -121,7 +121,7 @@ void bday(char *filename)
+ 
+     p[rt]=P_fit(lambda, obs, no_obs);
+ 
+-    printf("\t %d to %d", 33-no_bits-rt,32-rt);
++    printf("\t %lu to %d", 33-no_bits-rt,32-rt);
+     printf("\t%.2f\t\t%.4f\t\t%f\n", (real)sum/no_obs, chi_fit, p[rt]);   
+ 
+   }
+@@ -134,7 +134,7 @@ void bday(char *filename)
+ 
+   printf("\n\t\t\tdegree of freedoms is: %d\n", dgf);
+   puts("\t---------------------------------------------------------------");
+-  printf("\t\tp-value for KStest on those %d p-values: %f",32-no_bits+1,pvalue);
++  printf("\t\tp-value for KStest on those %lu p-values: %f",32-no_bits+1,pvalue);
+   puts("\n"); 
+ 
+   free(p);

Added: head/math/diehard/files/patch-cdbinrnk.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-cdbinrnk.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,20 @@
+--- cdbinrnk.c.orig	2019-08-03 09:50:12 UTC
++++ cdbinrnk.c
+@@ -13,6 +13,8 @@ typedef struct binmatrix {
+ 
+ } binmatrix;
+ 
++#include <string.h>
++
+ /*print the title*/
+ void rnk_ttl(char *fn, char *test)
+ {
+@@ -162,7 +164,7 @@ real rnk_stat(char *fn, counter no_mtr, 
+     Ef=no_mtr* ( *(p+i) );
+     tmp=(f[i]-Ef)*(f[i]-Ef)/Ef;
+     chsq+=tmp;
+-    printf("\t%s%d\t%-12d\t%-12.1f", cat[MIN(1,i)], i+llim, f[i], Ef);
++    printf("\t%s%lu\t%-12lu\t%-12.1f", cat[MIN(1,i)], i+llim, f[i], Ef);
+     printf("\t%-12.3f\t%-12.3f\n", tmp, chsq);
+   }
+   uni("close");

Added: head/math/diehard/files/patch-cdbitst.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-cdbitst.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,22 @@
+--- cdbitst.c.orig	2019-08-03 10:34:33 UTC
++++ cdbitst.c
+@@ -41,8 +41,8 @@ void bitst(char *filename)
+   puts("\t|-------------------------------------------------------------|\n");
+ 
+   printf("\t\tTHE OVERLAPPING 20-TUPLES BITSTREAM  TEST for %s\n", filename);
+-  printf("\t (%d bits/word, %d words", nb_pw, no_wds);
+-  printf(" %d bitstreams.", no_obs );
++  printf("\t (%lu bits/word, %lu words", nb_pw, no_wds);
++  printf(" %lu bitstreams.", no_obs );
+   printf(" No. missing words \n\t  should average %.2f", mean);
+   printf(" with sigma=%.2f.)\n", std);
+   puts("\t----------------------------------------------------------------");
+@@ -80,7 +80,7 @@ void bitst(char *filename)
+     }
+ 
+     z=(no_mswds-mean)/std;
+-    printf("\t   %d\t\t%d \t\t\t% .2f\t\t%f\n", i, no_mswds, z, 1-Phi(z));
++    printf("\t   %lu\t\t%lu \t\t\t% .2f\t\t%f\n", i, no_mswds, z, 1-Phi(z));
+   }
+ 
+   uni("close");

Modified: head/math/diehard/files/patch-cdomso.c
==============================================================================
--- head/math/diehard/files/patch-cdomso.c	Sun Sep  1 16:46:18 2019	(r510709)
+++ head/math/diehard/files/patch-cdomso.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -1,11 +1,34 @@
---- cdomso.c.orig	1998-04-02 15:29:02 UTC
+--- cdomso.c.orig	2019-08-03 10:18:08 UTC
 +++ cdomso.c
-@@ -89,7 +89,7 @@ unsigned long get_w(char *fn, short bits
+@@ -138,7 +138,7 @@ real monky_stat(char *filename, char *te
+       }
+ 
+       z=(no_mswds-mean)/std;
+-      printf("\t%d to %d  \t\t%d ", 33-rt-bits_pl, 32-rt, no_mswds);
++      printf("\t%lu to %lu  \t\t%lu ", 33-rt-bits_pl, 32-rt, no_mswds);
+       printf("\t\t% .4f\t\t%f\n", z, 1-Phi(z));
+     }
+  
+@@ -151,11 +151,11 @@ real monky_stat(char *filename, char *te
+   printf("\t------------------------------");
+   printf("-----------------------------------\n");
+   
+-  return;
++  return 0;
  }
  
- 
--real monky_stat(char *filename, char *test, int no_tests)
-+void monky_stat(char *filename, char *test, int no_tests)
+ /* type "OPSO" for OPSO test and so on */
+-void monky(char *filename, char *test)
++int monky(char *filename, char *test)
  {
-   const real bits_pw=20, mean=pow(2, bits_pw)*exp(-2);
-   const counter dim=pow(2, bits_pw-5);
+   const int no_tests=1;
+ 
+@@ -165,7 +165,7 @@ void monky(char *filename, char *test)
+ 
+   monky_stat(filename, test, no_tests);
+ 
+-  return;
++  return 0;
+ 
+ }
+ 

Added: head/math/diehard/files/patch-cdoperm5.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-cdoperm5.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,27 @@
+--- cdoperm5.c.orig	2019-08-03 10:52:40 UTC
++++ cdoperm5.c
+@@ -71,21 +71,21 @@ void operm5(char *filename)
+   puts("\t|rank 99).  This version uses 1,000,000 integers, twice.      |");
+   puts("\t|-------------------------------------------------------------|\n");
+ 
+-  printf("\t\t\tOPERM5 test for file \n", filename);
++  printf("%s \t\t\tOPERM5 test for file \n", filename);
+   puts("\t\t  (For samples of 1,000,000 consecutive 5-tuples)\n");
+ 
+   infile=fopen("operm5.cov", "r");
+ 
+   for(i=0; i<60; ++i){
+     for(j=i; j<60; ++j){
+-      fscanf(infile, "%d", &A[i][j]);
++      fscanf(infile, "%lu", &A[i][j]);
+       A[j][i]=A[i][j];
+     }
+   }
+ 
+   for(i=0; i<60; ++i){
+     for(j=i; j<60; ++j){
+-      fscanf(infile, "%d", &B[i][j]);
++      fscanf(infile, "%lu", &B[i][j]);
+       B[j][i]=B[i][j];
+     }
+   }

Added: head/math/diehard/files/patch-cdosum.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-cdosum.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,20 @@
+--- cdosum.c.orig	2019-08-03 10:56:11 UTC
++++ cdosum.c
+@@ -64,7 +64,7 @@ void osum(char *filename)
+     }
+ 
+     pv[i-1]=KStest(p, no_num);
+-    printf("\t\t\t  %d \t\t\t%f\n", i, pv[i-1]);
++    printf("\t\t\t  %lu \t\t\t%f\n", i, pv[i-1]);
+   }
+   uni("close");
+ 
+@@ -75,7 +75,7 @@ void osum(char *filename)
+   tmp=KStest(pv, no_obs);
+   free(pv);
+ 
+-  printf("\t\tp-value for %d kstests on %d kstests:%f\n", no_obs, no_sum, tmp);
++  printf("\t\tp-value for %lu kstests on %lu kstests:%f\n", no_obs, no_sum, tmp);
+ 
+   return;
+ }

Added: head/math/diehard/files/patch-cdpark.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-cdpark.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,36 @@
+--- cdpark.c.orig	2019-08-03 10:37:50 UTC
++++ cdpark.c
+@@ -36,8 +36,8 @@ void park(char *filename)
+   puts("\t|ble, provides input to a KSTEST based on a sample of 10.     |");
+   puts("\t|-------------------------------------------------------------|\n");
+   
+-  printf("\t\tCDPARK: result of %d tests on file %s\n", no_obs, filename);
+-  printf("\t  (Of %d tries, the average no. of successes", no_trials);
++  printf("\t\tCDPARK: result of %lu tests on file %s\n", no_obs, filename);
++  printf("\t  (Of %lu tries, the average no. of successes", no_trials);
+   printf(" should be \n\t   %.1f with sigma=%.1f)\n\n", mu, sigma);
+   printf("\t   No. succeses\t\tz-score\t\tp-value\n");
+ 
+@@ -79,7 +79,7 @@ void park(char *filename)
+     z=(no_succ-mu)/sigma;
+     p[i-1]=1-Phi(z);
+ 
+-    printf("\t\t%d\t\t% .4f\t\t%f\n", no_succ, z, p[i-1]);
++    printf("\t\t%lu\t\t% .4f\t\t%f\n", no_succ, z, p[i-1]);
+   }
+   uni("close");
+ 
+@@ -88,11 +88,11 @@ void park(char *filename)
+   mean=(real)sum/no_obs;
+   var=(real)ss/no_obs-mean*mean;
+ 
+-  printf("\t  Square side=%d, avg. no. parked=%.2f", side, mean);
++  printf("\t  Square side=%lu, avg. no. parked=%.2f", side, mean);
+   printf(" sample std.=%.2f\n", sqrt(var)); 
+  
+   pvalue=KStest(p, no_obs);
+-  printf("\t     p-value of the KSTEST for those %d", no_obs); 
++  printf("\t     p-value of the KSTEST for those %lu", no_obs); 
+   printf(" p-values: %f\n\n", pvalue);
+     
+   return;

Added: head/math/diehard/files/patch-cnt1s
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-cnt1s	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,17 @@
+--- cnt1s.c.orig	2019-08-03 10:00:05 UTC
++++ cnt1s.c
+@@ -1,4 +1,5 @@
+ #include "header.h"
++#include <string.h>
+ 
+ typedef enum {A,B,C,D,E} letters;
+ 
+@@ -192,7 +193,7 @@ void cnt1s(char *filename, char *test)
+ 
+   cnt_ttl(filename, test);
+       
+-  printf("\t  (Degrees of freedom: 5^4-5^3=2500; sample size: %d)\n\n", no_wds);
++  printf("\t  (Degrees of freedom: 5^4-5^3=2500; sample size: %lu)\n\n", no_wds);
+   printf("\t%s\tchisquare\tz-score\t\tp-value\n", s);
+ 
+   do{

Added: head/math/diehard/files/patch-craptest.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-craptest.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,20 @@
+--- craptest.c.orig	2019-08-03 10:04:26 UTC
++++ craptest.c
+@@ -77,7 +77,7 @@ void craptest(char *filename)
+ 
+   printf("\t\tRESULTS OF CRAPS TEST FOR %s \n", filename);
+   printf("\tNo. of wins:  Observed\tExpected\n");
+-  printf("\t                 %d        %f\n", no_win, mean);
++  printf("\t                 %lu       %f\n", no_win, mean);
+ 
+   pvalue_w=1-Phi(t);
+   printf("\t\tz-score=%6.3f, pvalue=%7.5f\n", t, pvalue_w);
+@@ -93,7 +93,7 @@ void craptest(char *filename)
+     mean=no_games*Ef[i];
+     t=(f[i]-mean)*(f[i]-mean)/mean;
+     sum+=t;     
+-    printf("\t%d\t%d\t\t%.1f",i+1, f[i], mean);
++    printf("\t%lu\t%lu\t\t%.1f",i+1, f[i], mean);
+     printf("\t\t%.3f\t\t%.3f\n", t, sum);
+   }
+ 

Added: head/math/diehard/files/patch-d3sphere.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/math/diehard/files/patch-d3sphere.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -0,0 +1,20 @@
+--- d3sphere.c.orig	2019-08-03 10:59:28 UTC
++++ d3sphere.c
+@@ -61,7 +61,7 @@ void sphere(char *filename)
+ 
+       r3=dmin*sqrt(dmin);
+       p[i-1]=1-exp(-MIN(r3/30., 20));
+-      printf("\t\t   %d\t\t%.3f\t\t%f\n", i, r3, p[i-1]);
++      printf("\t\t   %lu\t\t%.3f\t\t%f\n", i, r3, p[i-1]);
+   }
+   uni("close");
+ 
+@@ -69,7 +69,7 @@ void sphere(char *filename)
+   
+   puts("\t--------------------------------------------------------------");
+   pvalue=KStest(p,no_obs);
+-  printf("\t\tp-value for KS test on those %d p-values: %f", no_obs, pvalue);
++  printf("\t\tp-value for KS test on those %lu p-values: %f", no_obs, pvalue);
+   puts("\n");
+     
+   free(p);

Modified: head/math/diehard/files/patch-diehard.c
==============================================================================
--- head/math/diehard/files/patch-diehard.c	Sun Sep  1 16:46:18 2019	(r510709)
+++ head/math/diehard/files/patch-diehard.c	Sun Sep  1 17:28:00 2019	(r510710)
@@ -1,5 +1,14 @@
---- diehard.c.orig	1998-04-02 15:29:40 UTC
+--- diehard.c.orig	2019-09-01 17:00:11 UTC
 +++ diehard.c
+@@ -117,7 +117,7 @@ void diehard()
+
+   ungetc(c, stdin);
+
+-  gets(fn);
++  fgets(fn,100,stdin);
+ 
+   puts("\n\t\tHERE ARE YOUR CHOICES:\n");
+   puts("\t\t1   Birthday Spacings");
 @@ -153,5 +153,5 @@ main()
  {
    diehard();


More information about the svn-ports-all mailing list