From f4931142806556123ce75dcf8b84e60dc7cd4e3c Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 4 Nov 2013 16:32:01 +0800 Subject: [PATCH] gio/tests: Clean up inclusion of unistd.h Include unistd.h only on *NIX and define items as necessary on Windows, also replace instances of ssize_t with the GLib-equivilant gssize so to fix the build on platforms that do not have ssize_t, such as Visual C++. https://bugzilla.gnome.org/show_bug.cgi?id=711047 --- gio/tests/filter-cat.c | 13 +++++++++++-- gio/tests/gsubprocess-testprog.c | 4 ++-- gio/tests/readwrite.c | 5 ++++- gio/tests/resolver.c | 2 ++ gio/tests/win32-streams.c | 1 - 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gio/tests/filter-cat.c b/gio/tests/filter-cat.c index a367461..d2b9f5c 100644 --- a/gio/tests/filter-cat.c +++ b/gio/tests/filter-cat.c @@ -23,13 +23,22 @@ #include #include -#include #include #include #include #include +#ifdef G_OS_UNIX +#include +#endif + +#ifdef G_OS_WIN32 +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif +#endif + static gchar **locations = NULL; static char *from_charset = NULL; static char *to_charset = NULL; @@ -157,7 +166,7 @@ cat (GFile * file) g_input_stream_read (in, buffer, sizeof (buffer) - 1, NULL, &error); if (res > 0) { - ssize_t written; + gssize written; p = buffer; while (res > 0) diff --git a/gio/tests/gsubprocess-testprog.c b/gio/tests/gsubprocess-testprog.c index 1e5a948..df865f6 100644 --- a/gio/tests/gsubprocess-testprog.c +++ b/gio/tests/gsubprocess-testprog.c @@ -3,8 +3,8 @@ #include #include #include -#include #ifdef G_OS_UNIX +#include #include #include #endif @@ -20,7 +20,7 @@ write_all (int fd, { while (len > 0) { - ssize_t bytes_written = write (fd, buf, len); + gssize bytes_written = write (fd, buf, len); if (bytes_written < 0) g_error ("Failed to write to fd %d: %s", fd, strerror (errno)); diff --git a/gio/tests/readwrite.c b/gio/tests/readwrite.c index 5ac2f6f..ad156d3 100644 --- a/gio/tests/readwrite.c +++ b/gio/tests/readwrite.c @@ -1,9 +1,12 @@ #include #include #include -#include #include +#ifdef G_OS_UNIX +#include +#endif + static const char *original_data = "This is some test data that we can put in a file..."; static const char *new_data = "new data.."; diff --git a/gio/tests/resolver.c b/gio/tests/resolver.c index 02aa0c8..5f252f5 100644 --- a/gio/tests/resolver.c +++ b/gio/tests/resolver.c @@ -28,7 +28,9 @@ #include #include #include +#ifdef G_OS_UNIX #include +#endif #include diff --git a/gio/tests/win32-streams.c b/gio/tests/win32-streams.c index b7ff0b3..b9d95f9 100644 --- a/gio/tests/win32-streams.c +++ b/gio/tests/win32-streams.c @@ -27,7 +27,6 @@ #include #include #include -#include #include -- 2.7.4