use default error handler if none is specified
authorMatthias Braun <matze@braunis.de>
Tue, 14 Oct 2008 10:55:11 +0000 (10:55 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 14 Oct 2008 10:55:11 +0000 (10:55 +0000)
[r22873]

ir/libcore/lc_opts.c

index f58107c..f9b84b7 100644 (file)
@@ -708,9 +708,16 @@ void lc_opt_print_tree(lc_opt_entry_t *ent, FILE *f)
        lc_opt_print_tree_grp_indent(ent, f, 0);
 }
 
+static int lc_opts_default_error_handler(const char *prefix, const lc_opt_err_info_t *err)
+{
+       fprintf(stderr, "%s: %s; %s\n", prefix, err->msg, err->arg);
+       return 0;
+}
 
 void lc_opt_from_file(const char *filename, FILE *f, lc_opt_error_handler_t *handler)
 {
+       if (handler == NULL)
+               handler = lc_opts_default_error_handler;
        PMANGLE(in) = f;
        lc_opt_init_parser(filename, handler);
        PMANGLE(parse)();
@@ -815,12 +822,6 @@ int lc_opt_from_single_arg(const lc_opt_entry_t *root,
        return ret;
 }
 
-static int lc_opts_default_error_handler(const char *prefix, const lc_opt_err_info_t *err)
-{
-       fprintf(stderr, "%s: %s; %s\n", prefix, err->msg, err->arg);
-       return 0;
-}
-
 int lc_opt_from_argv(const lc_opt_entry_t *root,
                                         const char *opt_prefix,
                                         int argc, const char *argv[],