From e79db0177bbc83fb5154ee0efa1650c0a48bdf98 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 14 Jul 2013 12:18:35 -0400 Subject: [PATCH] Allow validating multiple desktop files There is no good reason to not allow this. https://bugs.freedesktop.org/show_bug.cgi?id=60744 --- src/validator.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/validator.c b/src/validator.c index 20512a6..df12a92 100644 --- a/src/validator.c +++ b/src/validator.c @@ -37,7 +37,7 @@ static GOptionEntry option_entries[] = { { "no-hints", 0, 0, G_OPTION_ARG_NONE, &no_hints, "Do not output hints to improve desktop file", NULL }, { "no-warn-deprecated", 0, 0, G_OPTION_ARG_NONE, &no_warn_deprecated, "Do not warn about usage of deprecated items", NULL }, { "warn-kde", 0, 0, G_OPTION_ARG_NONE, &warn_kde, "Warn about usage of KDE extensions to the specification", NULL }, - { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filename, NULL, "" }, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filename, NULL, "..." }, { NULL } }; @@ -46,6 +46,8 @@ main (int argc, char *argv[]) { GOptionContext *context; GError *error; + int i; + gboolean all_valid; context = g_option_context_new (NULL); g_option_context_set_summary (context, "Validate desktop entry files " @@ -66,19 +68,20 @@ main (int argc, char *argv[]) g_option_context_free (context); - /* only accept one desktop file argument */ - if (filename == NULL || filename[0] == NULL || filename[1] != NULL) { - g_printerr ("See \"%s --help\" for correct usage.\n", g_get_prgname ()); - return 1; - } + all_valid = TRUE; - if (!g_file_test (filename[0], G_FILE_TEST_IS_REGULAR)) { - g_printerr ("%s: file does not exist\n", filename[0]); - return 1; + for (i = 0; filename[i]; i++) { + if (!g_file_test (filename[i], G_FILE_TEST_IS_REGULAR)) { + g_printerr ("%s: file does not exist\n", filename[i]); + all_valid = FALSE; + } + + if (!desktop_file_validate (filename[i], warn_kde, no_warn_deprecated, no_hints)) + all_valid = FALSE; } - if (desktop_file_validate (filename[0], warn_kde, no_warn_deprecated, no_hints)) - return 0; - else + if (!all_valid) return 1; + + return 0; } -- 1.8.3.1