From 00e4b08b4d87c434f352bb8aece1009a649604c4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 7 May 2023 18:32:50 +0100 Subject: Improve the config error messages in the codepage module. --- src/modules/m_codepage.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/modules/m_codepage.cpp') diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 001f1d6da..d3240782a 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -328,6 +328,14 @@ private: RehashHashmap(ServerInstance->Channels.GetChans()); } + static std::string GetPrintable(uint32_t chr) + { + if (isprint(chr)) + return INSP_FORMAT("{} ({})", reinterpret_cast(&chr), chr); + else + return INSP_FORMAT("{}", chr); + } + public: ModuleCodepage() : Module(VF_VENDOR | VF_COMMON, "Allows the server administrator to define what characters are allowed in nicknames and how characters should be compared in a case insensitive way.") @@ -377,17 +385,17 @@ public: switch (newcodepage->AllowCharacter(static_cast(pos), front)) { case Codepage::AllowCharacterResult::OKAY: - ServerInstance->Logs.Debug(MODNAME, "Marked {} ({:.4}) as allowed (front: {})", - pos, reinterpret_cast(&pos), front ? "yes" : "no"); + ServerInstance->Logs.Debug(MODNAME, "Marked {} as allowed (front: {})", + GetPrintable(pos), front ? "yes" : "no"); break; case Codepage::AllowCharacterResult::NOT_VALID: throw ModuleException(this, INSP_FORMAT(" tag contains a forbidden character: {} at {}", - pos, tag->source.str())); + GetPrintable(pos), tag->source.str())); case Codepage::AllowCharacterResult::NOT_VALID_AT_FRONT: throw ModuleException(this, INSP_FORMAT(" tag contains a forbidden front character: {} at {}", - pos, tag->source.str())); + GetPrintable(pos), tag->source.str())); } } } -- cgit v1.3.1-10-gc9f91