diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2009-07-17 04:51:11 (GMT) |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2009-07-17 04:51:11 (GMT) |
commit | cf75d5b1a62badd5ae588aeed6b4f98ba987ca3e (patch) | |
tree | 1b59670f8a1b5a95cb170cb8ec66c309d536d1fc /src | |
parent | dd2bda5cb7b08a84c36d49f946059885fbc764c9 (diff) | |
download | Qt-cf75d5b1a62badd5ae588aeed6b4f98ba987ca3e.zip Qt-cf75d5b1a62badd5ae588aeed6b4f98ba987ca3e.tar.gz Qt-cf75d5b1a62badd5ae588aeed6b4f98ba987ca3e.tar.bz2 |
Fixed failure of badxml selftest on Windows.
Don't try to write to files with special characters in the name.
Also fix bizarre indent.
Diffstat (limited to 'src')
-rw-r--r-- | src/testlib/qtestfilelogger.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/testlib/qtestfilelogger.cpp b/src/testlib/qtestfilelogger.cpp index 0c146b4..a717058 100644 --- a/src/testlib/qtestfilelogger.cpp +++ b/src/testlib/qtestfilelogger.cpp @@ -72,15 +72,24 @@ void QTestFileLogger::init() QTest::qt_snprintf(filename, sizeof(filename), "%s.log", QTestResult::currentTestObjectName()); - #if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE) - if (::fopen_s(&QTest::stream, filename, "wt")) { - #else - QTest::stream = ::fopen(filename, "wt"); - if (!QTest::stream) { - #endif - printf("Unable to open file for simple logging: %s", filename); - ::exit(1); + // Keep filenames simple + for (int i = 0; i < sizeof(filename) && filename[i]; ++i) { + char& c = filename[i]; + if (!(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '-' + || c == '.')) { + c = '_'; } + } + +#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE) + if (::fopen_s(&QTest::stream, filename, "wt")) { +#else + QTest::stream = ::fopen(filename, "wt"); + if (!QTest::stream) { +#endif + printf("Unable to open file for simple logging: %s", filename); + ::exit(1); + } } void QTestFileLogger::flush(const char *msg) |