r18876 - gnucash/trunk/src - Win32/MSVC compatiblity

Christian Stimming cstim at code.gnucash.org
Mon Mar 8 13:48:44 EST 2010


Author: cstim
Date: 2010-03-08 13:48:44 -0500 (Mon, 08 Mar 2010)
New Revision: 18876
Trac: http://svn.gnucash.org/trac/changeset/18876

Modified:
   gnucash/trunk/src/CMakeLists.txt
   gnucash/trunk/src/engine/CMakeLists.txt
   gnucash/trunk/src/engine/gnc-euro.c
   gnucash/trunk/src/engine/gnc-ui-util.c
Log:
Win32/MSVC compatiblity

- Replace trunc() by floor()
 - Provide a round() workaround implementation for MSVC
 - Use g_strcasecmp instead of the libc one
 - Add include for libc replacements

Modified: gnucash/trunk/src/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/CMakeLists.txt	2010-03-08 18:48:24 UTC (rev 18875)
+++ gnucash/trunk/src/CMakeLists.txt	2010-03-08 18:48:44 UTC (rev 18876)
@@ -16,6 +16,7 @@
 
 /* Definitions for all OS */
 #define HAVE_LIBQOF /**/
+#define HAVE_TOWUPPER 1
 #define QOF_DISABLE_DEPRECATED 1
 ")
 
@@ -57,7 +58,6 @@
 #define HAVE_SYS_STAT_H 1
 #define HAVE_SYS_TIME_H 1
 #define HAVE_SYS_TYPES_H 1
-#define HAVE_TOWUPPER 1
 #define HAVE_UNISTD_H 1
 #define HAVE_WCTYPE_H 1
 

Modified: gnucash/trunk/src/engine/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/engine/CMakeLists.txt	2010-03-08 18:48:24 UTC (rev 18875)
+++ gnucash/trunk/src/engine/CMakeLists.txt	2010-03-08 18:48:44 UTC (rev 18876)
@@ -8,6 +8,7 @@
 INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
 INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
 INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for pow.h
 INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
 INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
 INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module) # for gnc-glib-utils.h

Modified: gnucash/trunk/src/engine/gnc-euro.c
===================================================================
--- gnucash/trunk/src/engine/gnc-euro.c	2010-03-08 18:48:24 UTC (rev 18875)
+++ gnucash/trunk/src/engine/gnc-euro.c	2010-03-08 18:48:44 UTC (rev 18876)
@@ -82,7 +82,7 @@
     if (!key || !value)
         return -1;
 
-    return strcasecmp(gnc_commodity_get_mnemonic(curr), euro->currency);
+    return g_ascii_strcasecmp(gnc_commodity_get_mnemonic(curr), euro->currency);
 }
 
 static int
@@ -94,7 +94,7 @@
     if (!key || !value)
         return -1;
 
-    return strcasecmp (code, euro->currency);
+    return g_ascii_strcasecmp (code, euro->currency);
 }
 
 /* ------------------------------------------------------ */

Modified: gnucash/trunk/src/engine/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/engine/gnc-ui-util.c	2010-03-08 18:48:24 UTC (rev 18875)
+++ gnucash/trunk/src/engine/gnc-ui-util.c	2010-03-08 18:48:44 UTC (rev 18876)
@@ -32,8 +32,8 @@
 #include <limits.h>
 #include <locale.h>
 #include <math.h>
-#ifdef G_OS_WIN32
-#include <pow.h>
+#if defined(G_OS_WIN32) && !defined(_MSC_VER)
+# include <pow.h>
 #endif
 #include <stdarg.h>
 #include <stdlib.h>
@@ -1841,6 +1841,14 @@
     return g_string_free(result, FALSE);
 }
 
+#ifdef _MSC_VER
+static double round(double x)
+{
+	// A simple round() implementation because MSVC doesn't seem to have that
+	return floor(x + 0.5);
+}
+#endif
+
 gchar *
 number_to_words(gdouble val, gint64 denom)
 {
@@ -1850,7 +1858,7 @@
     if (val < 0) val = -val;
     if (denom < 0) denom = -denom;
 
-    int_part = trunc(val);
+    int_part = floor(val);
     frac_part = round((val - int_part) * denom);
 
     int_string = integer_to_words(int_part);



More information about the gnucash-changes mailing list