diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-01-13 11:21:39 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-01-13 11:21:39 +0000 |
commit | 3f59ef95482db478230bb7634209bb826b6a06d0 (patch) | |
tree | 7aac260347591d79623c829584ab97f1e9050960 /src/cairo-matrix.c | |
parent | 5e32dcf863cc8f40e2679c8c8c42e3ac927ab3c9 (diff) |
[cairo-matrix] Tidy usage of HAVE_ISFINITE.
Use a macro to switch between isfinite() and its fallback in order to
avoid using an #ifdef from within a function.
Diffstat (limited to 'src/cairo-matrix.c')
-rw-r--r-- | src/cairo-matrix.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c index df6d3cd3..d5348262 100644 --- a/src/cairo-matrix.c +++ b/src/cairo-matrix.c @@ -39,7 +39,9 @@ #include "cairoint.h" #if _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE -#define HAVE_ISFINITE 1 +#define ISFINITE(x) isfinite (x) +#else +#define ISFINITE(x) ((x) * (x) >= 0.) /* check for NaNs */ #endif static void @@ -479,14 +481,8 @@ cairo_matrix_invert (cairo_matrix_t *matrix) if (det == 0) return _cairo_error (CAIRO_STATUS_INVALID_MATRIX); -#if HAVE_ISFINITE - if (! isfinite (det)) - return _cairo_error (CAIRO_STATUS_INVALID_MATRIX); -#else - /* this weird construct is for detecting NaNs */ - if (! (det * det > 0.)) + if (! ISFINITE (det)) return _cairo_error (CAIRO_STATUS_INVALID_MATRIX); -#endif _cairo_matrix_compute_adjoint (matrix); _cairo_matrix_scalar_multiply (matrix, 1 / det); @@ -502,14 +498,7 @@ _cairo_matrix_is_invertible (const cairo_matrix_t *matrix) _cairo_matrix_compute_determinant (matrix, &det); -#if HAVE_ISFINITE - if (! isfinite (det)) - return FALSE; - - return det != 0.; -#else - return det != 0. && det * det > 0.; -#endif + return det != 0. && ISFINITE (det); } void @@ -533,9 +522,7 @@ _cairo_matrix_compute_scale_factors (const cairo_matrix_t *matrix, _cairo_matrix_compute_determinant (matrix, &det); -#if HAVE_ISFINITE - assert (isfinite (det)); -#endif + assert (ISFINITE (det)); if (det == 0) { |