summaryrefslogtreecommitdiff
path: root/src/testlib/qtestfilelogger.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2009-07-17 14:51:11 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2009-07-17 14:51:11 +1000
commitcf75d5b1a62badd5ae588aeed6b4f98ba987ca3e (patch)
tree1b59670f8a1b5a95cb170cb8ec66c309d536d1fc /src/testlib/qtestfilelogger.cpp
parentdd2bda5cb7b08a84c36d49f946059885fbc764c9 (diff)
downloadqt4-tools-cf75d5b1a62badd5ae588aeed6b4f98ba987ca3e.tar.gz
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/testlib/qtestfilelogger.cpp')
-rw-r--r--src/testlib/qtestfilelogger.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/testlib/qtestfilelogger.cpp b/src/testlib/qtestfilelogger.cpp
index 0c146b42c6..a717058b19 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)