aboutsummaryrefslogtreecommitdiffstats
path: root/src/mds-kbdc/mds-kbdc.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-23 02:24:36 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-23 02:24:36 +0100
commite59c7db7e26853e033242f404ffc4cfb639add2e (patch)
tree6d67132319ff3631833da4e9691d257a2567ac79 /src/mds-kbdc/mds-kbdc.c
parentwhitespace (diff)
downloadmds-e59c7db7e26853e033242f404ffc4cfb639add2e.tar.gz
mds-e59c7db7e26853e033242f404ffc4cfb639add2e.tar.bz2
mds-e59c7db7e26853e033242f404ffc4cfb639add2e.tar.xz
some code simplificiations
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mds-kbdc/mds-kbdc.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/mds-kbdc/mds-kbdc.c b/src/mds-kbdc/mds-kbdc.c
index dc3327f..f7bfb06 100644
--- a/src/mds-kbdc/mds-kbdc.c
+++ b/src/mds-kbdc/mds-kbdc.c
@@ -38,33 +38,23 @@
*/
int main(int argc_, char** argv_)
{
- mds_kbdc_parse_error_t** parse_errors;
- mds_kbdc_tree_t* tree;
+ mds_kbdc_parsed_t result;
+ int fatal;
argc = argc_;
argv = argv_;
- fail_if (parse_to_tree(argv[1], &tree, &parse_errors) < 0);
- mds_kbdc_tree_print(tree, stderr);
- if (parse_errors != NULL)
- {
- mds_kbdc_parse_error_t** errors = parse_errors;
- int fatal = 0;
- while (*errors)
- {
- if ((*errors)->severity >= MDS_KBDC_PARSE_ERROR_ERROR)
- fatal = 1;
- mds_kbdc_parse_error_print(*errors++, stderr);
- }
- mds_kbdc_parse_error_free_all(parse_errors);
- if (fatal)
- return mds_kbdc_tree_free(tree), 1;
- }
- mds_kbdc_tree_free(tree);
- return 0;
+ mds_kbdc_parsed_initialise(&result);
+ fail_if (parse_to_tree(argv[1], &result) < 0);
+ fatal = mds_kbdc_parsed_is_fatal(&result);
+ mds_kbdc_tree_print(result.tree, stderr);
+ mds_kbdc_parsed_print_errors(&result, stderr);
+ mds_kbdc_parsed_destroy(&result);
+ return fatal;
pfail:
xperror(*argv);
+ mds_kbdc_parsed_destroy(&result);
return 1;
}