/pidgin/main: b6f09494adda: cross-win32: hide glib bug of mismat...

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Apr 17 02:19:23 EDT 2014


Changeset: b6f09494addae4f7f6ef7a59cf524203637cc807
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-17 08:19 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/b6f09494adda

Description:

cross-win32: hide glib bug of mismatched g_stat and GStatBuf for win32 (not win64)

diffstat:

 libpurple/glibcompat.h           |  12 ++++++++++++
 libpurple/util.c                 |  15 ++++++++++-----
 libpurple/win32/libc_interface.h |   1 +
 3 files changed, 23 insertions(+), 5 deletions(-)

diffs (59 lines):

diff --git a/libpurple/glibcompat.h b/libpurple/glibcompat.h
--- a/libpurple/glibcompat.h
+++ b/libpurple/glibcompat.h
@@ -148,6 +148,18 @@ static inline void g_object_class_instal
 #endif /* < 2.36.0 */
 
 
+/* glib's definition of g_stat+GStatBuf seems to be broken on 32-bit windows,
+ * so instead of relying on it, we'll define our own macros.
+ */
+#if defined(_WIN32) && !defined(_MSC_VER) && !defined(_WIN64)
+#  include <glib/gstdio.h>
+typedef struct _stat64 GStatBuf64;
+#  define GStatBuf GStatBuf64
+#  undef g_stat
+#  define g_stat _stat64
+#endif
+
+
 #ifdef __clang__
 
 #undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS
diff --git a/libpurple/util.c b/libpurple/util.c
--- a/libpurple/util.c
+++ b/libpurple/util.c
@@ -3095,12 +3095,17 @@ purple_util_write_data_to_file_absolute(
 		return FALSE;
 	}
 	/* Use stat to be absolutely sure. */
-	if ((g_stat(filename_temp, &st) == -1) || (st.st_size != (off_t)real_size))
-	{
+	if (g_stat(filename_temp, &st) == -1) {
 		purple_debug_error("util", "Error writing data to file %s: "
-				   "Incomplete file written; is your disk "
-				   "full?\n",
-				   filename_temp);
+			"couldn't g_stat file", filename_temp);
+		g_free(filename_temp);
+		return FALSE;
+	}
+	if (st.st_size != (off_t)real_size) {
+		purple_debug_error("util", "Error writing data to file %s: "
+			"Incomplete file written (%" G_GSIZE_FORMAT " != %"
+			G_GSIZE_FORMAT "); is your disk full?",
+			filename_temp, (gsize)st.st_size, real_size);
 		g_free(filename_temp);
 		return FALSE;
 	}
diff --git a/libpurple/win32/libc_interface.h b/libpurple/win32/libc_interface.h
--- a/libpurple/win32/libc_interface.h
+++ b/libpurple/win32/libc_interface.h
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include "libc_internal.h"
 #include <glib.h>
+#include "glibcompat.h"
 
 #ifdef __cplusplus
 extern "C" {



More information about the Commits mailing list