r19019 - gnucash/trunk/src - Win/MSVC compatibility: Replace g_* file operations by the direct calls into the MSVC runtime.

Christian Stimming cstim at code.gnucash.org
Mon Apr 12 15:20:54 EDT 2010


Author: cstim
Date: 2010-04-12 15:20:54 -0400 (Mon, 12 Apr 2010)
New Revision: 19019
Trac: http://svn.gnucash.org/trac/changeset/19019

Modified:
   gnucash/trunk/src/app-utils/gfec.c
   gnucash/trunk/src/backend/xml/Makefile.am
   gnucash/trunk/src/backend/xml/gnc-backend-xml.c
   gnucash/trunk/src/backend/xml/io-example-account.c
   gnucash/trunk/src/backend/xml/io-gncxml-v2.c
   gnucash/trunk/src/libqof/CMakeLists.txt
   gnucash/trunk/src/libqof/qof/Makefile.am
   gnucash/trunk/src/libqof/qof/gnc-date.c
Log:
Win/MSVC compatibility: Replace g_* file operations by the direct calls into the MSVC runtime.

This tries to avoid a collision between glib's C runtime vs.
the one that is used by MSVC (and hence also Qt) by using
file access only through MSVC's one.

Modified: gnucash/trunk/src/app-utils/gfec.c
===================================================================
--- gnucash/trunk/src/app-utils/gfec.c	2010-04-12 02:38:43 UTC (rev 19018)
+++ gnucash/trunk/src/app-utils/gfec.c	2010-04-12 19:20:54 UTC (rev 19019)
@@ -11,6 +11,10 @@
 
 #include "config.h"
 #include "gfec.h"
+#include "platform.h"
+#if COMPILER(MSVC)
+# define strdup _strdup
+#endif
 
 
 /* We assume that data is actually a char**. The way we return results

Modified: gnucash/trunk/src/backend/xml/Makefile.am
===================================================================
--- gnucash/trunk/src/backend/xml/Makefile.am	2010-04-12 02:38:43 UTC (rev 19018)
+++ gnucash/trunk/src/backend/xml/Makefile.am	2010-04-12 19:20:54 UTC (rev 19019)
@@ -13,6 +13,7 @@
   -I${top_srcdir}/src/gnc-module \
   -I${top_srcdir}/lib/libc\
   -I${top_srcdir}/src/libqof/qof \
+  -I$(top_srcdir)/src \
   ${LIBXML2_CFLAGS} \
   ${GLIB_CFLAGS} \
   ${GCONF_CFLAGS}

Modified: gnucash/trunk/src/backend/xml/gnc-backend-xml.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-backend-xml.c	2010-04-12 02:38:43 UTC (rev 19018)
+++ gnucash/trunk/src/backend/xml/gnc-backend-xml.c	2010-04-12 19:20:54 UTC (rev 19019)
@@ -59,8 +59,10 @@
 # define read _read
 # define write _write
 #endif
-#ifdef _MSC_VER
+#include "platform.h"
+#if COMPILER(MSVC)
 # define g_fopen fopen
+# define g_open _open
 #endif
 
 #include "qof.h"
@@ -248,7 +250,9 @@
         /* Again check whether the directory can be accessed */
         rc = g_stat (be->dirname, &statbuf);
         if (rc != 0
-#ifndef _MSC_VER
+#if COMPILER(MSVC)
+                || (statbuf.st_mode & _S_IFDIR) == 0
+#else
                 || !S_ISDIR(statbuf.st_mode)
 #endif
            )
@@ -278,7 +282,9 @@
             return;
         }
         if (rc == 0
-#ifndef _MSC_VER
+#if COMPILER(MSVC)
+                && (statbuf.st_mode & _S_IFDIR) != 0
+#else
                 && S_ISDIR(statbuf.st_mode)
 #endif
            )
@@ -1201,3 +1207,10 @@
 }
 
 /* ========================== END OF FILE ===================== */
+
+/* For emacs we set some variables concerning indentation:
+ * Local Variables: *
+ * indent-tabs-mode:nil *
+ * c-basic-offset:4 *
+ * tab-width:8 *
+ * End: */

Modified: gnucash/trunk/src/backend/xml/io-example-account.c
===================================================================
--- gnucash/trunk/src/backend/xml/io-example-account.c	2010-04-12 02:38:43 UTC (rev 19018)
+++ gnucash/trunk/src/backend/xml/io-example-account.c	2010-04-12 19:20:54 UTC (rev 19019)
@@ -51,6 +51,10 @@
 
 #include "Scrub.h"
 #include "TransLog.h"
