[Xfce4-commits] <midori:master> Check the length of form fields to save only once

Christian Dywan noreply at xfce.org
Mon Oct 12 23:08:02 CEST 2009


Updating branch refs/heads/master
         to 9702fbf5e4e532e408b0833692c313617e568b68 (commit)
       from 2fc3116f77a5082e106ec20d4185ead558a3a798 (commit)

commit 9702fbf5e4e532e408b0833692c313617e568b68
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Oct 12 18:21:12 2009 +0200

    Check the length of form fields to save only once

 extensions/formhistory.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/extensions/formhistory.c b/extensions/formhistory.c
index 81c31b5..0cb119c 100644
--- a/extensions/formhistory.c
+++ b/extensions/formhistory.c
@@ -102,14 +102,19 @@ static void
 formhistory_update_main_hash (GHashTable* keys)
 {
     GHashTableIter iter;
-    gchar* tmp = "";
-    gchar* new_value = "";
-    gchar* key = "";
-    gchar* value = "";
+    gchar* key;
+    gchar* value;
+
     g_hash_table_iter_init (&iter, keys);
     while (g_hash_table_iter_next (&iter, (gpointer)&key, (gpointer)&value))
     {
-        if (value && *value && (strlen (value) > MAXCHARS || strlen (value) < MINCHARS))
+        guint length;
+        gchar* tmp;
+
+        if (!(value && *value))
+            continue;
+        length = strlen (value);
+        if (length > MAXCHARS || length < MINCHARS)
             continue;
 
         tmp = g_hash_table_lookup (global_keys, (gpointer)key);
@@ -119,14 +124,14 @@ formhistory_update_main_hash (GHashTable* keys)
             if (!g_regex_match_simple (rvalue, tmp,
                                        G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
             {
-                new_value = g_strdup_printf ("%s%s,", tmp, rvalue);
+                gchar* new_value = g_strdup_printf ("%s%s,", tmp, rvalue);
                 g_hash_table_replace (global_keys, key, new_value);
             }
             g_free (rvalue);
         }
         else
         {
-            new_value = g_strdup_printf ("\"%s\",",value);
+            gchar* new_value = g_strdup_printf ("\"%s\",",value);
             g_hash_table_insert (global_keys, key, new_value);
         }
     }



More information about the Xfce4-commits mailing list