changeset 21900:fd8b439fd6c9

(Fmake_temp_name): Improve randomness of generated file names.
author Richard M. Stallman <rms@gnu.org>
date Sat, 02 May 1998 06:00:42 +0000
parents c2e75fe68665
children 1b46a79d86e3
files src/fileio.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Sat May 02 05:39:14 1998 +0000
+++ b/src/fileio.c	Sat May 02 06:00:42 1998 +0000
@@ -862,12 +862,17 @@
   while (1)
     {
       struct stat ignored;
-      unsigned num = make_temp_name_count++;
+      unsigned num = make_temp_name_count;
 
       p[0] = make_temp_name_tbl[num & 63], num >>= 6;
       p[1] = make_temp_name_tbl[num & 63], num >>= 6;
       p[2] = make_temp_name_tbl[num & 63], num >>= 6;
 
+      /* Poor man's congruential RN generator.  Replace with
+         ++make_temp_name_count for debugging.  */
+      make_temp_name_count += 25229;
+      make_temp_name_count %= 225307;
+
       if (stat (data, &ignored) < 0)
 	{
 	  /* We want to return only if errno is ENOENT.  */
@@ -878,9 +883,9 @@
 	       can do.  The alternatives are to return nil, which is
 	       as bad as (and in many cases worse than) throwing the
 	       error, or to ignore the error, which will likely result
-	       in looping through 262144 stat's, which is not only
-	       SLOW, but also useless since it will fallback to the
-	       errow below, anyway.  */
+	       in looping through 225307 stat's, which is not only
+	       dog-slow, but also useless since it will fallback to
+	       the errow below, anyway.  */
 	    report_file_error ("Cannot create temporary name for prefix `%s'",
 			       Fcons (prefix, Qnil));
 	  /* not reached */