From f41599c8e9435f3dfec60b872c2b4ae31177efdd Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 10 Oct 2020 17:22:46 +0300 Subject: Add support for test timeouts --- libbuild2/utility.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libbuild2/utility.cxx') diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx index 81f6809..193610f 100644 --- a/libbuild2/utility.cxx +++ b/libbuild2/utility.cxx @@ -593,4 +593,22 @@ namespace build2 script::regex::init (); } + + optional + parse_number (const string& s, uint64_t max_num) + { + optional r; + + if (!s.empty ()) + { + const char* b (s.c_str ()); + char* e (nullptr); + uint64_t v (strtoull (b, &e, 10)); // Can't throw. + + if (errno != ERANGE && e == b + s.size () && v <= max_num) + r = v; + } + + return r; + } } -- cgit v1.1