+#include "platform.h"
+#if COMPILER(MSVC)
+# define g_fopen fopen
+#endif
 
 static QofLogModule log_module = GNC_MOD_IO;
 

Modified: gnucash/trunk/src/backend/xml/io-gncxml-v2.c
===================================================================
--- gnucash/trunk/src/backend/xml/io-gncxml-v2.c	2010-04-12 02:38:43 UTC (rev 19018)
+++ gnucash/trunk/src/backend/xml/io-gncxml-v2.c	2010-04-12 19:20:54 UTC (rev 19019)
@@ -54,8 +54,10 @@
 # define fdopen _fdopen
 # define read _read
 #endif
-#ifdef _MSC_VER
+#include "platform.h"
+#if COMPILER(MSVC)
 # define g_fopen fopen
+# define g_open _open
 #endif
 
 /* Do not treat -Wstrict-aliasing warnings as errors because of problems of the
@@ -1385,7 +1387,13 @@
             gzval = gzread(file, buffer, BUFLEN);
             if (gzval > 0)
             {
-                if (write(params->fd, buffer, gzval) < 0)
+                if (
+#if COMPILER(MSVC)
+                    _write
+#else
+                    write
+#endif
+                    (params->fd, buffer, gzval) < 0)
                 {
                     g_warning("Could not write to pipe. The error is '%s' (%d)",
                               g_strerror(errno) ? g_strerror(errno) : "", errno);
@@ -2083,3 +2091,10 @@
 
     return success;
 }
+
+/* For emacs we set some variables concerning indentation:
+ * Local Variables: *
+ * indent-tabs-mode:nil *
+ * c-basic-offset:4 *
+ * tab-width:8 *
+ * End: */

Modified: gnucash/trunk/src/libqof/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/libqof/CMakeLists.txt	2010-04-12 02:38:43 UTC (rev 19018)
+++ gnucash/trunk/src/libqof/CMakeLists.txt	2010-04-12 19:20:54 UTC (rev 19019)
@@ -7,6 +7,7 @@
 INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
 INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}/.. ) # for config.h
 INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/lib/libc) # for strptime.h
+INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src) # for platform.h
 
 
 # Workaround to create a very simple gncla-dir.h file

Modified: gnucash/trunk/src/libqof/qof/Makefile.am
===================================================================
--- gnucash/trunk/src/libqof/qof/Makefile.am	2010-04-12 02:38:43 UTC (rev 19018)
+++ gnucash/trunk/src/libqof/qof/Makefile.am	2010-04-12 19:20:54 UTC (rev 19019)
@@ -8,6 +8,7 @@
 
 AM_CPPFLAGS = \
   -I$(top_srcdir)/lib/libc \
+  -I$(top_srcdir)/src \
   $(GLIB_CFLAGS)
 
 libgnc_qof_la_SOURCES =  \

Modified: gnucash/trunk/src/libqof/qof/gnc-date.c
===================================================================
--- gnucash/trunk/src/libqof/qof/gnc-date.c	2010-04-12 02:38:43 UTC (rev 19018)
+++ gnucash/trunk/src/libqof/qof/gnc-date.c	2010-04-12 19:20:54 UTC (rev 19019)
@@ -52,6 +52,7 @@
 #ifndef HAVE_LOCALTIME_R
 #include "localtime_r.h"
 #endif
+#include "platform.h"
 
 #define NANOS_PER_SECOND 1000000000
 
@@ -1420,10 +1421,18 @@
      * already adjusted for daylight savings time. */
     return -(tm->tm_gmtoff);
 #else
-    /* timezone is seconds *west* of UTC and is
-     * not adjusted for daylight savings time.
-     * In Spring, we spring forward, wheee! */
-    return (long int)(timezone - (tm->tm_isdst > 0 ? 3600 : 0));
+    {
+        long tz_seconds;
+        /* timezone is seconds *west* of UTC and is
+         * not adjusted for daylight savings time.
+         * In Spring, we spring forward, wheee! */
+# if COMPILER(MSVC)
+        _get_timezone(&tz_seconds);
+# else
+        tz_seconds = timezone;
+# endif
+        return (long int)(tz_seconds - (tm->tm_isdst > 0 ? 3600 : 0));
+    }
 #endif
 }
 
@@ -1571,3 +1580,10 @@
 
     return type;
 }
+
+/* For emacs we set some variables concerning indentation:
+ * Local Variables: *
+ * indent-tabs-mode:nil *
+ * c-basic-offset:4 *
+ * tab-width:8 *
+ * End: */



More information about the gnucash-changes mailing list