Commit | Line | Data |
---|---|---|
42bf3429 AE |
1 | From e0c8341b3e4e13778bcde00d477e461ea8e94306 Mon Sep 17 00:00:00 2001 |
2 | From: Stefan Westerfeld <stefan@space.twc.de> | |
3 | Date: Fri, 22 Apr 2016 18:03:37 +0200 | |
4 | Subject: [PATCH 031/176] RCORE: compile fixes for KUbuntu 16.04/gcc | |
5 | 5.3.1-14ubuntu2 | |
6 | ||
7 | Rapicorn uses isnan(...) and isinf(...) from cmath.h, however on KUbuntu 16.04 | |
8 | it should use std::isnan(...) and std::isinf(...) instead. Patch below. | |
9 | ||
10 | Acked-by: Tim Janik <timj@gnu.org> | |
11 | --- | |
12 | rcore/strings.cc | 10 +++++----- | |
13 | rcore/tests/benchrcore.cc | 4 ++-- | |
14 | rcore/tests/strings.cc | 4 ++-- | |
15 | 3 files changed, 9 insertions(+), 9 deletions(-) | |
16 | ||
17 | diff --git a/rcore/strings.cc b/rcore/strings.cc | |
18 | index d5b0216..8b3bc3f 100644 | |
19 | --- a/rcore/strings.cc | |
20 | +++ b/rcore/strings.cc | |
21 | @@ -437,7 +437,7 @@ static long double | |
22 | libc_strtold (const char *nptr, char **endptr) | |
23 | { | |
24 | const long double result = strtold (nptr, endptr); | |
25 | - if (isnan (result) && std::signbit (result) == 0) | |
26 | + if (std::isnan (result) && std::signbit (result) == 0) | |
27 | { | |
28 | const char *p = nptr; | |
29 | while (isspace (*p)) | |
30 | @@ -500,9 +500,9 @@ string_to_double (const char *dblstring, const char **endptr) | |
31 | String | |
32 | string_from_float (float value) | |
33 | { | |
34 | - if (isnan (value)) | |
35 | + if (std::isnan (value)) | |
36 | return std::signbit (value) ? "-NaN" : "+NaN"; | |
37 | - if (isinf (value)) | |
38 | + if (std::isinf (value)) | |
39 | return std::signbit (value) ? "-Infinity" : "+Infinity"; | |
40 | return string_format ("%.7g", value); | |
41 | } | |
42 | @@ -511,9 +511,9 @@ string_from_float (float value) | |
43 | String | |
44 | string_from_double (double value) | |
45 | { | |
46 | - if (isnan (value)) | |
47 | + if (std::isnan (value)) | |
48 | return std::signbit (value) ? "-NaN" : "+NaN"; | |
49 | - if (isinf (value)) | |
50 | + if (std::isinf (value)) | |
51 | return std::signbit (value) ? "-Infinity" : "+Infinity"; | |
52 | return string_format ("%.17g", value); | |
53 | } | |
54 | diff --git a/rcore/tests/benchrcore.cc b/rcore/tests/benchrcore.cc | |
55 | index 3899a08..12fde16 100644 | |
56 | --- a/rcore/tests/benchrcore.cc | |
57 | +++ b/rcore/tests/benchrcore.cc | |
58 | @@ -188,8 +188,8 @@ test_random_numbers() | |
59 | const double rf = random_frange (989617512, 9876547656); | |
60 | TASSERT (rf >= 989617512 && rf < 9876547656); | |
61 | } | |
62 | - TASSERT (isnan (random_frange (NAN, 1))); | |
63 | - TASSERT (isnan (random_frange (0, NAN))); | |
64 | + TASSERT (std::isnan (random_frange (NAN, 1))); | |
65 | + TASSERT (std::isnan (random_frange (0, NAN))); | |
66 | #if 0 // example penalty paid in random_int64() | |
67 | size_t i, j = 0; | |
68 | for (i = 0; i < 100; i++) | |
69 | diff --git a/rcore/tests/strings.cc b/rcore/tests/strings.cc | |
70 | index 468a6e6..dae3e3d 100644 | |
71 | --- a/rcore/tests/strings.cc | |
72 | +++ b/rcore/tests/strings.cc | |
73 | @@ -311,9 +311,9 @@ string_conversions (void) | |
74 | TCMP (string_to_double ("-0.5"), ==, -0.5); | |
75 | double tfloat; | |
76 | tfloat = string_to_double ("+NAN"); | |
77 | - assert (isnan (tfloat) && std::signbit (tfloat) == 0); | |
78 | + assert (std::isnan (tfloat) && std::signbit (tfloat) == 0); | |
79 | tfloat = string_to_double ("-NAN"); | |
80 | - assert (isnan (tfloat) && std::signbit (tfloat) == 1); | |
81 | + assert (std::isnan (tfloat) && std::signbit (tfloat) == 1); | |
82 | TCMP (string_capitalize ("fOO bar"), ==, "Foo Bar"); | |
83 | TCMP (string_capitalize ("foo BAR BAZ", 2), ==, "Foo Bar BAZ"); | |
84 | } | |
85 | -- | |
86 | 2.9.1 | |
87 |