forked from qt-creator/qt-creator
Port away from qsnprinf() and mark the project free of it
qsnprintf() has been deprecated in favor of std::snprintf(). Change-Id: I3a963e7715403a8ac5cf0d93302eb40d0c116656 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -71,6 +71,8 @@ if(MSVC)
|
|||||||
add_compile_options(/wd4573)
|
add_compile_options(/wd4573)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-DQT_NO_QSNPRINTF)
|
||||||
|
|
||||||
find_package(Qt6
|
find_package(Qt6
|
||||||
${IDE_QT_VERSION_MIN}
|
${IDE_QT_VERSION_MIN}
|
||||||
COMPONENTS Concurrent Core Gui Network PrintSupport Qml Sql Widgets Xml Core5Compat ${QT_TEST_COMPONENT}
|
COMPONENTS Concurrent Core Gui Network PrintSupport Qml Sql Widgets Xml Core5Compat ${QT_TEST_COMPONENT}
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
#include <QScopeGuard>
|
#include <QScopeGuard>
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <cstdio>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -1287,7 +1288,7 @@ void Preprocessor::trackExpansionCycles(PPToken *tk)
|
|||||||
|
|
||||||
// Offset and length of the macro invocation
|
// Offset and length of the macro invocation
|
||||||
char chunk[40];
|
char chunk[40];
|
||||||
qsnprintf(chunk, sizeof(chunk), "# expansion begin %d,%d", tk->byteOffset,
|
std::snprintf(chunk, sizeof(chunk), "# expansion begin %d,%d", tk->byteOffset,
|
||||||
tk->bytes());
|
tk->bytes());
|
||||||
buffer.append(chunk);
|
buffer.append(chunk);
|
||||||
|
|
||||||
@@ -1297,18 +1298,18 @@ void Preprocessor::trackExpansionCycles(PPToken *tk)
|
|||||||
const QPair<unsigned, unsigned> &p = m_state.m_expandedTokensInfo.at(i);
|
const QPair<unsigned, unsigned> &p = m_state.m_expandedTokensInfo.at(i);
|
||||||
if (p.first) {
|
if (p.first) {
|
||||||
if (generatedCount) {
|
if (generatedCount) {
|
||||||
qsnprintf(chunk, sizeof(chunk), " ~%d", generatedCount);
|
std::snprintf(chunk, sizeof(chunk), " ~%d", generatedCount);
|
||||||
buffer.append(chunk);
|
buffer.append(chunk);
|
||||||
generatedCount = 0;
|
generatedCount = 0;
|
||||||
}
|
}
|
||||||
qsnprintf(chunk, sizeof(chunk), " %d:%d", p.first, p.second);
|
std::snprintf(chunk, sizeof(chunk), " %d:%d", p.first, p.second);
|
||||||
buffer.append(chunk);
|
buffer.append(chunk);
|
||||||
} else {
|
} else {
|
||||||
++generatedCount;
|
++generatedCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (generatedCount) {
|
if (generatedCount) {
|
||||||
qsnprintf(chunk, sizeof(chunk), " ~%d", generatedCount);
|
std::snprintf(chunk, sizeof(chunk), " ~%d", generatedCount);
|
||||||
buffer.append(chunk);
|
buffer.append(chunk);
|
||||||
}
|
}
|
||||||
buffer.append('\n');
|
buffer.append('\n');
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
@@ -943,8 +944,7 @@ static inline QByteArray fileIdWin7(HANDLE handle)
|
|||||||
BY_HANDLE_FILE_INFORMATION info;
|
BY_HANDLE_FILE_INFORMATION info;
|
||||||
if (GetFileInformationByHandle(handle, &info)) {
|
if (GetFileInformationByHandle(handle, &info)) {
|
||||||
char buffer[sizeof "01234567:0123456701234567\0"];
|
char buffer[sizeof "01234567:0123456701234567\0"];
|
||||||
qsnprintf(buffer,
|
std::snprintf(buffer, sizeof(buffer),
|
||||||
sizeof(buffer),
|
|
||||||
"%lx:%08lx%08lx",
|
"%lx:%08lx%08lx",
|
||||||
info.dwVolumeSerialNumber,
|
info.dwVolumeSerialNumber,
|
||||||
info.nFileIndexHigh,
|
info.nFileIndexHigh,
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
#include <utils/processhandle.h>
|
#include <utils/processhandle.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
namespace Debugger::Internal {
|
namespace Debugger::Internal {
|
||||||
|
|
||||||
static uchar fromhex(uchar c)
|
static uchar fromhex(uchar c)
|
||||||
@@ -535,7 +537,7 @@ static QString quoteUnprintableLatin1(const QString &ba)
|
|||||||
if (isprint(c)) {
|
if (isprint(c)) {
|
||||||
res += ba.at(i);
|
res += ba.at(i);
|
||||||
} else {
|
} else {
|
||||||
qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
|
std::snprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
|
||||||
res += QLatin1String(buf);
|
res += QLatin1String(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user