fix for 687238, "hypot" compiles wrong on Windows
Alex Cherepanov <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Organization | Coscript Software |
| Message-ID | <[email protected]> |
Check for hypot() availability on the configure step, fix the hypot replacement macro, and deal with MSVC specially. Fix bug 687238. No difference was detected on our test suite running on GNU/Linux between the versions with the hypot() function and the macro. _______________________________________________ gs-code-review mailing list [email protected] http://www.ghostscript.com/mailman/listinfo/gs-code-review
hypot.diff
(text/plain, 2.8 KB)
Index: gs/src/math_.h =================================================================== RCS file: /cvs/ghostscript/gs/src/math_.h,v retrieving revision 1.5 diff -b -u -r1.5 math_.h --- gs/src/math_.h 16 Jun 2002 05:03:12 -0000 1.5 +++ gs/src/math_.h 10 Jan 2004 16:44:01 -0000 @@ -60,13 +60,13 @@ #endif /* Define the hypot procedure on those few systems that don't provide it. */ -#ifdef _IBMR2 +#if defined(_IBMR2) /* The RS/6000 has hypot, but math.h doesn't declare it! */ extern double hypot(double, double); -#else -# if !defined(__TURBOC__) && !defined(BSD4_2) && !defined(VMS) && !defined(__MWERKS__) -# define hypot(x,y) sqrt((x)*(x)+(y)*(y)) -# endif +#elif defined(_MSC_VER) +# define hypot(x,y) _hypot(x,y) +#elif !defined(__TURBOC__) && !defined(BSD4_2) && !defined(VMS) && !defined(__MWERKS__) && !defined(HAVE_HYPOT) +# define hypot(x,y) sqrt((double)(x)*(x)+(double)(y)*(y)) #endif #ifdef OSK Index: gs/src/configure.ac =================================================================== RCS file: /cvs/ghostscript/gs/src/configure.ac,v retrieving revision 1.38 diff -b -u -r1.38 configure.ac --- gs/src/configure.ac 6 Jan 2004 20:36:14 -0000 1.38 +++ gs/src/configure.ac 10 Jan 2004 16:44:01 -0000 @@ -1,3 +1,20 @@ +dnl Copyright (C) 2002-2004 artofcode LLC. All rights reserved. + +dnl This software is provided AS-IS with no warranty, either express or +dnl implied. + +dnl This software is distributed under license and may not be copied, +dnl modified or distributed except as expressly authorized under the terms +dnl of the license contained in the file LICENSE in this distribution. + +dnl For more information about licensing, please refer to +dnl http://www.ghostscript.com/licensing/. For information on +dnl commercial licensing, go to http://www.artifex.com/licensing/ or +dnl contact Artifex Software, Inc., 101 Lucas Valley Road #110, +dnl San Rafael, CA 94903, U.S.A., +1(415)492-9861. + +dnl $Id: configure.ac,v 1.38 2004/01/10 7:20:46 alexcher Exp $ + dnl Process this file with autoconf to produce a configure script dnl ------------------------------------------------ @@ -314,6 +331,9 @@ AC_CHECK_FUNCS([mkstemp], [HAVE_MKSTEMP=-DHAVE_MKSTEMP]) AC_SUBST(HAVE_MKSTEMP) +AC_CHECK_FUNCS([hypot], [HAVE_HYPOT=-DHAVE_HYPOT]) +AC_SUBST(HAVE_HYPOT) + AC_FUNC_FORK AC_PROG_GCC_TRADITIONAL AC_FUNC_MALLOC Index: gs/src/Makefile.in =================================================================== RCS file: /cvs/ghostscript/gs/src/Makefile.in,v retrieving revision 1.29 diff -b -u -r1.29 Makefile.in --- gs/src/Makefile.in 11 Dec 2003 02:22:11 -0000 1.29 +++ gs/src/Makefile.in 10 Jan 2004 16:44:02 -0000 @@ -106,7 +106,7 @@ # This gets rid of several security warnings that look # ominous. Enable this if you wish to get rid of them. -CAPOPT= @HAVE_MKSTEMP@ +CAPOPT= @HAVE_MKSTEMP@ @HAVE_HYPOT@ # Define the name of the executable file.