aboutsummaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-05-22 17:15:40 +0000
committerMike Buland <eichlan@xagasoft.com>2012-05-22 17:15:40 +0000
commitce793e31f387c0715fa5b50c20e06510cc3e95ff (patch)
tree5b15972bdcbe7a26933e8158f52b29fb014dc421 /src/stable
parent2295579eb790d6eff6e54e84c01da6de10809a71 (diff)
downloadlibbu++-ce793e31f387c0715fa5b50c20e06510cc3e95ff.tar.gz
libbu++-ce793e31f387c0715fa5b50c20e06510cc3e95ff.tar.bz2
libbu++-ce793e31f387c0715fa5b50c20e06510cc3e95ff.tar.xz
libbu++-ce793e31f387c0715fa5b50c20e06510cc3e95ff.zip
Moved random to stable, just needs some minor tweaks. But it's already in use
in a couple of core components, including in tempFile name generation.
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
11 files changed, 4 insertions, 4 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