summaryrefslogtreecommitdiffstats
path: root/Source/cmStringCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-05-17 14:07:26 (GMT)
committerBrad King <brad.king@kitware.com>2011-05-17 14:07:26 (GMT)
commite1b0a11dd471e1593ade56897185a9d4dd2e0857 (patch)
treeb0f1efae3ec53531386f148ce75098e40d2b1e96 /Source/cmStringCommand.cxx
parenta77dfb6d64b24737167e4a0312fb842544f27961 (diff)
downloadCMake-e1b0a11dd471e1593ade56897185a9d4dd2e0857.zip
CMake-e1b0a11dd471e1593ade56897185a9d4dd2e0857.tar.gz
CMake-e1b0a11dd471e1593ade56897185a9d4dd2e0857.tar.bz2
Improve string(RANDOM) default seed
The naive time(0) seed is unique only within one second. Instead try to read a real source of entropy and otherwise fall back to a combination of the process id and high-resolution time.
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r--Source/cmStringCommand.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 19d2369..e3bf08f 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -770,7 +770,7 @@ bool cmStringCommand
static bool seeded = false;
bool force_seed = false;
- int seed = (int) time(NULL);
+ int seed = 0;
int length = 5;
const char cmStringCommandDefaultAlphabet[] = "qwertyuiopasdfghjklzxcvbnm"
"QWERTYUIOPASDFGHJKLZXCVBNM"
@@ -825,7 +825,7 @@ bool cmStringCommand
if (!seeded || force_seed)
{
seeded = true;
- srand(seed);
+ srand(force_seed? seed : cmSystemTools::RandomSeed());
}
const char* alphaPtr = alphabet.c_str();