gegl r1944 - in trunk: . gegl



Author: neo
Date: Thu Jan 31 11:03:27 2008
New Revision: 1944
URL: http://svn.gnome.org/viewvc/gegl?rev=1944&view=rev

Log:
2008-01-31  Sven Neumann  <sven gimp org>

	* gegl/gegl-dot.c
	* gegl/gegl-xml.c: don't use sprintf.


Modified:
   trunk/ChangeLog
   trunk/gegl/gegl-dot.c
   trunk/gegl/gegl-xml.c

Modified: trunk/gegl/gegl-dot.c
==============================================================================
--- trunk/gegl/gegl-dot.c	(original)
+++ trunk/gegl/gegl-dot.c	Thu Jan 31 11:03:27 2008
@@ -171,13 +171,11 @@
         GeglNode *node = entry->data;
         {
           GSList *connections = gegl_node_get_sinks (node);
-          GSList *entry;
-          entry = connections;
+          GSList *iter;
 
-          while (entry)
+          for (iter = connections; iter; iter = g_slist_next (iter))
             {
-              GeglConnection *connection = entry->data;
-              gchar           buf[512];
+              GeglConnection *connection = iter->data;
               GeglNode       *source;
               GeglNode       *sink;
               GeglPad        *source_pad;
@@ -188,11 +186,9 @@
               source_pad = gegl_connection_get_source_pad (connection);
               sink_pad   = gegl_connection_get_sink_pad (connection);
 
-              sprintf (buf, "op_%p:%s -> op_%p:%s;\n", source,
-                       gegl_pad_get_name (source_pad), sink,
-                       gegl_pad_get_name (sink_pad));
-              g_string_append (string, buf);
-              entry = g_slist_next (entry);
+              g_string_append_printf (string, "op_%p:%s -> op_%p:%s;\n",
+                                      source, gegl_pad_get_name (source_pad),
+                                      sink,   gegl_pad_get_name (sink_pad));
             }
         }
         entry = g_slist_next (entry);
@@ -205,9 +201,11 @@
 gchar *
 gegl_to_dot (GeglNode *node)
 {
-  GString *string = g_string_new ("digraph gegl { graph [ rankdir = \"BT\"];\n");
+  GString *string;
 
+  string = g_string_new ("digraph gegl { graph [ rankdir = \"BT\"];\n");
   gegl_add_graph (string, node, "GEGL");
   g_string_append (string, "}");
+
   return g_string_free (string, FALSE);
 }

Modified: trunk/gegl/gegl-xml.c
==============================================================================
--- trunk/gegl/gegl-xml.c	(original)
+++ trunk/gegl/gegl-xml.c	Thu Jan 31 11:03:27 2008
@@ -23,15 +23,16 @@
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
+
 #include "gegl-types.h"
 #include "graph/gegl-node.h"
 #include "graph/gegl-pad.h"
+#include "operation/gegl-operation.h"
 #include "property-types/gegl-color.h"
 #include "property-types/gegl-curve.h"
+#include "property-types/gegl-paramspecs.h"
 #include "gegl-instrument.h"
 #include "gegl-xml.h"
-#include "property-types/gegl-paramspecs.h"
-#include "operation/gegl-operation.h"
 
 #ifdef G_OS_WIN32
 #ifndef PATH_MAX
@@ -127,14 +128,15 @@
           else if (pd->path_root)
             {
               gchar absolute_path[PATH_MAX];
-              sprintf (buf, "%s/%s", pd->path_root, param_value);
+              g_snprintf (buf, sizeof (buf),
+                          "%s/%s", pd->path_root, param_value);
               realpath (buf, absolute_path);
               gegl_node_set (new, param_name, absolute_path, NULL);
             }
           else
             {
               gchar absolute_path[PATH_MAX];
-              sprintf (buf, "./%s", param_value);
+              g_snprintf (buf, sizeof (buf), "./%s", param_value);
               realpath (buf, absolute_path);
               gegl_node_set (new, param_name, absolute_path, NULL);
             }
@@ -621,7 +623,7 @@
               gint  value;
               gchar str[64];
               gegl_node_get (node, properties[i]->name, &value, NULL);
-              sprintf (str, "%i", value);
+              g_snprintf (str, sizeof (str), "%i", value);
               tuple_old (ss->buf, properties[i]->name, str);
             }
           else if (properties[i]->value_type == G_TYPE_BOOLEAN)
@@ -698,7 +700,8 @@
               else
                 {
                   gchar temp_id[64];
-                  sprintf (temp_id, "clone%i", ss->clone_count++);
+                  g_snprintf (temp_id, sizeof (temp_id),
+                              "clone%i", ss->clone_count++);
                   id = g_strdup (temp_id);
                   g_hash_table_insert (ss->clones, iter, (gchar *) id);
                   /* the allocation is freed by the hash table */
@@ -1018,7 +1021,7 @@
               gint  value;
               gchar str[64];
               gegl_node_get (node, properties[i]->name, &value, NULL);
-              sprintf (str, "%i", value);
+              g_snprintf (str, sizeof (str), "%i", value);
               xml_param (ss, indent + 2, properties[i]->name, str);
             }
           else if (properties[i]->value_type == G_TYPE_BOOLEAN)
@@ -1169,7 +1172,8 @@
               else
                 {
                   gchar temp_id[64];
-                  sprintf (temp_id, "clone%i", ss->clone_count++);
+                  g_snprintf (temp_id, sizeof (temp_id),
+                              "clone%i", ss->clone_count++);
                   id = g_strdup (temp_id);
                   g_hash_table_insert (ss->clones, iter, (gchar *) id);
                   /* the allocation is freed by the hash table */



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