schema compiler: Don't store zero-valued flags

Don't store the "none" value for flags into the compiled schema file.
"none" should never appear as a value -- no flags set is indicated by an
empty array.
This commit is contained in:
Ryan Lortie
2010-10-04 02:57:06 -04:00
parent 136e705e83
commit 833e389516

View File

@@ -107,6 +107,12 @@ enum_state_add_value (EnumState *state,
return;
}
/* Silently drop the null case if it is mentioned.
* It is properly denoted with an empty array.
*/
if (state->is_flags && value == 0)
return;
if (state->is_flags && (value & (value - 1)))
{
g_set_error (error, G_MARKUP_ERROR,
@@ -121,7 +127,6 @@ enum_state_add_value (EnumState *state,
* If we loosen the one-bit-set restriction we need an overlap check.
*/
strinfo_builder_append_item (state->strinfo, nick, value);
}