diff options
author | Brian Ashworth <RedSoxFan@users.noreply.github.com> | 2018-11-18 14:05:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-18 14:05:03 -0500 |
commit | b2c5248ad36a7a5cf342aa44a21a0956c025c43f (patch) | |
tree | 265d4ea923f1329d1e7661c0f92a242337318d58 /common/util.c | |
parent | b87250425fe13149e41b346f15c5cf808f376438 (diff) | |
parent | 70bc4c3ab6c408850543d827f788ef310fdb269c (diff) |
Merge pull request #3018 from sxmichaels/add-scroll-factor
Add scroll factor input command.
Diffstat (limited to 'common/util.c')
-rw-r--r-- | common/util.c | 12 |
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: |