summaryrefslogtreecommitdiffstats
path: root/src/linguist/shared/ioutils.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-09-06 21:50:09 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-20 14:34:56 +0200
commitbf4fc2e5fca65204665ef2ad23a9792b72f727ab (patch)
treea6c323e8804181324d6cda3ddc806ad66d3bd080 /src/linguist/shared/ioutils.cpp
parente69551f23e47632d517f7ec7d6efc25580df8df0 (diff)
update qmake evaluator to newest version from qt creator
Change-Id: I66ec46dd87f922094f6937b50cc40e02ef08cc86 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Diffstat (limited to 'src/linguist/shared/ioutils.cpp')
-rw-r--r--src/linguist/shared/ioutils.cpp71
1 files changed, 39 insertions, 32 deletions
diff --git a/src/linguist/shared/ioutils.cpp b/src/linguist/shared/ioutils.cpp
index 7f7a69401..4038b8520 100644
--- a/src/linguist/shared/ioutils.cpp
+++ b/src/linguist/shared/ioutils.cpp
@@ -41,8 +41,8 @@
#include "ioutils.h"
-#include <QtCore/QDir>
-#include <QtCore/QFile>
+#include <qdir.h>
+#include <qfile.h>
#ifdef Q_OS_WIN
# include <windows.h>
@@ -52,7 +52,9 @@
# include <unistd.h>
#endif
-using namespace ProFileEvaluatorInternal;
+QT_BEGIN_NAMESPACE
+
+using namespace QMakeInternal;
IoUtils::FileType IoUtils::fileType(const QString &fileName)
{
@@ -100,44 +102,53 @@ QString IoUtils::resolvePath(const QString &baseDir, const QString &fileName)
return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName);
}
-#ifdef QT_BOOTSTRAPPED
-inline static bool isSpecialChar(ushort c)
+inline static
+bool hasSpecialChars(const QString &arg, const uchar (&iqm)[16])
+{
+ for (int x = arg.length() - 1; x >= 0; --x) {
+ ushort c = arg.unicode()[x].unicode();
+ if ((c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7))))
+ return true;
+ }
+ return false;
+}
+
+QString IoUtils::shellQuoteUnix(const QString &arg)
{
// Chars that should be quoted (TM). This includes:
-#ifdef Q_OS_WIN
- // - control chars & space
- // - the shell meta chars "&()<>^|
- // - the potential separators ,;=
- static const uchar iqm[] = {
- 0xff, 0xff, 0xff, 0xff, 0x45, 0x13, 0x00, 0x78,
- 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10
- };
-#else
static const uchar iqm[] = {
0xff, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0xd8,
0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78
}; // 0-32 \'"$`<>|;&(){}*?#!~[]
-#endif
- return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7)));
-}
+ if (!arg.length())
+ return QString::fromLatin1("\"\"");
-inline static bool hasSpecialChars(const QString &arg)
-{
- for (int x = arg.length() - 1; x >= 0; --x)
- if (isSpecialChar(arg.unicode()[x].unicode()))
- return true;
- return false;
+ QString ret(arg);
+ if (hasSpecialChars(ret, iqm)) {
+ ret.replace(QLatin1Char('\''), QLatin1String("'\\''"));
+ ret.prepend(QLatin1Char('\''));
+ ret.append(QLatin1Char('\''));
+ }
+ return ret;
}
-QString IoUtils::shellQuote(const QString &arg)
+QString IoUtils::shellQuoteWin(const QString &arg)
{
+ // Chars that should be quoted (TM). This includes:
+ // - control chars & space
+ // - the shell meta chars "&()<>^|
+ // - the potential separators ,;=
+ static const uchar iqm[] = {
+ 0xff, 0xff, 0xff, 0xff, 0x45, 0x13, 0x00, 0x78,
+ 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10
+ };
+
if (!arg.length())
return QString::fromLatin1("\"\"");
QString ret(arg);
- if (hasSpecialChars(ret)) {
-#ifdef Q_OS_WIN
+ if (hasSpecialChars(ret, iqm)) {
// Quotes are escaped and their preceding backslashes are doubled.
// It's impossible to escape anything inside a quoted string on cmd
// level, so the outer quoting must be "suspended".
@@ -150,12 +161,8 @@ QString IoUtils::shellQuote(const QString &arg)
--i;
ret.insert(i, QLatin1Char('"'));
ret.prepend(QLatin1Char('"'));
-#else // Q_OS_WIN
- ret.replace(QLatin1Char('\''), QLatin1String("'\\''"));
- ret.prepend(QLatin1Char('\''));
- ret.append(QLatin1Char('\''));
-#endif // Q_OS_WIN
}
return ret;
}
-#endif
+
+QT_END_NAMESPACE