File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,17 @@ float parse_float(const char *value) {
64
64
return flt ;
65
65
}
66
66
67
+ double parse_double (const char * value ) {
68
+ errno = 0 ;
69
+ char * end ;
70
+ double dbl = strtod (value , & end );
71
+ if (* end || errno ) {
72
+ sway_log (SWAY_DEBUG , "Invalid double value '%s', defaulting to NAN" , value );
73
+ return NAN ;
74
+ }
75
+ return dbl ;
76
+ }
77
+
67
78
enum movement_unit parse_movement_unit (const char * unit ) {
68
79
if (strcasecmp (unit , "px" ) == 0 ) {
69
80
return MOVEMENT_UNIT_PX ;
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ bool parse_boolean(const char *boolean, bool current);
57
57
*/
58
58
float parse_float (const char * value );
59
59
60
+ /**
61
+ * Given a string that represents a floating point value, return a double.
62
+ * Returns NAN on error.
63
+ */
64
+ double parse_double (const char * value );
65
+
60
66
const char * sway_wl_output_subpixel_to_string (enum wl_output_subpixel subpixel );
61
67
62
68
bool sway_set_cloexec (int fd , bool cloexec );
You can’t perform that action at this time.
0 commit comments