be forward-compatible by skipping unknown object properties.

2007-06-04  Michael Natterer  <mitch@gimp.org>

	* libgimpconfig/gimpconfig-deserialize.c: be forward-compatible by
	skipping unknown object properties.

	* app/config/gimprc-deserialize.c: synced code with
	libgimpconfig (same stuff should look the same).

	* app/config/gimprc.c: whitespace.


svn path=/trunk/; revision=22698
This commit is contained in:
Michael Natterer 2007-06-04 10:38:25 +00:00 committed by Michael Natterer
parent ca3c9634a4
commit b0c8362f85
4 changed files with 62 additions and 7 deletions

View File

@ -1,3 +1,13 @@
2007-06-04 Michael Natterer <mitch@gimp.org>
* libgimpconfig/gimpconfig-deserialize.c: be forward-compatible by
skipping unknown object properties.
* app/config/gimprc-deserialize.c: synced code with
libgimpconfig (same stuff should look the same).
* app/config/gimprc.c: whitespace.
2007-06-03 Kevin Cozens <kcozens@cvs.gnome.org>
* plug-ins/script-fu/scripts/round-corners.scm: Removed spurious

View File

@ -86,8 +86,9 @@ gimp_rc_deserialize (GimpConfig *config,
{
next = g_scanner_peek_next_token (scanner);
if (next != token &&
! (token == G_TOKEN_SYMBOL && next == G_TOKEN_IDENTIFIER))
if (G_UNLIKELY (next != token &&
! (token == G_TOKEN_SYMBOL &&
next == G_TOKEN_IDENTIFIER)))
{
break;
}

View File

@ -179,6 +179,7 @@ gimp_rc_set_property (GObject *object,
rc->system_gimprc = g_build_filename (gimp_sysconf_directory (),
"gimprc", NULL);
break;
case PROP_USER_GIMPRC:
g_free (rc->user_gimprc);

View File

@ -81,6 +81,7 @@ static GTokenType gimp_config_deserialize_value_array (GValue *value,
static GTokenType gimp_config_deserialize_any (GValue *value,
GParamSpec *prop_spec,
GScanner *scanner);
static GTokenType gimp_config_skip_unknown_property (GScanner *scanner);
static inline gboolean scanner_string_utf8_valid (GScanner *scanner,
const gchar *token_name);
@ -122,15 +123,15 @@ gimp_config_deserialize_properties (GimpConfig *config,
guint i;
guint scope_id;
guint old_scope_id;
GTokenType token;
GTokenType next;
GTokenType token;
GTokenType next;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
klass = G_OBJECT_GET_CLASS (config);
property_specs = g_object_class_list_properties (klass, &n_property_specs);
if (!property_specs)
if (! property_specs)
return TRUE;
scope_id = g_type_qname (G_TYPE_FROM_INSTANCE (config));
@ -157,8 +158,12 @@ gimp_config_deserialize_properties (GimpConfig *config,
{
next = g_scanner_peek_next_token (scanner);
if (next != token)
break;
if (G_UNLIKELY (next != token &&
! (token == G_TOKEN_SYMBOL &&
next == G_TOKEN_IDENTIFIER)))
{
break;
}
token = g_scanner_get_next_token (scanner);
@ -168,6 +173,10 @@ gimp_config_deserialize_properties (GimpConfig *config,
token = G_TOKEN_SYMBOL;
break;
case G_TOKEN_IDENTIFIER:
token = gimp_config_skip_unknown_property (scanner);
break;
case G_TOKEN_SYMBOL:
token = gimp_config_deserialize_property (config,
scanner, nest_level);
@ -750,3 +759,37 @@ gimp_config_deserialize_any (GValue *value,
return G_TOKEN_RIGHT_PAREN;
}
static GTokenType
gimp_config_skip_unknown_property (GScanner *scanner)
{
gint open_paren = 0;
while (TRUE)
{
GTokenType token = g_scanner_peek_next_token (scanner);
switch (token)
{
case G_TOKEN_LEFT_PAREN:
open_paren++;
g_scanner_get_next_token (scanner);
break;
case G_TOKEN_RIGHT_PAREN:
if (open_paren == 0)
return token;
open_paren--;
g_scanner_get_next_token (scanner);
break;
case G_TOKEN_EOF:
return token;
default:
g_scanner_get_next_token (scanner);
break;
}
}
}