@@ -31,13 +31,14 @@ pragma Ada_2012;
3131
3232with Ada.Calendar.Time_Zones ;
3333with Ada.Integer_Text_IO ;
34- with Ada.Numerics.Discrete_Random ;
3534with Ada.Numerics.Long_Elementary_Functions ;
3635with Ada.Streams.Stream_IO ;
3736with Ada.Strings.Fixed ;
3837with Ada.Strings.Maps.Constants ;
3938with Ada.Text_IO ;
4039
40+ with GNATCOLL.Random ;
41+
4142pragma Warnings (Off);
4243with Ada.Strings.Unbounded.Aux ;
4344pragma Warnings (On);
@@ -50,7 +51,8 @@ package body AWS.Utils is
5051
5152 use type Ada.Directories.File_Kind;
5253
53- package Integer_Random is new Numerics.Discrete_Random (Random_Integer);
54+ function Integer_Random is new
55+ GNATCOLL.Random.Random_Range (Random_Integer);
5456
5557 function Local_To_GMT (DT : Calendar.Time) return Calendar.Time
5658 with Inline ;
@@ -67,14 +69,6 @@ package body AWS.Utils is
6769 -- Returns True if the string pointed to by Str and terminating to Last
6870 -- is well-formed UTF-8.
6971
70- protected Shared_Random is
71- function Generate return Random_Integer;
72- procedure Reset ;
73- procedure Reset (Seed : Integer);
74- private
75- Random_Generator : Integer_Random.Generator;
76- end Shared_Random ;
77-
7872 -- -------------------
7973 -- Append_With_Sep --
8074 -- -------------------
@@ -1004,35 +998,16 @@ package body AWS.Utils is
1004998
1005999 function Random return Random_Integer is
10061000 begin
1007- return Shared_Random.Generate ;
1001+ return Integer_Random ;
10081002 end Random ;
10091003
1010- -- ----------------
1011- -- Random_Reset --
1012- -- ----------------
1013-
1014- procedure Random_Reset (Seed : Integer) is
1015- begin
1016- Shared_Random.Reset (Seed);
1017- end Random_Reset ;
1018-
10191004 -- -----------------
10201005 -- Random_String --
10211006 -- -----------------
10221007
10231008 procedure Random_String (Item : out String) is
1024- Chars : constant String
1025- := " 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
1026- Rand : Random_Integer := 0 ;
10271009 begin
1028- for Elem of Item loop
1029- if Rand = 0 then
1030- Rand := Random;
1031- end if ;
1032-
1033- Elem := Chars (Integer (Rand rem Chars'Length) + 1 );
1034- Rand := Rand / Chars'Length;
1035- end loop ;
1010+ GNATCOLL.Random.Random_Alphanumerical_String (Item);
10361011 end Random_String ;
10371012
10381013 function Random_String (Length : Natural) return String is
@@ -1131,37 +1106,6 @@ package body AWS.Utils is
11311106
11321107 end Semaphore ;
11331108
1134- -- -----------------
1135- -- Shared_Random --
1136- -- -----------------
1137-
1138- protected body Shared_Random is
1139-
1140- -- ------------
1141- -- Generate --
1142- -- ------------
1143-
1144- function Generate return Random_Integer is
1145- begin
1146- return Integer_Random.Random (Random_Generator);
1147- end Generate ;
1148-
1149- -- ---------
1150- -- Reset --
1151- -- ---------
1152-
1153- procedure Reset is
1154- begin
1155- Integer_Random.Reset (Random_Generator);
1156- end Reset ;
1157-
1158- procedure Reset (Seed : Integer) is
1159- begin
1160- Integer_Random.Reset (Random_Generator, Seed);
1161- end Reset ;
1162-
1163- end Shared_Random ;
1164-
11651109 -- ---------------------
11661110 -- Significant_Image --
11671111 -- ---------------------
@@ -1317,6 +1261,4 @@ package body AWS.Utils is
13171261 end if ;
13181262 end Time_Zone ;
13191263
1320- begin
1321- Shared_Random.Reset;
13221264end AWS.Utils ;
0 commit comments