summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qdatastream.cpp20
-rw-r--r--src/corelib/io/qdatastream.h2
-rw-r--r--src/corelib/io/qdebug.h2
-rw-r--r--src/corelib/io/qfileselector.cpp10
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp21
-rw-r--r--src/corelib/io/qloggingregistry.cpp83
-rw-r--r--src/corelib/io/qloggingregistry_p.h7
-rw-r--r--src/corelib/io/qprocess_unix.cpp4
-rw-r--r--src/corelib/io/qurl.h4
9 files changed, 87 insertions, 66 deletions
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 58e2500057..9044ad74b1 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -772,6 +772,17 @@ int QDataStream::readBlock(char *data, int len)
}
/*!
+ \fn QDataStream &QDataStream::operator>>(std::nullptr &ptr)
+ \since 5.9
+ \overload
+
+ Simulates reading a \c{std::nullptr_t} from the stream into \a ptr and
+ returns a reference to the stream. This function does not actually read
+ anything from the stream, as \c{std::nullptr_t} values are stored as 0
+ bytes.
+*/
+
+/*!
\fn QDataStream &QDataStream::operator>>(quint8 &i)
\overload
@@ -1085,6 +1096,15 @@ int QDataStream::readRawData(char *s, int len)
QDataStream write functions
*****************************************************************************/
+/*!
+ \fn QDataStream &QDataStream::operator<<(std::nullptr ptr)
+ \since 5.9
+ \overload
+
+ Simulates writing a \c{std::nullptr_t}, \a ptr, to the stream and returns a
+ reference to the stream. This function does not actually write anything to
+ the stream, as \c{std::nullptr_t} values are stored as 0 bytes.
+*/
/*!
\fn QDataStream &QDataStream::operator<<(quint8 i)
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 993a20fcd3..0a429d091a 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -153,6 +153,7 @@ public:
QDataStream &operator>>(quint32 &i);
QDataStream &operator>>(qint64 &i);
QDataStream &operator>>(quint64 &i);
+ QDataStream &operator>>(std::nullptr_t &ptr) { ptr = nullptr; return *this; }
QDataStream &operator>>(bool &i);
QDataStream &operator>>(qfloat16 &f);
@@ -168,6 +169,7 @@ public:
QDataStream &operator<<(quint32 i);
QDataStream &operator<<(qint64 i);
QDataStream &operator<<(quint64 i);
+ QDataStream &operator<<(std::nullptr_t) { return *this; }
QDataStream &operator<<(bool i);
QDataStream &operator<<(qfloat16 f);
QDataStream &operator<<(float f);
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index d5f32a6efd..ee8ef679a9 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -139,7 +139,7 @@ public:
inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); }
inline QDebug &operator<<(unsigned short t) { stream->ts << t; return maybeSpace(); }
#ifdef Q_COMPILER_UNICODE_STRINGS
- inline QDebug &operator<<(char16_t t) { return *this << QChar(t); }
+ inline QDebug &operator<<(char16_t t) { return *this << QChar(ushort(t)); }
inline QDebug &operator<<(char32_t t) { putUcs4(t); return maybeSpace(); }
#endif
inline QDebug &operator<<(signed int t) { stream->ts << t; return maybeSpace(); }
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index cb4f5c4b07..9db67f2f9b 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -363,6 +363,7 @@ void QFileSelectorPrivate::updateSelectors()
QStringList QFileSelectorPrivate::platformSelectors()
{
// similar, but not identical to QSysInfo::osType
+ // ### Qt6: remove macOS fallbacks to "mac" and the future compatibility
QStringList ret;
#if defined(Q_OS_WIN)
ret << QStringLiteral("windows");
@@ -380,12 +381,11 @@ QStringList QFileSelectorPrivate::platformSelectors()
# endif
# endif
QString productName = QSysInfo::productType();
-# ifdef Q_OS_MACOS
- if (productName != QLatin1String("osx"))
- ret << QStringLiteral("osx"); // compatibility
-# endif
if (productName != QLatin1String("unknown"))
- ret << productName; // "opensuse", "fedora", "macos", "ios", "android"
+ ret << productName; // "opensuse", "fedora", "osx", "ios", "android"
+# if defined(Q_OS_MACOS)
+ ret << QStringLiteral("macos"); // future compatibility
+# endif
#endif
return ret;
}
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index b8dca93f61..929db259ec 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2017 Intel Corporation.
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
** Contact: https://www.qt.io/licensing/
@@ -607,25 +608,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
if (!createParents)
return false;
- // we need the cleaned path in order to create the parents
- // and we save errno just in case encodeName needs to load codecs
- int savedErrno = errno;
- bool pathChanged;
- {
- QString cleanName = QDir::cleanPath(dirName);
-
- // Check if the cleaned name is the same or not. If we were given a
- // path with resolvable "../" sections, cleanPath will remove them, but
- // this may change the target dir if one of those segments was a
- // symlink. This operation depends on cleanPath's optimization of
- // returning the original string if it didn't modify anything.
- pathChanged = !dirName.isSharedWith(cleanName);
- if (pathChanged)
- nativeName = QFile::encodeName(cleanName);
- }
-
- errno = savedErrno;
- return createDirectoryWithParents(nativeName, pathChanged);
+ return createDirectoryWithParents(nativeName, false);
}
//static
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index ff865dc9a1..47fb1fb6b8 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -186,9 +186,10 @@ void QLoggingRule::parse(const QStringRef &pattern)
*/
void QLoggingSettingsParser::setContent(const QString &content)
{
- QString content_ = content;
- QTextStream stream(&content_, QIODevice::ReadOnly);
- setContent(stream);
+ _rules.clear();
+ const auto lines = content.splitRef(QLatin1Char('\n'));
+ for (const auto &line : lines)
+ parseNextLine(line);
}
/*!
@@ -198,42 +199,50 @@ void QLoggingSettingsParser::setContent(const QString &content)
void QLoggingSettingsParser::setContent(QTextStream &stream)
{
_rules.clear();
- while (!stream.atEnd()) {
- QString line = stream.readLine();
-
- // Remove all whitespace from line
- line = line.simplified();
- line.remove(QLatin1Char(' '));
+ QString line;
+ while (stream.readLineInto(&line))
+ parseNextLine(QStringRef(&line));
+}
- // comment
- if (line.startsWith(QLatin1Char(';')))
- continue;
+/*!
+ \internal
+ Parses one line of the configuation file
+*/
- if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
- // new section
- _section = line.mid(1, line.size() - 2);
- continue;
- }
+void QLoggingSettingsParser::parseNextLine(QStringRef line)
+{
+ // Remove whitespace at start and end of line:
+ line = line.trimmed();
+
+ // comment
+ if (line.startsWith(QLatin1Char(';')))
+ return;
+
+ if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
+ // new section
+ auto sectionName = line.mid(1, line.size() - 2).trimmed();
+ m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0;
+ return;
+ }
- if (_section.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0) {
- int equalPos = line.indexOf(QLatin1Char('='));
- if (equalPos != -1) {
- if (line.lastIndexOf(QLatin1Char('=')) == equalPos) {
- const QStringRef pattern = line.leftRef(equalPos);
- const QStringRef valueStr = line.midRef(equalPos + 1);
- int value = -1;
- if (valueStr == QLatin1String("true"))
- value = 1;
- else if (valueStr == QLatin1String("false"))
- value = 0;
- QLoggingRule rule(pattern, (value == 1));
- if (rule.flags != 0 && (value != -1))
- _rules.append(rule);
- else
- warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
- } else {
+ if (m_inRulesSection) {
+ int equalPos = line.indexOf(QLatin1Char('='));
+ if (equalPos != -1) {
+ if (line.lastIndexOf(QLatin1Char('=')) == equalPos) {
+ const auto pattern = line.left(equalPos).trimmed();
+ const auto valueStr = line.mid(equalPos + 1).trimmed();
+ int value = -1;
+ if (valueStr == QLatin1String("true"))
+ value = 1;
+ else if (valueStr == QLatin1String("false"))
+ value = 0;
+ QLoggingRule rule(pattern, (value == 1));
+ if (rule.flags != 0 && (value != -1))
+ _rules.append(rule);
+ else
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
- }
+ } else {
+ warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
}
}
}
@@ -286,7 +295,7 @@ void QLoggingRegistry::init()
if (!rulesSrc.isEmpty()) {
QTextStream stream(rulesSrc);
QLoggingSettingsParser parser;
- parser.setSection(QStringLiteral("Rules"));
+ parser.setImplicitRulesSection(true);
parser.setContent(stream);
er += parser.rules();
}
@@ -350,7 +359,7 @@ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat)
void QLoggingRegistry::setApiRules(const QString &content)
{
QLoggingSettingsParser parser;
- parser.setSection(QStringLiteral("Rules"));
+ parser.setImplicitRulesSection(true);
parser.setContent(content);
if (qtLoggingDebug())
diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h
index 23740c4955..69fc6ea4ec 100644
--- a/src/corelib/io/qloggingregistry_p.h
+++ b/src/corelib/io/qloggingregistry_p.h
@@ -93,7 +93,7 @@ Q_DECLARE_TYPEINFO(QLoggingRule, Q_MOVABLE_TYPE);
class Q_AUTOTEST_EXPORT QLoggingSettingsParser
{
public:
- void setSection(const QString &section) { _section = section; }
+ void setImplicitRulesSection(bool inRulesSection) { m_inRulesSection = inRulesSection; }
void setContent(const QString &content);
void setContent(QTextStream &stream);
@@ -101,7 +101,10 @@ public:
QVector<QLoggingRule> rules() const { return _rules; }
private:
- QString _section;
+ void parseNextLine(QStringRef line);
+
+private:
+ bool m_inRulesSection = false;
QVector<QLoggingRule> _rules;
};
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index e72773d7a4..251f68c9b4 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -122,6 +122,10 @@ QT_BEGIN_NAMESPACE
#if !defined(Q_OS_DARWIN)
+QT_BEGIN_INCLUDE_NAMESPACE
+extern char **environ;
+QT_END_INCLUDE_NAMESPACE
+
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index c16825a033..0bb8707ff9 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -196,7 +196,7 @@ public:
QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
- QUrl adjusted(FormattingOptions options) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QUrl adjusted(FormattingOptions options) const;
QByteArray toEncoded(FormattingOptions options = FullyEncoded) const;
static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode);
@@ -255,7 +255,7 @@ public:
QString fragment(ComponentFormattingOptions options = PrettyDecoded) const;
void setFragment(const QString &fragment, ParsingMode mode = TolerantMode);
- QUrl resolved(const QUrl &relative) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QUrl resolved(const QUrl &relative) const;
bool isRelative() const;
bool isParentOf(const QUrl &url) const;