From 1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 May 2013 01:55:04 -0400 Subject: Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in. --- src/misc.cpp | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'src/misc.cpp') diff --git a/src/misc.cpp b/src/misc.cpp index 20a53e7cc..86328b6b3 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -43,10 +43,18 @@ NumberList::NumberList(const Anope::string &list, bool descending) : is_valid(tr if (t == Anope::string::npos) { - unsigned num = convertTo(token, error, false); - if (error.empty()) - numbers.insert(num); - else + try + { + unsigned num = convertTo(token, error, false); + if (error.empty()) + numbers.insert(num); + } + catch (const ConvertException &) + { + error = "1"; + } + + if (!error.empty()) { if (!this->InvalidRange(list)) { @@ -58,14 +66,20 @@ NumberList::NumberList(const Anope::string &list, bool descending) : is_valid(tr else { Anope::string error2; - unsigned num1 = convertTo(token.substr(0, t), error, false); - unsigned num2 = convertTo(token.substr(t + 1), error2, false); - if (error.empty() && error2.empty()) + try { - for (unsigned i = num1; i <= num2; ++i) - numbers.insert(i); + unsigned num1 = convertTo(token.substr(0, t), error, false); + unsigned num2 = convertTo(token.substr(t + 1), error2, false); + if (error.empty() && error2.empty()) + for (unsigned i = num1; i <= num2; ++i) + numbers.insert(i); } - else + catch (const ConvertException &) + { + error = "1"; + } + + if (!error.empty() || !error2.empty()) { if (!this->InvalidRange(list)) { @@ -232,7 +246,7 @@ bool Anope::IsFile(const Anope::string &filename) time_t Anope::DoTime(const Anope::string &s) { if (s.empty()) - return -1; + return 0; int amount = 0; Anope::string end; @@ -257,7 +271,7 @@ time_t Anope::DoTime(const Anope::string &s) case 'y': return amount * 86400 * 365; default: - return -1; + break; } } } @@ -368,7 +382,7 @@ bool Anope::Match(const Anope::string &str, const Anope::string &mask, bool case if (r == NULL || r->GetExpression() != stripped_mask) { - ServiceReference provider("Regex", Config->RegexEngine); + ServiceReference provider("Regex", Config->GetBlock("options")->Get("regexengine")); if (provider) { try -- cgit