mirror of
https://github.com/labwc/labwc.git
synced 2026-02-08 10:06:59 -05:00
parent
d68376f2ac
commit
a457542fb1
5 changed files with 138 additions and 3 deletions
32
include/common/parse-double.h
Normal file
32
include/common/parse-double.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef LABWC_PARSE_DOUBLE_H
|
||||
#define LABWC_PARSE_DOUBLE_H
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* set_double() - Parse double-precision value of string.
|
||||
* @str: String to parse
|
||||
* @val: Storage for parsed value
|
||||
*
|
||||
* Return: true if string was parsed, false if not
|
||||
*
|
||||
* NOTE: If this function returns false, the value at *val will be untouched.
|
||||
*/
|
||||
bool set_double(const char *str, double *val);
|
||||
|
||||
static inline bool
|
||||
set_float(const char *str, float *val)
|
||||
{
|
||||
assert(val);
|
||||
|
||||
double d;
|
||||
if (set_double(str, &d)) {
|
||||
*val = d;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif /* LABWC_PARSE_DOUBLE_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue