summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1998-05-02 06:00:42 +0000
committerRichard M. Stallman <rms@gnu.org>1998-05-02 06:00:42 +0000
commit8a7777fc1a5625685fab4ddbc5f6031ab591efb3 (patch)
treeaad55a65446090570f3b90524cdec072b547d0f5 /src/fileio.c
parentba88b3223836b75b75c3906618de59f3b409e920 (diff)
downloademacs-8a7777fc1a5625685fab4ddbc5f6031ab591efb3.tar.gz
(Fmake_temp_name): Improve randomness of generated file names.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/fileio.c b/src/fileio.c
index b1ad711555d..16350504669 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -862,12 +862,17 @@ PREFIX should be an absolute file name.")
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 @@ PREFIX should be an absolute file name.")
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 */