aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-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 @@
3#include <sys/types.h> 3#include <sys/types.h>
4#include <sys/stat.h> 4#include <sys/stat.h>
5#include <unistd.h> 5#include <unistd.h>
6#include <float.h>
6#include <math.h> 7#include <math.h>
7#include <stdint.h> 8#include <stdint.h>
8#include <stdio.h> 9#include <stdio.h>
@@ -140,6 +141,17 @@ bool parse_boolean(const char *boolean, bool current) {
140 return false; 141 return false;
141} 142}
142 143
144float parse_float(const char *value) {
145 errno = 0;
146 char *end;
147 float flt = strtof(value, &end);
148 if (*end || errno) {
149 wlr_log(WLR_DEBUG, "Invalid float value '%s', defaulting to NAN", value);
150 return NAN;
151 }
152 return flt;
153}
154
143enum wlr_direction opposite_direction(enum wlr_direction d) { 155enum wlr_direction opposite_direction(enum wlr_direction d) {
144 switch (d) { 156 switch (d) {
145 case WLR_DIRECTION_UP: 157 case WLR_DIRECTION_UP: