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:
Marc Mutz
2024-08-26 08:54:14 +02:00
parent fe8383bcec
commit 640c132c31
4 changed files with 17 additions and 12 deletions

View File

@@ -71,6 +71,8 @@ if(MSVC)
add_compile_options(/wd4573)
endif()
add_definitions(-DQT_NO_QSNPRINTF)
find_package(Qt6
${IDE_QT_VERSION_MIN}
COMPONENTS Concurrent Core Gui Network PrintSupport Qml Sql Widgets Xml Core5Compat ${QT_TEST_COMPONENT}

View File

@@ -42,6 +42,7 @@
#include <QScopeGuard>
#include <cctype>
#include <cstdio>
#include <deque>
#include <list>
#include <algorithm>
@@ -1287,8 +1288,8 @@ void Preprocessor::trackExpansionCycles(PPToken *tk)
// Offset and length of the macro invocation
char chunk[40];
qsnprintf(chunk, sizeof(chunk), "# expansion begin %d,%d", tk->byteOffset,
tk->bytes());
std::snprintf(chunk, sizeof(chunk), "# expansion begin %d,%d", tk->byteOffset,
tk->bytes());
buffer.append(chunk);
// Expanded tokens
@@ -1297,18 +1298,18 @@ void Preprocessor::trackExpansionCycles(PPToken *tk)
const QPair<unsigned, unsigned> &p = m_state.m_expandedTokensInfo.at(i);
if (p.first) {
if (generatedCount) {
qsnprintf(chunk, sizeof(chunk), " ~%d", generatedCount);
std::snprintf(chunk, sizeof(chunk), " ~%d", generatedCount);
buffer.append(chunk);
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);
} else {
++generatedCount;
}
}
if (generatedCount) {
qsnprintf(chunk, sizeof(chunk), " ~%d", generatedCount);
std::snprintf(chunk, sizeof(chunk), " ~%d", generatedCount);
buffer.append(chunk);
}
buffer.append('\n');

View File

@@ -39,6 +39,7 @@
#include <algorithm>
#include <array>
#include <cstdio>
namespace Utils {
@@ -943,12 +944,11 @@ static inline QByteArray fileIdWin7(HANDLE handle)
BY_HANDLE_FILE_INFORMATION info;
if (GetFileInformationByHandle(handle, &info)) {
char buffer[sizeof "01234567:0123456701234567\0"];
qsnprintf(buffer,
sizeof(buffer),
"%lx:%08lx%08lx",
info.dwVolumeSerialNumber,
info.nFileIndexHigh,
info.nFileIndexLow);
std::snprintf(buffer, sizeof(buffer),
"%lx:%08lx%08lx",
info.dwVolumeSerialNumber,
info.nFileIndexHigh,
info.nFileIndexLow);
return QByteArray(buffer);
}
return QByteArray();

View File

@@ -15,6 +15,8 @@
#include <utils/processhandle.h>
#include <utils/qtcassert.h>
#include <cstdio>
namespace Debugger::Internal {
static uchar fromhex(uchar c)
@@ -535,7 +537,7 @@ static QString quoteUnprintableLatin1(const QString &ba)
if (isprint(c)) {
res += ba.at(i);
} else {
qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
std::snprintf(buf, sizeof(buf) - 1, "\\%x", int(c));
res += QLatin1String(buf);
}
}