]> git.sur5r.net Git - i3/i3/blobdiff - libi3/is_debug_build.c
Move is_debug_build() to libi3/
[i3/i3] / libi3 / is_debug_build.c
diff --git a/libi3/is_debug_build.c b/libi3/is_debug_build.c
new file mode 100644 (file)
index 0000000..3173c12
--- /dev/null
@@ -0,0 +1,17 @@
+#include <string.h>
+#include <stdbool.h>
+
+/*
+ * Returns true if this version of i3 is a debug build (anything which is not a
+ * release version), based on the git version number.
+ *
+ */
+bool is_debug_build() {
+    /* i3_version contains either something like this:
+     *     "4.0.2 (2011-11-11, branch "release")".
+     * or: "4.0.2-123-gCOFFEEBABE (2011-11-11, branch "next")".
+     *
+     * So we check for the offset of the first opening round bracket to
+     * determine whether this is a git version or a release version. */
+    return ((strchr(I3_VERSION, '(') - I3_VERSION) > 10);
+}