From 023037f7ee6bbb09844f4cc146734f1ecaa17a27 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Thu, 31 Jul 2025 21:49:30 -0400 Subject: [PATCH] refactor: XWindowsClipboard, user std::format_to_n in place of snprintf --- src/lib/platform/XWindowsClipboard.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index 4027d6c3d..6a53f1db6 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include // @@ -643,7 +644,7 @@ void XWindowsClipboard::motifFillCache() // get the Motif item property from the root window static const int buffer_size = 18 + 20; char name[buffer_size]; - snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", header.m_item); + std::format_to_n(name, buffer_size, "_MOTIF_CLIP_ITEM_{}", header.m_item); Atom atomItem = XInternAtom(m_display, name, False); data = ""; if (!XWindowsUtil::getWindowProperty(m_display, root, atomItem, &data, &target, &format, False)) { @@ -668,7 +669,7 @@ void XWindowsClipboard::motifFillCache() MotifFormatMap motifFormats; for (int32_t i = 0; i < numFormats; ++i) { // get Motif format property from the root window - snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", formats[i]); + std::format_to_n(name, buffer_size, "_MOTIF_CLIP_ITEM_{}", formats[i]); Atom atomFormat = XInternAtom(m_display, name, False); std::string data; if (!XWindowsUtil::getWindowProperty(m_display, root, atomFormat, &data, &target, &format, False)) { @@ -743,7 +744,7 @@ bool XWindowsClipboard::motifGetSelection(const MotifClipFormat *format, Atom *a // part that i don't know. static const int buffer_size = 18 + 20; char name[buffer_size]; - snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", format->m_data); + std::format_to_n(name, buffer_size, "_MOTIF_CLIP_ITEM_{}", format->m_data); Atom target = XInternAtom(m_display, name, False); Window root = RootWindow(m_display, DefaultScreen(m_display)); return XWindowsUtil::getWindowProperty(m_display, root, target, data, actualTarget, nullptr, False);