Make headers QT_NO_QSNPRINTF-clean
Before we roll out QT_NO_QSNPRINTF across Qt, we need to make sure at least the headers are clean, so downstream modules can port without being stabbed in the back by unported upstream headers. Task-number: QTBUG-127110 Change-Id: I7411ff0036482ad68bd5867b624518f68f249228 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 7e2fa57faf230ef8cb505b95c2bc0e70867ac131) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
0eab6aac05
commit
13ed410121
@ -21,6 +21,8 @@
|
||||
#include <QTest>
|
||||
#include <private/qglobal_p.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QTestPrivate {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
|
||||
@ -55,7 +56,7 @@ bool _q_compareSequence(ActualIterator actualIt, ActualIterator actualEnd,
|
||||
bool isOk = actualSize == expectedSize;
|
||||
|
||||
if (!isOk) {
|
||||
qsnprintf(msg, sizeof(msg), "Compared lists have different sizes.\n"
|
||||
std::snprintf(msg, sizeof(msg), "Compared lists have different sizes.\n"
|
||||
" Actual (%s) size: %lld\n"
|
||||
" Expected (%s) size: %lld",
|
||||
actual, qlonglong(actualSize),
|
||||
@ -68,7 +69,7 @@ bool _q_compareSequence(ActualIterator actualIt, ActualIterator actualEnd,
|
||||
char *val1 = toString(*actualIt);
|
||||
char *val2 = toString(*expectedIt);
|
||||
|
||||
qsnprintf(msg, sizeof(msg), "Compared lists differ at index %lld.\n"
|
||||
std::snprintf(msg, sizeof(msg), "Compared lists differ at index %lld.\n"
|
||||
" Actual (%s): %s\n"
|
||||
" Expected (%s): %s",
|
||||
qlonglong(i), actual, val1 ? val1 : "<null>",
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include <QtGui/qvector4d.h>
|
||||
#include <QtGui/qicon.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#if 0
|
||||
// inform syncqt
|
||||
#pragma qt_no_master_include
|
||||
@ -130,7 +132,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
|
||||
const bool t1Null = t1.isNull();
|
||||
const bool t2Null = t2.isNull();
|
||||
if (t1Null != t2Null) {
|
||||
qsnprintf(msg, 1024, "Compared QImages differ.\n"
|
||||
std::snprintf(msg, 1024, "Compared QImages differ.\n"
|
||||
" Actual (%s).isNull(): %d\n"
|
||||
" Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null);
|
||||
return compare_helper(false, msg, actual, expected, file, line);
|
||||
@ -138,7 +140,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
|
||||
if (t1Null && t2Null)
|
||||
return compare_helper(true, nullptr, actual, expected, file, line);
|
||||
if (!qFuzzyCompare(t1.devicePixelRatio(), t2.devicePixelRatio())) {
|
||||
qsnprintf(msg, 1024, "Compared QImages differ in device pixel ratio.\n"
|
||||
std::snprintf(msg, 1024, "Compared QImages differ in device pixel ratio.\n"
|
||||
" Actual (%s): %g\n"
|
||||
" Expected (%s): %g",
|
||||
actual, t1.devicePixelRatio(),
|
||||
@ -146,7 +148,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
|
||||
return compare_helper(false, msg, actual, expected, file, line);
|
||||
}
|
||||
if (t1.width() != t2.width() || t1.height() != t2.height()) {
|
||||
qsnprintf(msg, 1024, "Compared QImages differ in size.\n"
|
||||
std::snprintf(msg, 1024, "Compared QImages differ in size.\n"
|
||||
" Actual (%s): %dx%d\n"
|
||||
" Expected (%s): %dx%d",
|
||||
actual, t1.width(), t1.height(),
|
||||
@ -154,7 +156,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
|
||||
return compare_helper(false, msg, actual, expected, file, line);
|
||||
}
|
||||
if (t1.format() != t2.format()) {
|
||||
qsnprintf(msg, 1024, "Compared QImages differ in format.\n"
|
||||
std::snprintf(msg, 1024, "Compared QImages differ in format.\n"
|
||||
" Actual (%s): %d\n"
|
||||
" Expected (%s): %d",
|
||||
actual, t1.format(), expected, t2.format());
|
||||
@ -172,7 +174,7 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
|
||||
const bool t1Null = t1.isNull();
|
||||
const bool t2Null = t2.isNull();
|
||||
if (t1Null != t2Null) {
|
||||
qsnprintf(msg, 1024, "Compared QPixmaps differ.\n"
|
||||
std::snprintf(msg, 1024, "Compared QPixmaps differ.\n"
|
||||
" Actual (%s).isNull(): %d\n"
|
||||
" Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null);
|
||||
return compare_helper(false, msg, actual, expected, file, line);
|
||||
@ -180,7 +182,7 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
|
||||
if (t1Null && t2Null)
|
||||
return compare_helper(true, nullptr, actual, expected, file, line);
|
||||
if (!qFuzzyCompare(t1.devicePixelRatio(), t2.devicePixelRatio())) {
|
||||
qsnprintf(msg, 1024, "Compared QPixmaps differ in device pixel ratio.\n"
|
||||
std::snprintf(msg, 1024, "Compared QPixmaps differ in device pixel ratio.\n"
|
||||
" Actual (%s): %g\n"
|
||||
" Expected (%s): %g",
|
||||
actual, t1.devicePixelRatio(),
|
||||
@ -188,7 +190,7 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
|
||||
return compare_helper(false, msg, actual, expected, file, line);
|
||||
}
|
||||
if (t1.width() != t2.width() || t1.height() != t2.height()) {
|
||||
qsnprintf(msg, 1024, "Compared QPixmaps differ in size.\n"
|
||||
std::snprintf(msg, 1024, "Compared QPixmaps differ in size.\n"
|
||||
" Actual (%s): %dx%d\n"
|
||||
" Expected (%s): %dx%d",
|
||||
actual, t1.width(), t1.height(),
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include <QtCore/quuid.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QTest {
|
||||
@ -77,7 +79,7 @@ inline typename std::enable_if<!QtPrivate::IsQEnumHelper<F>::Value, char*>::type
|
||||
{
|
||||
const size_t space = 3 + 2 * sizeof(unsigned); // 2 for 0x, two hex digits per byte, 1 for '\0'
|
||||
char *msg = new char[space];
|
||||
qsnprintf(msg, space, "0x%x", unsigned(f.toInt()));
|
||||
std::snprintf(msg, space, "0x%x", unsigned(f.toInt()));
|
||||
return msg;
|
||||
}
|
||||
|
||||
@ -196,7 +198,7 @@ template<> inline char *toString(const QChar &c)
|
||||
const ushort uc = c.unicode();
|
||||
if (uc < 128) {
|
||||
char msg[32];
|
||||
qsnprintf(msg, sizeof(msg), "QChar: '%c' (0x%x)", char(uc), unsigned(uc));
|
||||
std::snprintf(msg, sizeof(msg), "QChar: '%c' (0x%x)", char(uc), unsigned(uc));
|
||||
return qstrdup(msg);
|
||||
}
|
||||
return qstrdup(qPrintable(QString::fromLatin1("QChar: '%1' (0x%2)").arg(c).arg(QString::number(static_cast<int>(c.unicode()), 16))));
|
||||
@ -206,7 +208,7 @@ template<> inline char *toString(const QChar &c)
|
||||
template<> inline char *toString(const QModelIndex &idx)
|
||||
{
|
||||
char msg[128];
|
||||
qsnprintf(msg, sizeof(msg), "QModelIndex(%d,%d,%p,%p)",
|
||||
std::snprintf(msg, sizeof(msg), "QModelIndex(%d,%d,%p,%p)",
|
||||
idx.row(), idx.column(), idx.internalPointer(),
|
||||
static_cast<const void*>(idx.model()));
|
||||
return qstrdup(msg);
|
||||
@ -216,21 +218,21 @@ template<> inline char *toString(const QModelIndex &idx)
|
||||
template<> inline char *toString(const QPoint &p)
|
||||
{
|
||||
char msg[128];
|
||||
qsnprintf(msg, sizeof(msg), "QPoint(%d,%d)", p.x(), p.y());
|
||||
std::snprintf(msg, sizeof(msg), "QPoint(%d,%d)", p.x(), p.y());
|
||||
return qstrdup(msg);
|
||||
}
|
||||
|
||||
template<> inline char *toString(const QSize &s)
|
||||
{
|
||||
char msg[128];
|
||||
qsnprintf(msg, sizeof(msg), "QSize(%dx%d)", s.width(), s.height());
|
||||
std::snprintf(msg, sizeof(msg), "QSize(%dx%d)", s.width(), s.height());
|
||||
return qstrdup(msg);
|
||||
}
|
||||
|
||||
template<> inline char *toString(const QRect &s)
|
||||
{
|
||||
char msg[256];
|
||||
qsnprintf(msg, sizeof(msg), "QRect(%d,%d %dx%d) (bottomright %d,%d)",
|
||||
std::snprintf(msg, sizeof(msg), "QRect(%d,%d %dx%d) (bottomright %d,%d)",
|
||||
s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom());
|
||||
return qstrdup(msg);
|
||||
}
|
||||
@ -238,21 +240,21 @@ template<> inline char *toString(const QRect &s)
|
||||
template<> inline char *toString(const QPointF &p)
|
||||
{
|
||||
char msg[64];
|
||||
qsnprintf(msg, sizeof(msg), "QPointF(%g,%g)", p.x(), p.y());
|
||||
std::snprintf(msg, sizeof(msg), "QPointF(%g,%g)", p.x(), p.y());
|
||||
return qstrdup(msg);
|
||||
}
|
||||
|
||||
template<> inline char *toString(const QSizeF &s)
|
||||
{
|
||||
char msg[64];
|
||||
qsnprintf(msg, sizeof(msg), "QSizeF(%gx%g)", s.width(), s.height());
|
||||
std::snprintf(msg, sizeof(msg), "QSizeF(%gx%g)", s.width(), s.height());
|
||||
return qstrdup(msg);
|
||||
}
|
||||
|
||||
template<> inline char *toString(const QRectF &s)
|
||||
{
|
||||
char msg[256];
|
||||
qsnprintf(msg, sizeof(msg), "QRectF(%g,%g %gx%g) (bottomright %g,%g)",
|
||||
std::snprintf(msg, sizeof(msg), "QRectF(%g,%g %gx%g) (bottomright %g,%g)",
|
||||
s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom());
|
||||
return qstrdup(msg);
|
||||
}
|
||||
@ -313,7 +315,7 @@ struct QCborValueFormatter
|
||||
static char *formatSimpleType(QCborSimpleType st)
|
||||
{
|
||||
char *buf = new char[BufferLen];
|
||||
qsnprintf(buf, BufferLen, "QCborValue(QCborSimpleType(%d))", int(st));
|
||||
std::snprintf(buf, BufferLen, "QCborValue(QCborSimpleType(%d))", int(st));
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -321,7 +323,7 @@ struct QCborValueFormatter
|
||||
{
|
||||
QScopedArrayPointer<char> hold(format(taggedValue));
|
||||
char *buf = new char[BufferLen];
|
||||
qsnprintf(buf, BufferLen, "QCborValue(QCborTag(%llu), %s)",
|
||||
std::snprintf(buf, BufferLen, "QCborValue(QCborTag(%llu), %s)",
|
||||
qToUnderlying(tag), hold.get());
|
||||
return buf;
|
||||
}
|
||||
@ -336,9 +338,9 @@ struct QCborValueFormatter
|
||||
char *buf = new char[BufferLen];
|
||||
const char *typeName = typeEnum.valueToKey(t);
|
||||
if (typeName)
|
||||
qsnprintf(buf, BufferLen, "QCborValue(%s, %s)", typeName, str);
|
||||
std::snprintf(buf, BufferLen, "QCborValue(%s, %s)", typeName, str);
|
||||
else
|
||||
qsnprintf(buf, BufferLen, "QCborValue(<unknown type 0x%02x>)", t);
|
||||
std::snprintf(buf, BufferLen, "QCborValue(<unknown type 0x%02x>)", t);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user