aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/stable/file.cpp8
-rw-r--r--src/stable/random.cpp (renamed from src/experimental/random.cpp)0
-rw-r--r--src/stable/random.h (renamed from src/experimental/random.h)0
-rw-r--r--src/stable/randombase.cpp (renamed from src/experimental/randombase.cpp)0
-rw-r--r--src/stable/randombase.h (renamed from src/experimental/randombase.h)0
-rw-r--r--src/stable/randombasic.cpp (renamed from src/experimental/randombasic.cpp)0
-rw-r--r--src/stable/randombasic.h (renamed from src/experimental/randombasic.h)0
-rw-r--r--src/stable/randomcmwc.cpp (renamed from src/experimental/randomcmwc.cpp)0
-rw-r--r--src/stable/randomcmwc.h (renamed from src/experimental/randomcmwc.h)0
-rw-r--r--src/stable/randomsystem.cpp (renamed from src/experimental/randomsystem.cpp)0
-rw-r--r--src/stable/randomsystem.h (renamed from src/experimental/randomsystem.h)0
-rw-r--r--src/unstable/bitstring.cpp10
12 files changed, 7 insertions, 11 deletions
diff --git a/src/stable/file.cpp b/src/stable/file.cpp
index 8d10596..81b476d 100644
--- a/src/stable/file.cpp
+++ b/src/stable/file.cpp
@@ -12,6 +12,7 @@
12#include <fcntl.h> 12#include <fcntl.h>
13#include <unistd.h> 13#include <unistd.h>
14#include <time.h> 14#include <time.h>
15#include "bu/random.h"
15 16
16#include "bu/config.h" 17#include "bu/config.h"
17 18
@@ -190,7 +191,6 @@ void Bu::File::setBlocking( bool bBlocking )
190Bu::File Bu::File::tempFile( Bu::String &sName ) 191Bu::File Bu::File::tempFile( Bu::String &sName )
191{ 192{
192 uint32_t iX; 193 uint32_t iX;
193 iX = time( NULL ) + getpid();
194 int iXes; 194 int iXes;
195 for( iXes = sName.getSize()-1; iXes >= 0; iXes-- ) 195 for( iXes = sName.getSize()-1; iXes >= 0; iXes-- )
196 { 196 {
@@ -200,11 +200,11 @@ Bu::File Bu::File::tempFile( Bu::String &sName )
200 iXes++; 200 iXes++;
201 if( iXes == sName.getSize() ) 201 if( iXes == sName.getSize() )
202 throw Bu::ExceptionBase("Invalid temporary filename template."); 202 throw Bu::ExceptionBase("Invalid temporary filename template.");
203 for( int iter = 0; iter < 100; iter++ ) 203 for( int iter = 0; iter < 1000; iter++ )
204 { 204 {
205 for( int j = iXes; j < sName.getSize(); j++ ) 205 for( int j = iXes; j < sName.getSize(); j++ )
206 { 206 {
207 iX = (1103515245 * iX + 12345); 207 uint32_t iX = Bu::Random::rand();
208 sName[j] = ('A'+(iX%26)) | ((iX&0x1000)?(0x20):(0)); 208 sName[j] = ('A'+(iX%26)) | ((iX&0x1000)?(0x20):(0));
209 } 209 }
210 210
@@ -214,7 +214,7 @@ Bu::File Bu::File::tempFile( Bu::String &sName )
214 |Bu::File::Create|Bu::File::Exclusive ); 214 |Bu::File::Create|Bu::File::Exclusive );
215 } catch(...) { } 215 } catch(...) { }
216 } 216 }
217 throw Bu::FileException("Failed to create unique temporary file after 100" 217 throw Bu::FileException("Failed to create unique temporary file after 1000"
218 " iterations."); 218 " iterations.");
219} 219}
220 220
diff --git a/src/experimental/random.cpp b/src/stable/random.cpp
index 725948a..725948a 100644
--- a/src/experimental/random.cpp
+++ b/src/stable/random.cpp
diff --git a/src/experimental/random.h b/src/stable/random.h
index ba26f21..ba26f21 100644
--- a/src/experimental/random.h
+++ b/src/stable/random.h
diff --git a/src/experimental/randombase.cpp b/src/stable/randombase.cpp
index 6514df3..6514df3 100644
--- a/src/experimental/randombase.cpp
+++ b/src/stable/randombase.cpp
diff --git a/src/experimental/randombase.h b/src/stable/randombase.h
index aff1d45..aff1d45 100644
--- a/src/experimental/randombase.h
+++ b/src/stable/randombase.h
diff --git a/src/experimental/randombasic.cpp b/src/stable/randombasic.cpp
index ac591be..ac591be 100644
--- a/src/experimental/randombasic.cpp
+++ b/src/stable/randombasic.cpp
diff --git a/src/experimental/randombasic.h b/src/stable/randombasic.h
index a53e16f..a53e16f 100644
--- a/src/experimental/randombasic.h
+++ b/src/stable/randombasic.h
diff --git a/src/experimental/randomcmwc.cpp b/src/stable/randomcmwc.cpp
index a4e807e..a4e807e 100644
--- a/src/experimental/randomcmwc.cpp
+++ b/src/stable/randomcmwc.cpp
diff --git a/src/experimental/randomcmwc.h b/src/stable/randomcmwc.h
index 747eb6a..747eb6a 100644
--- a/src/experimental/randomcmwc.h
+++ b/src/stable/randomcmwc.h
diff --git a/src/experimental/randomsystem.cpp b/src/stable/randomsystem.cpp
index 0501587..0501587 100644
--- a/src/experimental/randomsystem.cpp
+++ b/src/stable/randomsystem.cpp
diff --git a/src/experimental/randomsystem.h b/src/stable/randomsystem.h
index 7106d58..7106d58 100644
--- a/src/experimental/randomsystem.h
+++ b/src/stable/randomsystem.h
diff --git a/src/unstable/bitstring.cpp b/src/unstable/bitstring.cpp
index c32240c..9559aad 100644
--- a/src/unstable/bitstring.cpp
+++ b/src/unstable/bitstring.cpp
@@ -6,16 +6,12 @@
6 */ 6 */
7 7
8#include "bu/bitstring.h" 8#include "bu/bitstring.h"
9#include <stdlib.h> 9#include "bu/random.h"
10#include <stdio.h> 10#include <stdio.h>
11#include <string.h> 11#include <string.h>
12 12
13#include "bu/exceptionbase.h" 13#include "bu/exceptionbase.h"
14 14
15#ifdef _WIN32
16#define random() rand()
17#endif
18
19#define bitsToBytes( iBits ) (((iBits/8)+((iBits%8)?(1):(0)))); 15#define bitsToBytes( iBits ) (((iBits/8)+((iBits%8)?(1):(0))));
20 16
21Bu::BitString::BitString() 17Bu::BitString::BitString()
@@ -51,7 +47,7 @@ Bu::BitString::BitString( long iNewBits, bool bFillRandomly )
51 // I'll just use the low order byte) 47 // I'll just use the low order byte)
52 for( j = 0; j < iBytes; j++ ) 48 for( j = 0; j < iBytes; j++ )
53 { 49 {
54 caData[j] = (unsigned char)(random() & 0xFF); 50 caData[j] = (unsigned char)(Bu::Random::rand() & 0xFF);
55 } 51 }
56 } 52 }
57 else 53 else
@@ -413,7 +409,7 @@ void Bu::BitString::randomize()
413 { 409 {
414 for( int j = 0; j < iBytes; j++ ) 410 for( int j = 0; j < iBytes; j++ )
415 { 411 {
416 caData[j] = (unsigned char)(random() & 0xFF); 412 caData[j] = (unsigned char)(Bu::Random::rand() & 0xFF);
417 } 413 }
418 fixup(); 414 fixup();
419 } 415 }