Commit e90728cf authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

allow numbers when deserializing enum values.

2002-11-18  Sven Neumann  <neo@wintermute>

	* app/config/gimpconfig-deserialize.c (gimp_config_deserialize_enum):
	allow numbers when deserializing enum values.
parent 2b01d397
2002-11-18 Sven Neumann <neo@wintermute>
* app/config/gimpconfig-deserialize.c (gimp_config_deserialize_enum):
allow numbers when deserializing enum values.
2002-11-18 Sven Neumann <sven@gimp.org>
 
* data/images/Makefile.am
......
......@@ -429,26 +429,46 @@ gimp_config_deserialize_enum (GValue *value,
GEnumClass *enum_class;
GEnumValue *enum_value;
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return G_TOKEN_IDENTIFIER;
g_scanner_get_next_token (scanner);
enum_class = g_type_class_peek (G_VALUE_TYPE (value));
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
switch (g_scanner_peek_next_token (scanner))
{
g_scanner_error (scanner,
_("invalid value '%s' for token %s"),
scanner->value.v_identifier, prop_spec->name);
return G_TOKEN_NONE;
case G_TOKEN_IDENTIFIER:
g_scanner_get_next_token (scanner);
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
{
g_scanner_error (scanner,
_("invalid value '%s' for token %s"),
scanner->value.v_identifier, prop_spec->name);
return G_TOKEN_NONE;
}
break;
case G_TOKEN_INT:
g_scanner_get_next_token (scanner);
enum_value = g_enum_get_value (enum_class, scanner->value.v_int);
if (!enum_value)
{
g_scanner_error (scanner,
_("invalid value '%ld' for token %s"),
scanner->value.v_int, prop_spec->name);
return G_TOKEN_NONE;
}
break;
default:
return G_TOKEN_IDENTIFIER;
}
g_value_set_enum (value, enum_value->value);
return G_TOKEN_RIGHT_PAREN;
......
......@@ -429,26 +429,46 @@ gimp_config_deserialize_enum (GValue *value,
GEnumClass *enum_class;
GEnumValue *enum_value;
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
return G_TOKEN_IDENTIFIER;
g_scanner_get_next_token (scanner);
enum_class = g_type_class_peek (G_VALUE_TYPE (value));
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
switch (g_scanner_peek_next_token (scanner))
{
g_scanner_error (scanner,
_("invalid value '%s' for token %s"),
scanner->value.v_identifier, prop_spec->name);
return G_TOKEN_NONE;
case G_TOKEN_IDENTIFIER:
g_scanner_get_next_token (scanner);
enum_value = g_enum_get_value_by_nick (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
enum_value = g_enum_get_value_by_name (G_ENUM_CLASS (enum_class),
scanner->value.v_identifier);
if (!enum_value)
{
g_scanner_error (scanner,
_("invalid value '%s' for token %s"),
scanner->value.v_identifier, prop_spec->name);
return G_TOKEN_NONE;
}
break;
case G_TOKEN_INT:
g_scanner_get_next_token (scanner);
enum_value = g_enum_get_value (enum_class, scanner->value.v_int);
if (!enum_value)
{
g_scanner_error (scanner,
_("invalid value '%ld' for token %s"),
scanner->value.v_int, prop_spec->name);
return G_TOKEN_NONE;
}
break;
default:
return G_TOKEN_IDENTIFIER;
}
g_value_set_enum (value, enum_value->value);
return G_TOKEN_RIGHT_PAREN;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment