File: parse-double.h

package info (click to toggle)
labwc 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,980 kB
  • sloc: ansic: 34,416; perl: 5,836; xml: 875; sh: 162; python: 131; makefile: 12
file content (32 lines) | stat: -rw-r--r-- 649 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 */