Don't skip invalid enum values in schemas

Signed-off-by: Maks Naumov <maksqwe1@ukr.net>

https://bugzilla.gnome.org/show_bug.cgi?id=742997
This commit is contained in:
Maks Naumov 2015-01-15 14:33:17 -08:00 committed by Philip Withnall
parent 30b25a6fd9
commit 12e32e96a3
3 changed files with 13 additions and 2 deletions

View File

@ -97,9 +97,9 @@ enum_state_add_value (EnumState *state,
} }
value = g_ascii_strtoll (valuestr, &end, 0); value = g_ascii_strtoll (valuestr, &end, 0);
if (*end || state->is_flags ? if (*end || (state->is_flags ?
(value > G_MAXUINT32 || value < 0) : (value > G_MAXUINT32 || value < 0) :
(value > G_MAXINT32 || value < G_MININT32)) (value > G_MAXINT32 || value < G_MININT32)))
{ {
g_set_error (error, G_MARKUP_ERROR, g_set_error (error, G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT, G_MARKUP_ERROR_INVALID_CONTENT,

View File

@ -86,6 +86,7 @@ static const SchemaTest tests[] = {
{ "enum", NULL, NULL }, { "enum", NULL, NULL },
{ "enum-with-aliases", NULL, NULL }, { "enum-with-aliases", NULL, NULL },
{ "enum-with-invalid-alias", NULL, "*“banger” is not in enumerated type*" }, { "enum-with-invalid-alias", NULL, "*“banger” is not in enumerated type*" },
{ "enum-with-invalid-value", NULL, "*invalid numeric value*" },
{ "enum-with-repeated-alias", NULL, "*<alias value='sausages'/> already specified*" }, { "enum-with-repeated-alias", NULL, "*<alias value='sausages'/> already specified*" },
{ "enum-with-repeated-nick", NULL, "*<value nick='spam'/> already specified*" }, { "enum-with-repeated-nick", NULL, "*<value nick='spam'/> already specified*" },
{ "enum-with-repeated-value", NULL, "*value='1' already specified*" }, { "enum-with-repeated-value", NULL, "*value='1' already specified*" },

View File

@ -0,0 +1,10 @@
<schemalist>
<enum id='org.gtk.test.MyEnum'>
<value nick='nospam' value='*'/>
<value nick='spam' value='1'/>
<value nick='ham' value='2'/>
<value nick='eggs' value='3'/>
<value nick='bangers' value='4'/>
<value nick='mash' value='5'/>
</enum>
</schemalist>