[Xfce4-commits] <squeeze:master> Fix segfault, cleanup support-reader.c file.

Stephan Arts noreply at xfce.org
Sun Aug 21 22:50:01 CEST 2011


Updating branch refs/heads/master
         to a5fa5beafeb47facb590a2a3e98812d50b973217 (commit)
       from b335b9482992ec3eb7199a90b242f9cc169baaf8 (commit)

commit a5fa5beafeb47facb590a2a3e98812d50b973217
Author: Stephan Arts <stephan at xfce.org>
Date:   Sun Aug 21 22:48:43 2011 +0200

    Fix segfault, cleanup support-reader.c file.

 libsqueeze/command-option.c |    3 +
 libsqueeze/support-reader.c |  169 ++++++++++++++++++++++++++-----------------
 2 files changed, 107 insertions(+), 65 deletions(-)

diff --git a/libsqueeze/command-option.c b/libsqueeze/command-option.c
index 92e582e..a5f12e8 100644
--- a/libsqueeze/command-option.c
+++ b/libsqueeze/command-option.c
@@ -193,6 +193,9 @@ lsq_command_option_create_pair(LSQCommandOption **option_list)
   LSQCommandOptionPair **option_pair;
   LSQCommandOptionPair **pair_iter;
 
+  g_return_val_if_fail (NULL != option_list, NULL);
+
+
   for(option_iter = option_list; *option_iter; option_iter++)
   {
     length++;
diff --git a/libsqueeze/support-reader.c b/libsqueeze/support-reader.c
index 6d7cae2..af78c93 100644
--- a/libsqueeze/support-reader.c
+++ b/libsqueeze/support-reader.c
@@ -1,17 +1,17 @@
 /* 
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or 
- *  (at your option) any later version.
+ *	This program is free software; you can redistribute it and/or modify
+ *	it under the terms of the GNU General Public License as published by
+ *	the Free Software Foundation; either version 2 of the License, or 
+ *	(at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
+ *	This program is distributed in the hope that it will be useful,
+ *	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
+ *	GNU Library General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *	You should have received a copy of the GNU General Public License
+ *	along with this program; if not, write to the Free Software
+ *	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
 #include <config.h>
@@ -113,6 +113,13 @@ lsq_support_reader_new(void)
 	return reader;
 }
 
+/**
+ * lsq_support_reader_parse_file:
+ *
+ * @filename: The filename that should be parsed.
+ *
+ * Returns: a new LSQSupportFactory object.
+ */
 LSQSupportFactory *
 lsq_support_reader_parse_file(const gchar *filename)
 {
@@ -134,15 +141,17 @@ lsq_support_reader_parse_file(const gchar *filename)
 	xfce_rc_set_group(rc, "Desktop Entry");
 
 	type = xfce_rc_read_entry(rc, "Type", "");
-	if(strcmp(type, "X-Squeeze-Archiver"))
+	if (0 != strcmp(type, "X-Squeeze-Archiver"))
 	{
 		g_object_unref(factory);
 		return NULL;
 	}
 
 	name = xfce_rc_read_entry(rc, "Name", NULL);
-	if(name)
+	if (NULL != name)
+    {
 		factory->id = g_strdup(name);
+    }
 	else
 	{
 		g_object_unref(factory);
@@ -153,38 +162,41 @@ lsq_support_reader_parse_file(const gchar *filename)
 
 	xfce_rc_set_group(rc, "Squeeze-Add");
 
-  option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
-  if(option_names)
-  {
-    add_options = lsq_command_option_create_list(rc, option_names);
-    g_strfreev(option_names);
-  }
+	option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
+
+	if(NULL != option_names)
+	{
+        add_options = lsq_command_option_create_list(rc, option_names);
+        g_strfreev(option_names);
+	}
 
 	xfce_rc_set_group(rc, "Squeeze-Remove");
 
-  option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
-  if(option_names)
-  {
-    remove_options = lsq_command_option_create_list(rc, option_names);
-    g_strfreev(option_names);
-  }
+	option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
+
+	if (NULL != option_names)
+	{
+        remove_options = lsq_command_option_create_list(rc, option_names);
+        g_strfreev (option_names);
+	}
 
 	xfce_rc_set_group(rc, "Squeeze-Extract");
 
-  option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
-  if(option_names)
-  {
-    extract_options = lsq_command_option_create_list(rc, option_names);
-    g_strfreev(option_names);
-  }
+	option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
+	if(option_names)
+	{
+        extract_options = lsq_command_option_create_list(rc, option_names);
+        g_strfreev(option_names);
+	}
 
 	xfce_rc_set_group(rc, "Squeeze-Refresh");
-  column_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Headers", ";");
-  parser_string = xfce_rc_read_entry(rc, "X-Squeeze-Parse", NULL);
-  if(parser_string)
-  {
-    parser = lsq_scanf_parser_new(parser_string);
-  }
+	column_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Headers", ";");
+	parser_string = xfce_rc_read_entry(rc, "X-Squeeze-Parse", NULL);
+
+	if (NULL != parser_string)
+	{
+	    parser = lsq_scanf_parser_new(parser_string);
+	}
 
 	_mime_types = mime_types;
 	for(i = 0; _mime_types[i]; ++i)
@@ -218,43 +230,70 @@ lsq_support_reader_parse_file(const gchar *filename)
 				_iter++;
 			}
 		}
-		else
+	 	else
+		{
 			s_template->supported = FALSE;
+		}
 
 		s_template->content_type = g_strdup (_mime_types[i]);
 		s_template->id = (const gchar *)factory->id;
 
-        new_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-New", NULL);
-        add_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Add", NULL);
-        remove_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Remove", NULL);
-        extract_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Extract", NULL);
-        refresh_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Refresh", NULL);
+		new_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-New", NULL);
+		add_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Add", NULL);
+		remove_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Remove", NULL);
+		extract_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Extract", NULL);
+		refresh_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Refresh", NULL);
 
-	
-        if (new_str_queue)    
-            s_template->new_cmd_queue     = lsq_command_queue_new(new_str_queue);
-        if (add_str_queue)
-            s_template->add_cmd_queue     = lsq_command_queue_new(add_str_queue);
-        if (remove_str_queue)
-            s_template->remove_cmd_queue  = lsq_command_queue_new(remove_str_queue);
-        if (extract_str_queue)
-            s_template->extract_cmd_queue = lsq_command_queue_new(extract_str_queue);
-        if (refresh_str_queue)
-            s_template->refresh_cmd_queue = lsq_command_queue_new(refresh_str_queue);
-
-        s_template->add_options = add_options;
-        s_template->remove_options = remove_options;
-        s_template->extract_options = extract_options;
-
-
-    s_template->n_properties = g_strv_length(column_names);
-    s_template->property_names = column_names;
-    s_template->parser = parser;
-
-		if (s_template->supported)
+        /* Read the 'new-archive' command-queue from file */	
+		if (NULL != new_str_queue)	
+		{
+			s_template->new_cmd_queue = lsq_command_queue_new(new_str_queue);
+		}
+
+        /* Read the 'add-to-archive' command-queue from file */	
+		if (NULL != add_str_queue)
+		{
+			s_template->add_cmd_queue = lsq_command_queue_new(add_str_queue);
+		}
+
+        /* Read the 'remove-to-archive' command-queue from file */	
+		if (NULL != remove_str_queue)
+		{
+			s_template->remove_cmd_queue = lsq_command_queue_new(remove_str_queue);
+		}
+
+        /* Read the 'extract-to-archive' command-queue from file */	
+		if (NULL != extract_str_queue)
+		{
+			s_template->extract_cmd_queue = lsq_command_queue_new(extract_str_queue);
+		}
+
+        /* Read the 'refresh-archive' command-queue from file */	
+		if (NULL != refresh_str_queue)
+		{
+			s_template->refresh_cmd_queue = lsq_command_queue_new(refresh_str_queue);
+		}
+
+        /* Add the appropriate options to the template */
+		s_template->add_options = add_options;
+		s_template->remove_options = remove_options;
+		s_template->extract_options = extract_options;
+
+
+		s_template->n_properties = g_strv_length(column_names);
+		s_template->property_names = column_names;
+		s_template->parser = parser;
+
+#ifdef DEBUG
+		if (NULL != s_template->supported)
+		{
 			g_debug("%s supported\n", _mime_types[i]);
+		}
 		else
+		{
 			g_debug("%s not supported\n", _mime_types[i]);
+		}
+#endif
 
 		lsq_support_factory_add_template(factory, s_template);
 	}


More information about the Xfce4-commits mailing list