[gnumeric] ssdiff: add option to send output to a file.



commit ecfaf872c5ee4a27b63536a35fa574657a84312d
Author: Morten Welinder <terra gnome org>
Date:   Sun Dec 30 17:00:40 2012 -0500

    ssdiff: add option to send output to a file.

 ChangeLog    |    4 ++++
 src/ssdiff.c |   23 +++++++++++++++++++----
 2 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d027bf2..21eab1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-12-30  Morten Welinder  <terra gnome org>
+
+	* src/ssdiff.c (main): Add option to send output to a file.
+
 2012-12-29  Morten Welinder  <terra gnome org>
 
 	* src/ssdiff.c (diff): Use C locale.
diff --git a/src/ssdiff.c b/src/ssdiff.c
index 7bb5a36..04014a3 100644
--- a/src/ssdiff.c
+++ b/src/ssdiff.c
@@ -36,6 +36,7 @@
 
 static gboolean ssdiff_show_version = FALSE;
 static gboolean ssdiff_xml = FALSE;
+static char *ssdiff_output = NULL;
 
 static const GOptionEntry ssdiff_options [] = {
 	{
@@ -46,6 +47,13 @@ static const GOptionEntry ssdiff_options [] = {
 	},
 
 	{
+		"output", 'o',
+		0, G_OPTION_ARG_STRING, &ssdiff_output,
+		N_("Send output to file"),
+		N_("file")
+	},
+
+	{
 		"xml", 'x',
 		0, G_OPTION_ARG_NONE, &ssdiff_xml,
 		N_("Output in xml format"),
@@ -818,6 +826,7 @@ main (int argc, char const **argv)
 	GOptionContext *ocontext;
 	GError *error = NULL;
 	const GnmDiffActions *actions;
+	char *output_uri;
 	GsfOutput *output;
 
 	/* No code before here, we need to init threads */
@@ -842,11 +851,17 @@ main (int argc, char const **argv)
 		return 0;
 	}
 
-	output = gsf_output_stdio_new_FILE ("<stdout>", stdout, TRUE);
+	if (!ssdiff_output)
+		ssdiff_output = g_strdup ("fd://1");
+	output_uri = go_shell_arg_to_uri (ssdiff_output);
+	output = go_file_create (output_uri, &error);
+	g_free (output_uri);
 	if (!output) {
-		/* Unlikely. */
-		g_printerr (_("%s: Failed to write to stdout.\n"),
-			    g_get_prgname ());
+		g_printerr (_("%s: Failed to create output file: %s\n"),
+			    g_get_prgname (),
+			    error ? error->message : "?");
+		if (error)
+			g_error_free (error);
 		return 1;
 	}
 



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