httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@hyperreal.org
Subject cvs commit: apache-1.3/src/modules/standard mod_rewrite.c
Date Fri, 26 Nov 1999 19:31:23 GMT
gstein      99/11/26 11:31:23

  Modified:    src/modules/standard mod_rewrite.c
  Log:
  The floating point rounding performed by the ap_snprintf() was throwing
  off the distribution of the random value. The much simpler forms works
  just as well, and provides a normal distribution.
  
  Revision  Changes    Path
  1.151     +1 -9      apache-1.3/src/modules/standard/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v
  retrieving revision 1.150
  retrieving revision 1.151
  diff -u -r1.150 -r1.151
  --- mod_rewrite.c	1999/10/27 09:13:17	1.150
  +++ mod_rewrite.c	1999/11/26 19:31:21	1.151
  @@ -3047,16 +3047,8 @@
   
   static int rewrite_rand(int l, int h)
   {
  -    int i;
  -    char buf[50];
  -
       rewrite_rand_init();
  -    ap_snprintf(buf, sizeof(buf), "%.0f", 
  -                (((double)(rand()%RAND_MAX)/RAND_MAX)*(h-l)));
  -    i = atoi(buf)+1;
  -    if (i < l) i = l;
  -    if (i > h) i = h;
  -    return i;
  +    return rand() % (h - l + 1) + l;
   }
   
   static char *select_random_value_part(request_rec *r, char *value)
  
  
  

Mime
View raw message