[cairo-commit] 4 commits - boilerplate/cairo-boilerplate-win32-printing.c configure.ac test/any2ppm.c test/cairo-test.c util/Makefile.am

Chris Wilson ickle at kemper.freedesktop.org
Tue Apr 10 04:11:37 PDT 2012


 boilerplate/cairo-boilerplate-win32-printing.c |   30 +++++++++++++++++++++++--
 configure.ac                                   |    1 
 test/any2ppm.c                                 |   14 +++++------
 test/cairo-test.c                              |    2 -
 util/Makefile.am                               |    4 +++
 5 files changed, 41 insertions(+), 10 deletions(-)

New commits:
commit b74e8ebd50da443537a031132ebc86728f79e5f5
Author: Maarten Bosmans <mkbosmans at gmail.com>
Date:   Mon Apr 9 21:33:52 2012 +0200

    Add _cairo_win32_print_gdi_error to boilerplate code
    
    This function is not exported in libcairo, so can't be used from the
    library.

diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c
index 6fc6115..625d52c 100644
--- a/boilerplate/cairo-boilerplate-win32-printing.c
+++ b/boilerplate/cairo-boilerplate-win32-printing.c
@@ -59,8 +59,34 @@
 # define FEATURESETTING_PSLEVEL 0x0002
 #endif
 
-cairo_status_t
-_cairo_win32_print_gdi_error (const char *context);
+static cairo_status_t
+_cairo_win32_print_gdi_error (const char *context)
+{
+    void *lpMsgBuf;
+    DWORD last_error = GetLastError ();
+
+    if (!FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER |
+			 FORMAT_MESSAGE_FROM_SYSTEM,
+			 NULL,
+			 last_error,
+			 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
+			 (LPWSTR) &lpMsgBuf,
+			 0, NULL)) {
+	fprintf (stderr, "%s: Unknown GDI error", context);
+    } else {
+	fprintf (stderr, "%s: %S", context, (wchar_t *)lpMsgBuf);
+
+	LocalFree (lpMsgBuf);
+    }
+
+    fflush (stderr);
+
+    /* We should switch off of last_status, but we'd either return
+     * CAIRO_STATUS_NO_MEMORY or CAIRO_STATUS_UNKNOWN_ERROR and there
+     * is no CAIRO_STATUS_UNKNOWN_ERROR.
+     */
+    return CAIRO_STATUS_NO_MEMORY;
+}
 
 static cairo_user_data_key_t win32_closure_key;
 
commit 0bb3e0769a49f639ae86a9577394fc51709441f5
Author: Maarten Bosmans <mkbosmans at gmail.com>
Date:   Mon Apr 9 21:33:51 2012 +0200

    test: Only use alarm() when SIGALRM is also defined
    
    On some platforms (mingw) the alarm() configure check succeeds, but the
    alarm function doesn't actually work.

diff --git a/test/cairo-test.c b/test/cairo-test.c
index c5ef843..3f37147 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -90,7 +90,7 @@
 #define ARRAY_SIZE(A) (sizeof(A) / sizeof (A[0]))
 #endif
 
-#if ! HAVE_ALARM
+#if ! HAVE_ALARM || ! defined(SIGALRM)
 #define alarm(X);
 #endif
 
commit 9fcbe25c2dcf831783bb0fd20af9754c0b5c409b
Author: Maarten Bosmans <mkbosmans at gmail.com>
Date:   Mon Apr 9 21:33:50 2012 +0200

    Protect code using dlfcn.h with CAIRO_HAS_DLSYM

diff --git a/configure.ac b/configure.ac
index cedfebe..5d2e6ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,7 @@ AM_CONDITIONAL(CAIRO_HAS_DL, test "x$have_dl" = "xyes")
 if test "x$have_dlsym" = "xyes"; then
   AC_DEFINE([CAIRO_HAS_DLSYM], 1, [Define to 1 if dlsym is available])
 fi
+AM_CONDITIONAL(CAIRO_HAS_DLSYM, test "x$have_dlsym" = "xyes")
 
 dnl ===========================================================================
 
diff --git a/util/Makefile.am b/util/Makefile.am
index f202f35..82d0a80 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -12,20 +12,24 @@ endif
 
 if CAIRO_HAS_TRACE
 SUBDIRS += cairo-trace
+if CAIRO_HAS_DLSYM
 if CAIRO_HAS_SCRIPT_SURFACE
 if CAIRO_HAS_TEE_SURFACE
 SUBDIRS += cairo-fdr
 endif
 endif
 endif
+endif
 
 if BUILD_SPHINX
+if CAIRO_HAS_DLSYM
 if CAIRO_HAS_SCRIPT_SURFACE
 if CAIRO_HAS_TEE_SURFACE
 SUBDIRS += cairo-sphinx
 endif
 endif
 endif
+endif
 
 AM_CPPFLAGS = -I$(top_srcdir)/src \
 	      -I$(top_builddir)/src \
commit 3f32419257bb2e380dd63a3b1a850b512a617776
Author: Maarten Bosmans <mkbosmans at gmail.com>
Date:   Mon Apr 9 21:33:49 2012 +0200

    test: Give some functions in any2ppm a prefix
    
    The function name _write is too generic and can clash with already
    defined functions.

diff --git a/test/any2ppm.c b/test/any2ppm.c
index 0ae0877..6b61c47 100644
--- a/test/any2ppm.c
+++ b/test/any2ppm.c
@@ -96,7 +96,7 @@
 #define ARRAY_LENGTH(A) (sizeof (A) / sizeof (A[0]))
 
 static int
-_writen (int fd, char *buf, int len)
+_cairo_writen (int fd, char *buf, int len)
 {
     while (len) {
 	int ret;
@@ -120,7 +120,7 @@ _writen (int fd, char *buf, int len)
 }
 
 static int
-_write (int fd,
+_cairo_write (int fd,
 	char *buf, int maxlen, int buflen,
 	const unsigned char *src, int srclen)
 {
@@ -141,7 +141,7 @@ _write (int fd,
 	src += len;
 
 	if (buflen == maxlen) {
-	    if (! _writen (fd, buf, buflen))
+	    if (! _cairo_writen (fd, buf, buflen))
 		return -1;
 
 	    buflen = 0;
@@ -204,7 +204,7 @@ write_ppm (cairo_surface_t *surface, int fd)
 
 	switch ((int) format) {
 	case CAIRO_FORMAT_ARGB32:
-	    len = _write (fd,
+	    len = _cairo_write (fd,
 			  buf, sizeof (buf), len,
 			  (unsigned char *) row, 4 * width);
 	    break;
@@ -215,13 +215,13 @@ write_ppm (cairo_surface_t *surface, int fd)
 		rgb[0] = (p & 0xff0000) >> 16;
 		rgb[1] = (p & 0x00ff00) >> 8;
 		rgb[2] = (p & 0x0000ff) >> 0;
-		len = _write (fd,
+		len = _cairo_write (fd,
 			      buf, sizeof (buf), len,
 			      rgb, 3);
 	    }
 	    break;
 	case CAIRO_FORMAT_A8:
-	    len = _write (fd,
+	    len = _cairo_write (fd,
 			  buf, sizeof (buf), len,
 			  (unsigned char *) row, width);
 	    break;
@@ -230,7 +230,7 @@ write_ppm (cairo_surface_t *surface, int fd)
 	    return "write failed";
     }
 
-    if (len && ! _writen (fd, buf, len))
+    if (len && ! _cairo_writen (fd, buf, len))
 	return "write failed";
 
     return NULL;


More information about the cairo-commit mailing list