Check the length of form fields to save only once
This commit is contained in:
parent
2fc3116f77
commit
9702fbf5e4
1 changed files with 12 additions and 7 deletions
|
@ -102,14 +102,19 @@ static void
|
||||||
formhistory_update_main_hash (GHashTable* keys)
|
formhistory_update_main_hash (GHashTable* keys)
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gchar* tmp = "";
|
gchar* key;
|
||||||
gchar* new_value = "";
|
gchar* value;
|
||||||
gchar* key = "";
|
|
||||||
gchar* value = "";
|
|
||||||
g_hash_table_iter_init (&iter, keys);
|
g_hash_table_iter_init (&iter, keys);
|
||||||
while (g_hash_table_iter_next (&iter, (gpointer)&key, (gpointer)&value))
|
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;
|
continue;
|
||||||
|
|
||||||
tmp = g_hash_table_lookup (global_keys, (gpointer)key);
|
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,
|
if (!g_regex_match_simple (rvalue, tmp,
|
||||||
G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY))
|
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_hash_table_replace (global_keys, key, new_value);
|
||||||
}
|
}
|
||||||
g_free (rvalue);
|
g_free (rvalue);
|
||||||
}
|
}
|
||||||
else
|
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);
|
g_hash_table_insert (global_keys, key, new_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue