Make sure to generate qmake friendly file names

According to Ossi the only safe characters in a path for qmake are
alphanumerical, underscore, dot and dash.

Task-number: QTCREATORBUG-10980
Change-Id: Ibacbfeb7f04f1f0524093f1d8fce637ea4ae6fd6
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Tobias Hunger
2013-12-09 12:56:24 +01:00
parent b684f0afb5
commit 2d4cfc90fc
5 changed files with 33 additions and 6 deletions

View File

@@ -236,6 +236,25 @@ QString FileUtils::fileSystemFriendlyName(const QString &name)
return result;
}
int FileUtils::indexOfQmakeUnfriendly(const QString &name, int startpos)
{
static QRegExp checkRegExp(QLatin1String("[^a-zA-Z0-9_.-]"));
return checkRegExp.indexIn(name, startpos);
}
QString FileUtils::qmakeFriendlyName(const QString &name)
{
QString result = name;
// Remove characters that might trip up a build system (especially qmake):
int pos = indexOfQmakeUnfriendly(result);
while (pos >= 0) {
result[pos] = QLatin1Char('_');
pos = indexOfQmakeUnfriendly(result, pos);
}
return fileSystemFriendlyName(result);
}
bool FileUtils::makeWritable(const FileName &path)
{
const QString fileName = path.toString();