[glib/backport-1797-freebsd-date-parsing-glib-2-66: 2/3] gdatetime: Use isnan() instead of !isfinite()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/backport-1797-freebsd-date-parsing-glib-2-66: 2/3] gdatetime: Use isnan() instead of !isfinite()
- Date: Sat, 12 Dec 2020 18:35:40 +0000 (UTC)
commit 72246a564d11f211928c590a3411dc372886eb6e
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Dec 11 15:39:47 2020 +0000
gdatetime: Use isnan() instead of !isfinite()
Both are provided by libm, but `isnan()` is provided as a macro, whereas
`isfinite()` is an actual function, and hence libm has to be available
at runtime. That didn’t trivially work on FreeBSD, resulting in this
refactor.
`isfinite(x)` is equivalent to `!isnan(x) && !isinfinite(x)`. The case
of `x` being (negative or positive) infinity is already handled by the
range checks on the next line, so it’s safe to switch to `isnan()` here.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
glib/gdatetime.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index db54aed50..02cc3bd01 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -1588,7 +1588,7 @@ g_date_time_new (GTimeZone *tz,
day < 1 || day > days_in_months[GREGORIAN_LEAP (year)][month] ||
hour < 0 || hour > 23 ||
minute < 0 || minute > 59 ||
- !isfinite (seconds) ||
+ isnan (seconds) ||
seconds < 0.0 || seconds >= 60.0)
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]