Subject: [PATCH] Win32 build
From: David Mandelin (mandelin@cs.wisc.edu)
Date: Wed Aug 29 2001 - 14:07:10 CDT
The latest version of the WordPerfect importer uses rint(), which is not
available on Win32. I couldn't find a replacement, so I wrote one. I
don't know a lot about FP, but it seems to do the same thing as Solaris
rint() in the default rounding mode, and it works on both Win32 and
Solaris.
Index: af/util/Makefile
===================================================================
RCS file: /cvsroot/abi/src/af/util/Makefile,v
retrieving revision 1.59
diff -u -r1.59 Makefile
--- af/util/Makefile 2001/08/24 17:49:09 1.59
+++ af/util/Makefile 2001/08/29 19:03:07
@@ -87,6 +87,7 @@
$(OBJDIR)/ut_growbuf.$(OBJ_SUFFIX) \
$(OBJDIR)/ut_hash.$(OBJ_SUFFIX) \
$(OBJDIR)/ut_iconv.$(OBJ_SUFFIX) \
+ $(OBJDIR)/ut_math.$(OBJ_SUFFIX) \
$(OBJDIR)/ut_mbtowc.$(OBJ_SUFFIX) \
$(OBJDIR)/ut_misc.$(OBJ_SUFFIX) \
$(OBJDIR)/ut_png.$(OBJ_SUFFIX) \
Index: af/util/xp/ut_math.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/util/xp/ut_math.cpp,v
retrieving revision 1.1
diff -u -r1.1 ut_math.cpp
--- af/util/xp/ut_math.cpp 1998/11/08 17:45:37 1.1
+++ af/util/xp/ut_math.cpp 2001/08/29 19:03:07
@@ -17,9 +17,24 @@
* 02111-1307, USA.
*/
-
-
-
#include "ut_types.h"
#include "ut_math.h"
+#include <math.h>
+
+double UT_rint(double x) {
+ double y, z;
+ int n;
+ if (x >= 0) {
+ y = x + 0.5;
+ z = floor(y);
+ n = (int) z;
+ if (y == z && n % 2) --z;
+ } else {
+ y = x - 0.5;
+ z = ceil(y);
+ n = (int) z;
+ if (y == z && n % 2) ++z;
+ }
+ return z;
+}
Index: af/util/xp/ut_math.h
===================================================================
RCS file: /cvsroot/abi/src/af/util/xp/ut_math.h,v
retrieving revision 1.1
diff -u -r1.1 ut_math.h
--- af/util/xp/ut_math.h 1998/11/08 17:45:37 1.1
+++ af/util/xp/ut_math.h 2001/08/29 19:03:07
@@ -41,4 +41,7 @@
#define finite _finite
#endif /* WIN32 */
+// XP wrapper for rint() in C math lib.
+double UT_rint(double);
+
#endif /* UTMATH_H */
Index: wp/impexp/xp/ie_imp_WordPerfect.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_WordPerfect.cpp,v
retrieving revision 1.1
diff -u -r1.1 ie_imp_WordPerfect.cpp
--- wp/impexp/xp/ie_imp_WordPerfect.cpp 2001/08/29 10:02:38 1.1
+++ wp/impexp/xp/ie_imp_WordPerfect.cpp 2001/08/29 19:03:18
@@ -21,12 +21,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <math.h> // for rint (font size)
#include "xap_EncodingManager.h"
#include "ut_string_class.h"
#include "ut_string.h"
+#include "ut_math.h"
#include "pd_Document.h"
#include "ut_string.h"
#include "ut_units.h"
@@ -755,7 +755,7 @@
UT_DEBUGMSG(("WordPerfect: Got this font face change info: (num PIDS: %i, font descriptor PID: %i, old matched point size: %i, hash: %i, matched font index: %i, matched font point size: %i)\n",
(int) numPIDs, (int) fontDescriptorPID, (int) oldMatchedPointSize, (int) hash, (int) matchedFontIndex, (int) matchedFontPointSize));
- m_textAttributes.m_fontSize = (UT_uint16) rint((double)((((float)matchedFontPointSize)/100.0f)*2.0f)); // fixme: ghastly magic numbers;
+ m_textAttributes.m_fontSize = (UT_uint16) UT_rint((double)((((float)matchedFontPointSize)/100.0f)*2.0f)); // fixme: ghastly magic numbers;
X_CheckWordPerfectError(_flushText());
X_CheckWordPerfectError(_appendCurrentTextProperties());
@@ -785,7 +785,7 @@
UT_DEBUGMSG(("WordPerfect: Got this font size change info: (num PIDS: %i, old typeface PID: %i, desired point size: %i, hash: %i, matched font index: %i, matched font point size: %i)\n",
(int) numPIDs, (int) oldDesiredDescriptorPID, (int) desiredPointSize, (int) hash, (int) matchedFontIndex, (int) matchedFontPointSize));
- m_textAttributes.m_fontSize = (UT_uint16) rint((double)((((float)desiredPointSize)/100.0f)*2.0f)); // fixme: ghastly magic numbers;
+ m_textAttributes.m_fontSize = (UT_uint16) UT_rint((double)((((float)desiredPointSize)/100.0f)*2.0f)); // fixme: ghastly magic numbers;
X_CheckWordPerfectError(_flushText());
X_CheckWordPerfectError(_appendCurrentTextProperties());
This archive was generated by hypermail 2b25 : Wed Aug 29 2001 - 14:07:19 CDT