X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Flibcore%2Flc_opts.c;h=f9b84b7b066e048360f0042fc055048fd9f2afb8;hb=38249b0311df91904bb3a566a770efe650f40efc;hp=d34f6c85ec326d7ed530e9ba2b277c4bdca841fe;hpb=11ab4a7adef7f8be573d4d51e69030d9abd8c70f;p=libfirm diff --git a/ir/libcore/lc_opts.c b/ir/libcore/lc_opts.c index d34f6c85e..f9b84b7b0 100644 --- a/ir/libcore/lc_opts.c +++ b/ir/libcore/lc_opts.c @@ -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)(); @@ -823,6 +830,9 @@ int lc_opt_from_argv(const lc_opt_entry_t *root, int i; int options_set = 0; + if (handler == NULL) + handler = lc_opts_default_error_handler; + for(i = 0; i < argc; ++i) { options_set |= lc_opt_from_single_arg(root, opt_prefix, argv[i], handler); } @@ -890,13 +900,7 @@ const lc_arg_env_t *lc_opt_get_arg_env(void) return env; } -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_opts_init(const char *ini_name, lc_opt_entry_t *root, const char *arg_prefix, int argc, const char **argv) +void lc_opt_default_configs(const char *ini_name) { FILE *f; char path[MAX_PATH]; @@ -939,7 +943,6 @@ void lc_opts_init(const char *ini_name, lc_opt_entry_t *root, const char *arg_pr /* Process ini file in user's home. */ f = fopen(path, "rt"); if (f) { - fprintf(stderr, "Warning: Automatically reading options from '%s'\n", path); lc_opt_from_file(path, f, lc_opts_default_error_handler); fclose(f); } @@ -947,11 +950,7 @@ void lc_opts_init(const char *ini_name, lc_opt_entry_t *root, const char *arg_pr /* Process ini file in current directory. */ f = fopen(local_ini_file, "rt"); if (f) { - fprintf(stderr, "Warning: Automatically reading options from '%s'\n", local_ini_file); lc_opt_from_file(local_ini_file, f, lc_opts_default_error_handler); fclose(f); } - - /* process arguments from the command line */ - lc_opt_from_argv(root, arg_prefix, argc, argv, lc_opts_default_error_handler); }