[Xfce4-commits] <midori:master> Use gstring to build suggestions script in formhistory

Christian Dywan noreply at xfce.org
Fri Dec 9 22:24:02 CET 2011


Updating branch refs/heads/master
         to b41367b7357898923a9dbcc4166af2c67a0a4057 (commit)
       from a57850e533deec401120c6851af3ea4cee22875b (commit)

commit b41367b7357898923a9dbcc4166af2c67a0a4057
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Fri Dec 9 21:29:16 2011 +0100

    Use gstring to build suggestions script in formhistory

 extensions/formhistory.c |   23 +++++++++--------------
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/extensions/formhistory.c b/extensions/formhistory.c
index d7a0c6e..00e9ea7 100644
--- a/extensions/formhistory.c
+++ b/extensions/formhistory.c
@@ -101,27 +101,22 @@ formhistory_fixup_value (char* value)
 static gchar*
 formhistory_build_js ()
 {
-    gchar* suggestions = g_strdup ("");
+    GString* suggestions;
     GHashTableIter iter;
     gpointer key, value;
-    gchar* script;
 
+    suggestions = g_string_new (
+        "function FormSuggestions(eid) { "
+        "arr = new Array();");
     g_hash_table_iter_init (&iter, global_keys);
     while (g_hash_table_iter_next (&iter, &key, &value))
     {
-       gchar* _suggestions = g_strdup_printf ("%s arr[\"%s\"] = [%s]; ",
-                                              suggestions, (char*)key, (char*)value);
-       katze_assign (suggestions, _suggestions);
+        g_string_append_printf (suggestions, " arr[\"%s\"] = [%s]; ",
+                                (gchar*)key, (gchar*)value);
     }
-    script = g_strdup_printf ("function FormSuggestions(eid) { "
-                              "arr = new Array();"
-                              "%s"
-                              "this.suggestions = arr[eid]; }"
-                              "%s",
-                              suggestions,
-                              jsforms);
-    g_free (suggestions);
-    return script;
+    g_string_append (suggestions, "this.suggestions = arr[eid]; }");
+    g_string_append (suggestions, jsforms);
+    return g_string_free (suggestions, FALSE);
 }
 
 static void


More information about the Xfce4-commits mailing list