[Numpy-svn] r6218 - trunk/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sat Dec 27 11:20:03 CST 2008


Author: cdavid
Date: 2008-12-27 11:19:40 -0600 (Sat, 27 Dec 2008)
New Revision: 6218

Modified:
   trunk/numpy/core/src/scalartypes.inc.src
Log:
Try ugly hack to circumvent long double brokenness with mingw.

Modified: trunk/numpy/core/src/scalartypes.inc.src
===================================================================
--- trunk/numpy/core/src/scalartypes.inc.src	2008-12-27 16:33:40 UTC (rev 6217)
+++ trunk/numpy/core/src/scalartypes.inc.src	2008-12-27 17:19:40 UTC (rev 6218)
@@ -604,7 +604,26 @@
     return ret;
 }
 
+/* Hack to deal with mingw brokenness wrt long double support in printf */
+
 /**begin repeat
+ * #name=float, double#
+ * #NAME=FLOAT, DOUBLE#
+ */
+#define _CAST_@NAME@(prec) (prec)
+/**end repeat**/
+#ifdef __MINGW32__
+#undef LONGDOUBLEPREC_REPR
+#undef LONGDOUBLEPREC_STR
+#define LONGDOUBLEPREC_REPR DOUBLEPREC_REPR
+#define LONGDOUBLEPREC_STR DOUBLEPREC_STR
+#define _CAST_LONGDOUBLE(prec) ((double)prec)
+#else
+#define _CAST_LONGDOUBLE(prec) (prec)
+#endif
+
+
+/**begin repeat
  * #name=float, double, longdouble#
  * #NAME=FLOAT, DOUBLE, LONGDOUBLE#
  */
@@ -619,7 +638,7 @@
     register char* cp;
 
     PyOS_snprintf(format, sizeof(format), "%%.%i" NPY_@NAME@_FMT, prec);
-    PyOS_snprintf(buf, buflen, format, val);
+    PyOS_snprintf(buf, buflen, format, _CAST_@NAME@(val));
     cp = buf;
     if (*cp == '-') {
         ++cp;
@@ -683,6 +702,9 @@
 }
 
 /**end repeat**/
+#undef _CAST_FLOAT
+#undef _CAST_DOUBLE
+#undef _CAST_LONGDOUBLE
 
 /* over-ride repr and str of array-scalar strings and unicode to
    remove NULL bytes and then call the corresponding functions



More information about the Numpy-svn mailing list