From 4dada51e08b173389a0d6656c4181f706ee7e098 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 29 Sep 2025 13:00:17 +0100 Subject: [PATCH] Sort options in the information formatter output. --- include/textproc.h | 3 ++- language/anope.en_US.po | 7 +++++-- src/misc.cpp | 30 ++++++++++++++---------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/textproc.h b/include/textproc.h index 21f9009c4..c49b57628 100644 --- a/include/textproc.h +++ b/include/textproc.h @@ -114,7 +114,8 @@ class CoreExport InfoFormatter final private: size_t longest = 0; NickCore *nc; - std::vector > replies; + std::vector options; + std::vector> replies; public: InfoFormatter(NickCore *nc); diff --git a/language/anope.en_US.po b/language/anope.en_US.po index c19dd8ed9..279c9ed42 100644 --- a/language/anope.en_US.po +++ b/language/anope.en_US.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: Anope\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-09-23 18:18+0100\n" -"PO-Revision-Date: 2025-09-23 18:18+0100\n" +"POT-Creation-Date: 2025-09-29 12:59+0100\n" +"PO-Revision-Date: 2025-09-29 13:00+0100\n" "Last-Translator: Sadie Powell \n" "Language-Team: English\n" "Language: en_US\n" @@ -5899,6 +5899,9 @@ msgstr "" msgid "Validates a previously requested vhost using DNS" msgstr "" +msgid "Validates a previously requested vhost using DNS. If you own the domain you have requested as a vhost you can validate your ownership of it using a DNS TXT record to approve your own vhost." +msgstr "" + msgid "Value" msgstr "" diff --git a/src/misc.cpp b/src/misc.cpp index 720de88d3..14a037e6c 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -264,6 +264,19 @@ void InfoFormatter::SendTo(CommandSource &source) const auto flexible = sourcenc ? sourcenc->HasExt("NS_FLEXIBLE") : false; const auto *monospace = !flexible && sourcenc && sourcenc->HasExt("NS_MONOSPACE") ? "\021" : ""; + if (!this->options.empty()) + { + std::sort(this->options.begin(), this->options.end()); + + auto &optstr = (*this)[_("Options")]; + for (const auto& option : this->options) + { + if (!optstr.empty()) + optstr += ", "; + optstr += option; + } + } + for (const auto &[key, value] : this->replies) { if (flexible) @@ -291,22 +304,7 @@ Anope::string &InfoFormatter::operator[](const Anope::string &key) void InfoFormatter::AddOption(const Anope::string &opt) { - Anope::string options = Language::Translate(this->nc, "Options"); - Anope::string *optstr = NULL; - for (auto &[option, value] : this->replies) - { - if (option == options) - { - optstr = &value; - break; - } - } - if (!optstr) - optstr = &(*this)[_("Options")]; - - if (!optstr->empty()) - *optstr += ", "; - *optstr += Language::Translate(nc, opt.c_str()); + this->options.push_back(Language::Translate(nc, opt.c_str())); }