You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by "Ralf S. Engelschall" <rs...@apache.org> on 1998/03/03 16:53:34 UTC
cvs commit: apache-1.3/src/modules/standard mod_rewrite.h
rse 98/03/03 07:53:34
Modified: src/modules/standard mod_rewrite.h
Log:
Add own definition for RAND_MAX because some non-strict-POSIX
platforms don't define it although they provide the rand() function :-(
Revision Changes Path
1.41 +4 -0 apache-1.3/src/modules/standard/mod_rewrite.h
Index: mod_rewrite.h
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- mod_rewrite.h 1998/03/02 06:51:20 1.40
+++ mod_rewrite.h 1998/03/03 15:53:33 1.41
@@ -198,6 +198,10 @@
#define YES TRUE
#endif
+#ifndef RAND_MAX
+#define RAND_MAX 32767
+#endif
+
#ifndef LONG_STRING_LEN
#define LONG_STRING_LEN 2048
#endif
Re: cvs commit: apache-1.3/src/modules/standard mod_rewrite.h
Posted by Ben Laurie <be...@algroup.co.uk>.
Ralf S. Engelschall wrote:
>
> rse 98/03/03 07:53:34
>
> Modified: src/modules/standard mod_rewrite.h
> Log:
> Add own definition for RAND_MAX because some non-strict-POSIX
> platforms don't define it although they provide the rand() function :-(
If you are going to do this, you'll need to make sure rand() doesn't
screw you up by giving you something bigger than RAND_MAX. I'd suggest
you change this:
sprintf(buf, "%.0f", (((double)rand()/RAND_MAX)*(h-l)));
to this:
sprintf(buf, "%.0f",
(((double)(rand()%(RAND_MAX+1))/RAND_MAX)*(h-l)));
Hmmm... unfortunately, if RAND_MAX is 2^32-1, then this'll overflow. But
you get my drift!
Cheers,
Ben.
--
Ben Laurie |Phone: +44 (181) 735 0686| Apache Group member
Freelance Consultant |Fax: +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd, |Apache-SSL author http://www.apache-ssl.org/
London, England. |"Apache: TDG" http://www.ora.com/catalog/apache