diff --git a/src/corelib/text/qbytearrayalgorithms.h b/src/corelib/text/qbytearrayalgorithms.h index 7b9529eba95..b5a20256374 100644 --- a/src/corelib/text/qbytearrayalgorithms.h +++ b/src/corelib/text/qbytearrayalgorithms.h @@ -139,11 +139,21 @@ Q_CORE_EXPORT int qstrnicmp(const char *, const char *, size_t len); Q_CORE_EXPORT int qstrnicmp(const char *, qsizetype, const char *, qsizetype = -1); #ifndef QT_NO_QSNPRINTF // use std::(v)snprintf() from instead +#if QT_DEPRECATED_SINCE(6, 9) +#define QSNPF_DEPR(vsn) \ + QT_DEPRECATED_VERSION_X_6_9("Use C++11 std::" #vsn "printf() instead, taking care to " \ + "ensure that you didn't rely on QString::asprintf() " \ + "ideosyncrasies that q" #vsn "printf might, but " \ + "std::" #vsn "printf() does not, support.") // implemented in qvsnprintf.cpp +QSNPF_DEPR(vsn) Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(3, 0); +QSNPF_DEPR(sn) Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...) Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); +#undef QSNPF_DEPR +#endif // QT_DEPRECATED_SINCE(6, 9) #endif // QT_NO_QSNPRINTF // qChecksum: Internet checksum diff --git a/src/corelib/text/qvsnprintf.cpp b/src/corelib/text/qvsnprintf.cpp index afe526516ff..1e374b98e30 100644 --- a/src/corelib/text/qvsnprintf.cpp +++ b/src/corelib/text/qvsnprintf.cpp @@ -22,15 +22,15 @@ QT_BEGIN_NAMESPACE \sa qsnprintf(), qvsnprintf(). */ +#if QT_DEPRECATED_SINCE(6, 9) + #if !defined(QT_VSNPRINTF) || defined(Q_QDOC) /*! \fn int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap) \relates QByteArray - \obsolete - - Use C++11's \c{std::vsnprintf()} from \c{} instead. + \deprecated [6.9] Use C++11's \c{std::vsnprintf()} from \c{} instead. A portable \c vsnprintf() function. Will call \c ::vsnprintf(), \c ::_vsnprintf(), or \c ::vsnprintf_s depending on the system, or @@ -89,9 +89,7 @@ int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap) \target bytearray-qsnprintf \relates QByteArray - \obsolete - - Use C++11's \c{std::snprintf()} from \c{} instead. + \deprecated [6.9] Use C++11's \c{std::snprintf()} from \c{} instead. A portable snprintf() function, calls qvsnprintf. @@ -111,10 +109,14 @@ int qsnprintf(char *str, size_t n, const char *fmt, ...) va_list ap; va_start(ap, fmt); + QT_IGNORE_DEPRECATIONS( int ret = qvsnprintf(str, n, fmt, ap); + ) va_end(ap); return ret; } +#endif // QT_DEPRECATED_SINCE(6, 9) + QT_END_NAMESPACE diff --git a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp index 29103b5e3d4..11e60716bf9 100644 --- a/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/text/qbytearray/tst_qbytearray.cpp @@ -40,7 +40,9 @@ private slots: void base64(); void fromBase64_data(); void fromBase64(); +#if QT_DEPRECATED_SINCE(6, 9) void qvsnprintf(); +#endif void qstrlen(); void qstrnlen(); void qstrcpy(); @@ -679,6 +681,9 @@ void tst_QByteArray::fromBase64() } } +#if QT_DEPRECATED_SINCE(6, 9) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void tst_QByteArray::qvsnprintf() { char buf[20]; @@ -723,6 +728,8 @@ void tst_QByteArray::qvsnprintf() QT_WARNING_POP #endif } +QT_WARNING_POP +#endif // QT_DEPRECATED_SINCE(6, 9) void tst_QByteArray::qstrlen()