[libgsf] GsfOutputGio: fix error handling.



commit 252c084d8bbb2c636920cafb9c32c43cac08b0e3
Author: Morten Welinder <terra gnome org>
Date:   Sat Jan 5 13:31:28 2013 -0500

    GsfOutputGio: fix error handling.
    
    Throw in a couple of dead kittens while we're at it.

 ChangeLog             |    9 ++++++++-
 NEWS                  |    1 +
 configure.in          |    1 +
 gsf/gsf-libxml.c      |    8 ++++++++
 gsf/gsf-msole-utils.c |    5 +++++
 gsf/gsf-output-gio.c  |   27 ++++++++++++++++++++-------
 6 files changed, 43 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e795f6e..734ddd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,14 @@
 2013-01-05  Morten Welinder  <terra gnome org>
 
+	* gsf/gsf-output-gio.c (gsf_output_gio_new_full): New function
+	factored out from gsf_output_gio_new.
+	(gsf_output_gio_new_for_path, gsf_output_gio_new_for_uri): Use
+	gsf_output_gio_new_full for proper error handling.
+
+2013-01-05  Morten Welinder  <terra gnome org>
+
 	* gsf/gsf-output-gio.c (gsf_output_gio_new_for_uri): Use
-	proconditions for programming errors.
+	preconditions for programming errors.
 	(gsf_output_gio_write): Drop unneeded cast.
 
 	* gsf/gsf-libxml.c (gsf_xml_out_add_gvalue): Deal with G_TYPE_CHAR
diff --git a/NEWS b/NEWS
index cf90fdf..d2e9b75 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Frob:
 
 Morten:
 	* Deal with G_TYPE_CHAR signedness.
+	* Fix error handling of gsf_output_gio_new_for_uri.
 
 Paolo Bonzini:
 	* Fix gsf_input_dep for msole streams.  [#689706]
diff --git a/configure.in b/configure.in
index ed4c48b..d2c7b2d 100644
--- a/configure.in
+++ b/configure.in
@@ -264,6 +264,7 @@ SAVE_CFLAGS=$CFLAGS
 SAVE_LIBS=$LIBS
 CFLAGS="$CFLAGS $LIBGSF_CFLAGS"
 LIBS="$LIBGSF_LIBS $LIBS"
+AC_CHECK_FUNCS(g_value_get_schar g_value_set_schar)
 AC_MSG_CHECKING([for g_chmod])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gstdio.h>]], [[(void)g_chmod("/xxx",0777);]])],
                [AC_DEFINE(HAVE_G_CHMOD, 1, [Define if g_chmod is available as macro or function])
diff --git a/gsf/gsf-libxml.c b/gsf/gsf-libxml.c
index b36b823..4e74ad6 100644
--- a/gsf/gsf-libxml.c
+++ b/gsf/gsf-libxml.c
@@ -32,6 +32,14 @@
 #include <math.h>
 #include <string.h>
 
+/* Dead kittens.  */
+#ifndef HAVE_G_VALUE_SET_SCHAR
+#define g_value_set_schar(v_,sc_) g_value_set_char((v_),(char)(sc_))
+#endif
+#ifndef HAVE_G_VALUE_GET_SCHAR
+#define g_value_get_schar(v_) (signed char)g_value_get_char((v_))
+#endif
+
 static GObjectClass *parent_class;
 
 static gint
diff --git a/gsf/gsf-msole-utils.c b/gsf/gsf-msole-utils.c
index 80b7631..7c9b7df 100644
--- a/gsf/gsf-msole-utils.c
+++ b/gsf/gsf-msole-utils.c
@@ -39,6 +39,11 @@
 #include <time.h>
 #include <glib/gi18n-lib.h>
 
+/* Dead kittens.  */
+#ifndef HAVE_G_VALUE_SET_SCHAR
+#define g_value_set_schar(v_,sc_) g_value_set_char((v_),(char)(sc_))
+#endif
+
 #define NO_DEBUG_OLE_PROPS
 #ifndef NO_DEBUG_OLE_PROPS
 #define d(code)	do { code } while (0)
diff --git a/gsf/gsf-output-gio.c b/gsf/gsf-output-gio.c
index e6911e2..8faf5f2 100644
--- a/gsf/gsf-output-gio.c
+++ b/gsf/gsf-output-gio.c
@@ -45,9 +45,10 @@ can_seek (GOutputStream *stream)
 }
 
 static GsfOutput *
-wrap_if_not_seekable (GsfOutputGio *output)
+wrap_if_not_seekable (GsfOutputGio *output, GError **err)
 {
 	if (!can_seek (output->stream)) {
+		(void)err;
 		/* todo: return a wrapper around the output that's seekable */
 	}
 
@@ -60,15 +61,15 @@ wrap_if_not_seekable (GsfOutputGio *output)
  *
  * Returns: A new #GsfOutputGio or NULL
  */
-GsfOutput *
-gsf_output_gio_new (GFile *file)
+static GsfOutput *
+gsf_output_gio_new_full (GFile *file, GError **err)
 {
 	GsfOutputGio *output;
 	GOutputStream *stream;
 
 	g_return_val_if_fail (file != NULL, NULL);
 
-	stream = (GOutputStream *)g_file_replace (file, NULL, 0, FALSE, NULL, NULL);
+	stream = (GOutputStream *)g_file_replace (file, NULL, 0, FALSE, NULL, err);
 	if (stream == NULL) {
 		return NULL;
 	}
@@ -84,7 +85,19 @@ gsf_output_gio_new (GFile *file)
 	output->stream = stream;
 	g_object_ref (output->file);
 
-	return wrap_if_not_seekable (output);
+	return wrap_if_not_seekable (output, err);
+}
+
+/**
+ * gsf_input_gio_new:
+ * @file: an existing GFile
+ *
+ * Returns: A new #GsfOutputGio or NULL
+ */
+GsfOutput *
+gsf_output_gio_new (GFile *file)
+{
+	return gsf_output_gio_new_full (file, NULL);
 }
 
 /**
@@ -109,7 +122,7 @@ gsf_output_gio_new_for_path (char const *path, GError **err)
 
 	file = g_file_new_for_path (path);
 
-	output = gsf_output_gio_new (file);
+	output = gsf_output_gio_new_full (file, err);
 	g_object_unref (file);
 
 	return output;
@@ -131,7 +144,7 @@ gsf_output_gio_new_for_uri (char const *uri, GError **err)
 	g_return_val_if_fail (uri != NULL, NULL);
 
 	file = g_file_new_for_uri (uri);
-	output = gsf_output_gio_new (file);
+	output = gsf_output_gio_new_full (file, err);
 	g_object_unref (file);
 
 	return output;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]