tools/source/inet/inetmsg.cxx     |    3 ++-
 tools/source/misc/json_writer.cxx |    4 ++++
 tools/source/ref/globname.cxx     |    4 ++--
 tools/source/stream/stream.cxx    |   12 +++++-------
 4 files changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 4280a3257948e57cdf194a6e23718b46d907bbd6
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Sat Nov 5 16:08:39 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Sun Nov 6 01:13:45 2022 +0100

    -Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): tools
    
    (The "clang-format off" in tools/source/misc/json_writer.cxx is necessary
    because otherwise the code between the 
SAL_WNODEPRECATED_DECLARATIONS_PUSH/POP
    macros would be ill-formatted in a way that would trigger 
loplugin:indentation.)
    
    Change-Id: Ic96787865d4c96be07c41f4939893420dfa04046
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142339
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index d58581e74200..b2e7f70b40d4 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -23,6 +23,7 @@
 #include <comphelper/string.hxx>
 #include <rtl/character.hxx>
 #include <o3tl/safeint.hxx>
+#include <o3tl/sprintf.hxx>
 #include <o3tl/string_view.hxx>
 
 #include <map>
@@ -265,7 +266,7 @@ void INetMIMEMessage::EnableAttachMultipartFormDataChild()
     tools::Time aCurTime( tools::Time::SYSTEM );
     sal_uInt64 nThis = reinterpret_cast< sal_uIntPtr >( this ); // we can be 
on a 64bit architecture
     nThis = ( ( nThis >> 32 ) ^ nThis ) & SAL_MAX_UINT32;
-    sprintf (sTail, "%08X%08X",
+    o3tl::sprintf (sTail, "%08X%08X",
              static_cast< unsigned int >(aCurTime.GetTime()),
              static_cast< unsigned int >(nThis));
     m_aBoundary = "------------_4D48";
diff --git a/tools/source/misc/json_writer.cxx 
b/tools/source/misc/json_writer.cxx
index fbb29bb2472c..3d78f82e08e6 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -326,7 +326,11 @@ void JsonWriter::put(const char* pPropName, sal_Int64 
nPropVal)
     memcpy(mPos, "\": ", 3);
     mPos += 3;
 
+    // clang-format off
+    SAL_WNODEPRECATED_DECLARATIONS_PUSH // sprintf (macOS 13 SDK)
     mPos += sprintf(mPos, "%" SAL_PRIdINT64, nPropVal);
+    SAL_WNODEPRECATED_DECLARATIONS_POP
+    // clang-format on
 
     validate();
 }
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index a41b29bba6d3..df8ff10943ea 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -17,10 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <stdio.h>
 #include <string.h>
 
 #include <comphelper/mimeconfighelper.hxx>
+#include <o3tl/sprintf.hxx>
 #include <rtl/character.hxx>
 
 #include <tools/stream.hxx>
@@ -153,7 +153,7 @@ bool SvGlobalName::MakeId( std::u16string_view rIdStr )
 OUString SvGlobalName::GetHexName() const
 {
     char buf[ 37 ];
-    int n = sprintf(buf,
+    int n = o3tl::sprintf(buf,
                     "%8.8" SAL_PRIXUINT32 
"-%4.4X-%4.4X-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
                     m_aData.Data1, m_aData.Data2, m_aData.Data3,
                     m_aData.Data4[0], m_aData.Data4[1], m_aData.Data4[2], 
m_aData.Data4[3],
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index f6d703423828..d5abf5e2d9e2 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -26,12 +26,12 @@
 #include <memory>
 
 #include <string.h>
-#include <stdio.h>
 
 #include <o3tl/safeint.hxx>
 #include <osl/endian.h>
 #include <osl/diagnose.h>
 #include <rtl/strbuf.hxx>
+#include <rtl/string.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <sal/log.hxx>
 #include <tools/long.hxx>
@@ -1361,17 +1361,15 @@ void SvStream::RefreshBuffer()
 
 SvStream& SvStream::WriteInt32AsString(sal_Int32 nInt32)
 {
-    char buffer[12];
-    std::size_t nLen = sprintf(buffer, "%" SAL_PRIdINT32, nInt32);
-    WriteBytes(buffer, nLen);
+    auto const buffer = OString::number(nInt32);
+    WriteBytes(buffer.getStr(), buffer.length);
     return *this;
 }
 
 SvStream& SvStream::WriteUInt32AsString(sal_uInt32 nUInt32)
 {
-    char buffer[11];
-    std::size_t nLen = sprintf(buffer, "%" SAL_PRIuUINT32, nUInt32);
-    WriteBytes(buffer, nLen);
+    auto const buffer = OString::number(nUInt32);
+    WriteBytes(buffer.getStr(), buffer.length);
     return *this;
 }
 

Reply via email to