[librsvg] Really Fix Build of rsvg-convert on Windows
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Really Fix Build of rsvg-convert on Windows
- Date: Fri, 19 Dec 2014 11:06:05 +0000 (UTC)
commit 452ef81f5201808357db50169ed4f8c18b50b12e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Fri Dec 19 18:43:15 2014 +0800
Really Fix Build of rsvg-convert on Windows
Commit 1811f20 attempted to fix the build of rsvg-convert on Windows, but
unfortunately there were some issues about it, as
g_win32_input_stream_new() took a Windows HANDLE (i.e. a void*/gpointer),
not a numeric constant like STDIN_FILENO, as its first argument.
Acquire the HANDLE for stdin on Windows first, and pass it into
g_win32_input_stream_new(). Also use G_OS_WIN32 to check we are building
for Windows, as we do elsewhere for GLib-using items.
https://bugzilla.gnome.org/show_bug.cgi?id=734977
rsvg-convert.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/rsvg-convert.c b/rsvg-convert.c
index 7ab4721..4ddd1ad 100644
--- a/rsvg-convert.c
+++ b/rsvg-convert.c
@@ -36,12 +36,18 @@
#include <locale.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
-#ifdef _WIN32
-#include <gio/gwin32inputstream.h>
-#else
+
+#ifdef G_OS_UNIX
#include <gio/gunixinputstream.h>
#endif
+#ifdef G_OS_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include <gio/gwin32inputstream.h>
+#endif
+
#include "rsvg-css.h"
#include "rsvg.h"
#include "rsvg-size-callback.h"
@@ -120,6 +126,10 @@ main (int argc, char **argv)
RsvgDimensionData dimensions;
FILE *output_file = stdout;
+#ifdef G_OS_WIN32
+ HANDLE handle;
+#endif
+
GOptionEntry options_table[] = {
{"dpi-x", 'd', 0, G_OPTION_ARG_DOUBLE, &dpi_x,
N_("pixels per inch [optional; defaults to 90dpi]"), N_("<float>")},
@@ -218,7 +228,15 @@ main (int argc, char **argv)
if (using_stdin) {
file = NULL;
#ifdef _WIN32
- stream = g_win32_input_stream_new (STDIN_FILENO, FALSE);
+ handle = GetStdHandle (STD_INPUT_HANDLE);
+
+ if (handle == INVALID_HANDLE_VALUE) {
+ gchar *emsg = g_win32_error_message (GetLastError());
+ g_printerr ( _("Unable to acquire HANDLE for STDIN: %s\n"), emsg);
+ g_free (emsg);
+ exit (1);
+ }
+ stream = g_win32_input_stream_new (handle, FALSE);
#else
stream = g_unix_input_stream_new (STDIN_FILENO, FALSE);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]