aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_codepage.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-05-07 18:34:26 +0100
committerGravatar Sadie Powell2023-05-07 18:34:26 +0100
commit41590517224bf7ef9d3eb54230b5690db28d6e95 (patch)
tree2aad2efaa2af5e59a118ecbe9729ed6515be0a17 /src/modules/m_codepage.cpp
parentImprove the config error messages in the codepage module. (diff)
Fix narrowing unsigned long to uint32_t in the codepage module.
Diffstat (limited to 'src/modules/m_codepage.cpp')
-rw-r--r--src/modules/m_codepage.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp
index d3240782a..a2ec9cb4e 100644
--- a/src/modules/m_codepage.cpp
+++ b/src/modules/m_codepage.cpp
@@ -107,7 +107,7 @@ public:
virtual void GetLinkData(Module::LinkData& data, std::string& compatdata) const = 0;
// Maps an upper case character to a lower case character.
- virtual bool Map(unsigned long upper, unsigned long lower) = 0;
+ virtual bool Map(uint32_t upper, uint32_t lower) = 0;
};
class SingleByteCodepage final
@@ -182,7 +182,7 @@ public:
compatdata = INSP_FORMAT("front={}&middle={}&map={}", data["front"], data["middle"], data["map"]);
}
- bool Map(unsigned long upper, unsigned long lower) override
+ bool Map(uint32_t upper, uint32_t lower) override
{
if (upper > UCHAR_MAX || lower > UCHAR_MAX)
return false;
@@ -370,19 +370,19 @@ public:
std::unique_ptr<Codepage> newcodepage = std::make_unique<SingleByteCodepage>();
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("cpchars"))
{
- unsigned long begin = tag->getNum<unsigned long>("begin", tag->getNum<unsigned long>("index", 0));
+ uint32_t begin = tag->getNum<uint32_t>("begin", tag->getNum<uint32_t>("index", 0));
if (!begin)
throw ModuleException(this, "<cpchars> tag without index or begin specified at " + tag->source.str());
- unsigned long end = tag->getNum<unsigned long>("end", begin);
+ uint32_t end = tag->getNum<uint32_t>("end", begin);
if (begin > end)
throw ModuleException(this, "<cpchars:begin> must be lower than <cpchars:end> at " + tag->source.str());
bool front = tag->getBool("front", false);
- for (unsigned long pos = begin; pos <= end; ++pos)
+ for (uint32_t pos = begin; pos <= end; ++pos)
{
// This cast could be unsafe but it's not obvious how to make it safe.
- switch (newcodepage->AllowCharacter(static_cast<uint32_t>(pos), front))
+ switch (newcodepage->AllowCharacter(pos, front))
{
case Codepage::AllowCharacterResult::OKAY:
ServerInstance->Logs.Debug(MODNAME, "Marked {} as allowed (front: {})",
@@ -402,11 +402,11 @@ public:
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("cpcase"))
{
- unsigned long lower = tag->getNum<unsigned long>("lower", 0);
+ uint32_t lower = tag->getNum<uint32_t>("lower", 0);
if (!lower)
throw ModuleException(this, "<cpcase:lower> is required at " + tag->source.str());
- unsigned long upper = tag->getNum<unsigned long>("upper", 0);
+ uint32_t upper = tag->getNum<uint32_t>("upper", 0);
if (!upper)
throw ModuleException(this, "<cpcase:upper> is required at " + tag->source.str());