honor appended -c option for --check

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
kardan 2013-06-12 14:15:54 +02:00 committed by Uli Schlachter
parent 0c62831eea
commit 57bec371f7
1 changed files with 17 additions and 10 deletions

View File

@ -288,6 +288,7 @@ main(int argc, char **argv)
ssize_t cmdlen = 1; ssize_t cmdlen = 1;
xdgHandle xdg; xdgHandle xdg;
bool no_argb = false; bool no_argb = false;
bool run_test = false;
xcb_generic_event_t *event; xcb_generic_event_t *event;
xcb_query_tree_cookie_t tree_c; xcb_query_tree_cookie_t tree_c;
static struct option long_options[] = static struct option long_options[] =
@ -340,16 +341,8 @@ main(int argc, char **argv)
exit_help(EXIT_SUCCESS); exit_help(EXIT_SUCCESS);
break; break;
case 'k': case 'k':
if(!luaA_parserc(&xdg, confpath, false)) run_test = true;
{ break;
fprintf(stderr, "✘ Configuration file syntax error.\n");
return EXIT_FAILURE;
}
else
{
fprintf(stderr, "✔ Configuration file syntax OK.\n");
return EXIT_SUCCESS;
}
case 'c': case 'c':
if(a_strlen(optarg)) if(a_strlen(optarg))
confpath = a_strdup(optarg); confpath = a_strdup(optarg);
@ -361,6 +354,20 @@ main(int argc, char **argv)
break; break;
} }
if (run_test)
{
if(!luaA_parserc(&xdg, confpath, false))
{
fprintf(stderr, "✘ Configuration file syntax error.\n");
return EXIT_FAILURE;
}
else
{
fprintf(stderr, "✔ Configuration file syntax OK.\n");
return EXIT_SUCCESS;
}
}
/* register function for signals */ /* register function for signals */
g_unix_signal_add(SIGINT, exit_on_signal, NULL); g_unix_signal_add(SIGINT, exit_on_signal, NULL);
g_unix_signal_add(SIGTERM, exit_on_signal, NULL); g_unix_signal_add(SIGTERM, exit_on_signal, NULL);