aboutsummaryrefslogtreecommitdiffstats
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 abaca17f..40c64230 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>
@@ -141,6 +142,17 @@ bool parse_boolean(const char *boolean, bool current) {
141 return false; 142 return false;
142} 143}
143 144
145float parse_float(const char *value) {
146 errno = 0;
147 char *end;
148 float flt = strtof(value, &end);
149 if (*end || errno) {
150 wlr_log(WLR_DEBUG, "Invalid float value '%s', defaulting to NAN", value);
151 return NAN;
152 }
153 return flt;
154}
155
144enum wlr_direction opposite_direction(enum wlr_direction d) { 156enum wlr_direction opposite_direction(enum wlr_direction d) {
145 switch (d) { 157 switch (d) {
146 case WLR_DIRECTION_UP: 158 case WLR_DIRECTION_UP: