diff options
author | Björn Gustavsson <[email protected]> | 2015-12-04 12:15:40 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-12-11 14:37:46 +0100 |
commit | 80757f9491c72ee262a5910e0b3b02e95b1e5f2a (patch) | |
tree | 1019a6da73ac28571a0b51727ed6fa33daf11522 /lib/syntax_tools | |
parent | dee396ffd32dcd68c47cab983c75ba32f921b9db (diff) | |
download | otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.tar.gz otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.tar.bz2 otp-80757f9491c72ee262a5910e0b3b02e95b1e5f2a.zip |
Use 'rand' instead of the obsolete 'random' module
In most cases, we don't have to seed the random number generator,
as the rand:uniform/1 takes care about that itself.
Diffstat (limited to 'lib/syntax_tools')
-rw-r--r-- | lib/syntax_tools/src/erl_syntax_lib.erl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/syntax_tools/src/erl_syntax_lib.erl b/lib/syntax_tools/src/erl_syntax_lib.erl index 5b5b18d15b..58c4cc5244 100644 --- a/lib/syntax_tools/src/erl_syntax_lib.erl +++ b/lib/syntax_tools/src/erl_syntax_lib.erl @@ -359,9 +359,9 @@ new_variable_name(S) -> %% within a reasonably small range relative to the number of elements in %% the set. %% -%% This function uses the module `random' to generate new +%% This function uses the module `rand' to generate new %% keys. The seed it uses may be initialized by calling -%% `random:seed/0' or `random:seed/3' before this +%% `rand:seed/1' or `rand:seed/2' before this %% function is first called. %% %% @see new_variable_name/1 @@ -404,7 +404,13 @@ start_range(S) -> %% order, but (pseudo-)randomly distributed over the range. generate(_Key, Range) -> - random:uniform(Range). % works well + _ = case rand:export_seed() of + undefined -> + rand:seed(exsplus, {753,8,73}); + _ -> + ok + end, + rand:uniform(Range). % works well %% ===================================================================== |