diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2007-09-05 22:59:37 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2007-09-05 22:59:37 +0000 |
commit | fc2b14e35224bd4d192a90814ab97584f1a9d2b6 (patch) | |
tree | c8e84a02bcd80e943019f5d5b15f10c1661f5b56 /ACE/tests/Test_Output.cpp | |
parent | e9051ece517e0f6a98cac1baa114b0a0807660fd (diff) | |
download | ATCD-fc2b14e35224bd4d192a90814ab97584f1a9d2b6.tar.gz |
ChangeLogTag:Wed Sep 5 23:40:15 UTC 2007 Ossama Othman <ossama_othman at symantec dot com>
Diffstat (limited to 'ACE/tests/Test_Output.cpp')
-rw-r--r-- | ACE/tests/Test_Output.cpp | 44 |
1 files changed, 11 insertions, 33 deletions
diff --git a/ACE/tests/Test_Output.cpp b/ACE/tests/Test_Output.cpp index 55dd73f7887..fbeede7a8cc 100644 --- a/ACE/tests/Test_Output.cpp +++ b/ACE/tests/Test_Output.cpp @@ -83,7 +83,7 @@ ACE_Test_Output::set_output (const ACE_TCHAR *filename, int append) ACE_LOG_MSG->msg_ostream (&cout); #else - ACE_TCHAR temp[MAXPATHLEN]; + ACE_TCHAR temp[MAXPATHLEN + 1] = { 0 }; // Ignore the error value since the directory may already exist. const ACE_TCHAR *test_dir; @@ -91,13 +91,15 @@ ACE_Test_Output::set_output (const ACE_TCHAR *filename, int append) # if defined (ACE_WIN32) || !defined (ACE_USES_WCHAR) test_dir = ACE_OS::getenv (ACE_TEXT ("ACE_TEST_DIR")); # else - ACE_TCHAR tempenv[MAXPATHLEN]; - char *test_dir_n = ACE_OS::getenv ("ACE_TEST_DIR"); + ACE_TCHAR tempenv[MAXPATHLEN + 1] = { 0 }; + char const * const test_dir_n = ACE_OS::getenv ("ACE_TEST_DIR"); if (test_dir_n == 0) test_dir = 0; else { - ACE_OS::strcpy (tempenv, ACE_TEXT_CHAR_TO_TCHAR (test_dir_n)); + ACE_OS::strncpy (tempenv, + ACE_TEXT_CHAR_TO_TCHAR (test_dir_n), + MAXPATHLEN); test_dir = tempenv; } # endif /* ACE_WIN32 || !ACE_USES_WCHAR */ @@ -109,11 +111,11 @@ ACE_Test_Output::set_output (const ACE_TCHAR *filename, int append) // This could be done with ACE_OS::sprintf() but it requires different // format strings for wide-char POSIX vs. narrow-char POSIX and Windows. // Easier to keep straight like this. - ACE_OS_String::strcpy (temp, test_dir); - ACE_OS_String::strcat (temp, ACE_LOG_DIRECTORY); - ACE_OS_String::strcat - (temp, ACE::basename (filename, ACE_DIRECTORY_SEPARATOR_CHAR)); - ACE_OS_String::strcat (temp, ACE_LOG_FILE_EXT_NAME); + ACE_OS::strncpy (temp, test_dir, MAXPATHLEN); + ACE_OS::strcat (temp, ACE_LOG_DIRECTORY); + ACE_OS::strcat (temp, + ACE::basename (filename, ACE_DIRECTORY_SEPARATOR_CHAR)); + ACE_OS::strcat (temp, ACE_LOG_FILE_EXT_NAME); #if defined (VXWORKS) // This is the only way I could figure out to avoid a console @@ -220,27 +222,3 @@ ACE_Test_Output::close_singleton (void) delete ACE_Test_Output::instance_; ACE_Test_Output::instance_ = 0; } - -void -randomize (int array[], size_t size) -{ - size_t i; - - for (i = 0; i < size; i++) - array [i] = static_cast <int> (i); - - // See with a fixed number so that we can produce "repeatable" - // random numbers. - ACE_OS::srand (0); - - // Generate an array of random numbers from 0 .. size - 1. - - for (i = 0; i < size; i++) - { - size_t index = ACE_OS::rand() % size--; - int temp = array [index]; - array [index] = array [size]; - array [size] = temp; - } -} - |