diff options
author | Vincent Untz <vuntz@gnome.org> | 2008-04-26 10:34:22 +0000 |
---|---|---|
committer | Vincent Untz <vuntz@gnome.org> | 2008-04-26 10:34:22 +0000 |
commit | b2c108e4782a25545aa57c9d8add5c4ab01801cc (patch) | |
tree | c245061807de25b5f856f2e99adaa465369c645c | |
parent | 83e6050a2501379a7709379e9dfdf656738a7148 (diff) |
at least one main category must be included in the Categories. Output an
2008-04-26 Vincent Untz <vuntz@gnome.org>
* src/validate.c: (handle_categories_key): at least one main category
must be included in the Categories. Output an error if it's not the
case.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/validate.c | 25 |
2 files changed, 28 insertions, 3 deletions
@@ -1,3 +1,9 @@ +2008-04-26 Vincent Untz <vuntz@gnome.org> + + * src/validate.c: (handle_categories_key): at least one main category + must be included in the Categories. Output an error if it's not the + case. + 2008-03-06 Vincent Untz <vuntz@gnome.org> * src/install.c: (process_one_file): don't unlink the destination file diff --git a/src/validate.c b/src/validate.c index 3474e0e..8821645 100644 --- a/src/validate.c +++ b/src/validate.c @@ -42,8 +42,9 @@ #include "keyfileutils.h" #include "validate.h" -//FIXME: document where we are stricter than the spec -// * only UTF-8 (so no Legacy-Mixed encoding) +/*FIXME: document where we are stricter than the spec + * + only UTF-8 (so no Legacy-Mixed encoding) + */ /*TODO: * + Lecagy-Mixed Encoding (annexe D) @@ -1152,6 +1153,13 @@ handle_mime_key (kf_validator *kf, * FIXME: it's not really deprecated, so the error message is wrong * + All categories extending the format should start with "X-". * Checked. + * + At least one main category must be included. + * Checked. + * FIXME: decide if it's okay to have an empty list of categories. + * + Some categories, if include, require that another category is included. + * Eg: if Audio is there, AudioVideo must be there. Same for most additional + * categories. + * TODO */ static gboolean handle_categories_key (kf_validator *kf, @@ -1163,10 +1171,12 @@ handle_categories_key (kf_validator *kf, GHashTable *hashtable; int i; unsigned int j; + gboolean main_category_present; handle_key_for_application (kf, locale_key, value); retval = TRUE; + main_category_present = FALSE; hashtable = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL); categories = g_strsplit (value, ";", 0); @@ -1196,8 +1206,10 @@ handle_categories_key (kf_validator *kf, } \ if (j != G_N_ELEMENTS (table)) - IF_CHECK_REGISTERED_CATEGORIES (main_categories_registered) + IF_CHECK_REGISTERED_CATEGORIES (main_categories_registered) { + main_category_present = TRUE; continue; + } IF_CHECK_REGISTERED_CATEGORIES (additional_categories_registered) continue; IF_CHECK_REGISTERED_CATEGORIES (reserved_categories_registered) { @@ -1229,6 +1241,13 @@ handle_categories_key (kf_validator *kf, g_strfreev (categories); g_hash_table_destroy (hashtable); + if (!main_category_present) { + print_fatal (kf, "value \"%s\" for key \"%s\" in group \"%s\" " + "does not contain a registered main category\n", + value, locale_key, kf->current_group, categories[i]); + retval = FALSE; + } + return retval; } |