-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathstrtofloat.h
48 lines (41 loc) · 907 Bytes
/
strtofloat.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
//
// SPDX-License-Identifier: BSD-2-Clause
#include <common/float10.h>
#include <common/float16.h>
#include <common/locale.h>
#include <common/mbstate.h>
#include <fenv.h>
#include <float.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
#if WIDE
typedef wchar_t char_t;
#else
typedef char char_t;
#endif
flt_t NAME(const char_t *restrict nptr, char_t **restrict endptr,
locale_t locale) {
const char_t *s = nptr;
#define PEEK(n) s[n]
#define SKIP(n) \
do { \
s += (n); \
} while (0)
#include "parser_whitespace.h"
#include "parser_strtofloat.h"
#undef PEEK
#undef SKIP
if (endptr != NULL)
*endptr = (char_t *)(have_number ? s : nptr);
if (!have_number) {
errno = EINVAL;
return 0.0;
}
if (have_range_error)
errno = ERANGE;
return number;
}