aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/powerof.h26
-rw-r--r--src/common/util.cpp6
2 files changed, 29 insertions, 3 deletions
diff --git a/src/common/powerof.h b/src/common/powerof.h
new file mode 100644
index 000000000..0f6c6254a
--- /dev/null
+++ b/src/common/powerof.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <stdint.h>
+
+namespace tools
+{
+ template<uint64_t a, uint64_t b>
+ struct PowerOf
+ {
+ enum Data : uint64_t
+ {
+ // a^b = a * a^(b-1)
+ Value = a * PowerOf<a, b - 1>::Value,
+ };
+ };
+
+ template<uint64_t a>
+ struct PowerOf<a, 0>
+ {
+ enum Data : uint64_t
+ {
+ // a^0 = 1
+ Value = 1,
+ };
+ };
+}
diff --git a/src/common/util.cpp b/src/common/util.cpp
index 433cb4919..f8707d65c 100644
--- a/src/common/util.cpp
+++ b/src/common/util.cpp
@@ -1000,13 +1000,13 @@ std::string get_nix_version_display_string()
for (char c: val)
{
if (c == '*')
- newval += escape ? "*" : ".*";
+ newval += escape ? "*" : ".*", escape = false;
else if (c == '?')
- newval += escape ? "?" : ".";
+ newval += escape ? "?" : ".", escape = false;
else if (c == '\\')
newval += '\\', escape = !escape;
else
- newval += c;
+ newval += c, escape = false;
}
return newval;
}