From c8f54b35097dba9824b78ef0995e066ebc7df915 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Mar 2023 19:59:01 +0100 Subject: [PATCH] lib/pcre/UniqueRegex: use libfmt --- src/lib/pcre/UniqueRegex.cxx | 8 +++----- src/lib/pcre/meson.build | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/pcre/UniqueRegex.cxx b/src/lib/pcre/UniqueRegex.cxx index deaae0898..48e4ceb3b 100644 --- a/src/lib/pcre/UniqueRegex.cxx +++ b/src/lib/pcre/UniqueRegex.cxx @@ -4,8 +4,7 @@ #include "UniqueRegex.hxx" #include "Error.hxx" - -#include +#include "lib/fmt/ToBuffer.hxx" void UniqueRegex::Compile(const char *pattern, bool anchored, bool capture, @@ -28,9 +27,8 @@ UniqueRegex::Compile(const char *pattern, bool anchored, bool capture, &error_number, &error_offset, nullptr); if (re == nullptr) { - char msg[256]; - snprintf(msg, sizeof(msg), "Error in regex at offset %zu", - error_offset); + const auto msg = FmtBuffer<256>("Error in regex at offset {}", + error_offset); throw Pcre::MakeError(error_number, msg); } diff --git a/src/lib/pcre/meson.build b/src/lib/pcre/meson.build index 074c4dcad..3839ff6b9 100644 --- a/src/lib/pcre/meson.build +++ b/src/lib/pcre/meson.build @@ -16,6 +16,7 @@ pcre = static_library( include_directories: inc, dependencies: [ pcre_dep, + fmt_dep, ], )