aboutsummaryrefslogtreecommitdiff
path: root/common/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/util.c')
-rw-r--r--common/util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c
index f4588b57..0caafb39 100644
--- a/common/util.c
+++ b/common/util.c
@@ -3,6 +3,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <float.h>
#include <math.h>
#include <stdint.h>
#include <stdio.h>
@@ -140,6 +141,17 @@ bool parse_boolean(const char *boolean, bool current) {
return false;
}
+float parse_float(const char *value) {
+ errno = 0;
+ char *end;
+ float flt = strtof(value, &end);
+ if (*end || errno) {
+ wlr_log(WLR_DEBUG, "Invalid float value '%s', defaulting to NAN", value);
+ return NAN;
+ }
+ return flt;
+}
+
enum wlr_direction opposite_direction(enum wlr_direction d) {
switch (d) {
case WLR_DIRECTION_UP: