From: Matthias Braun Date: Tue, 14 Oct 2008 07:32:19 +0000 (+0000) Subject: be consequent: don't warn about config files, simply don't read them by default X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=dff7693f7e553fa1f6f1f034db2a46274620c9e2;p=libfirm be consequent: don't warn about config files, simply don't read them by default [r22868] --- diff --git a/ir/common/firm.c b/ir/common/firm.c index 2084a0bd7..105296a7f 100644 --- a/ir/common/firm.c +++ b/ir/common/firm.c @@ -73,8 +73,8 @@ lc_opt_entry_t *firm_opt_get_root(void) { } void firm_init_options(const char *arg_prefix, int argc, const char **argv) { - /* parse any init files for firm */ - lc_opts_init("firm", firm_opt_get_root(), arg_prefix, argc, argv); + /* parse commandline */ + lc_opt_from_argv(firm_opt_get_root(), arg_prefix, argc, argv, NULL); } void init_firm(const firm_parameter_t *param) diff --git a/ir/libcore/lc_opts.c b/ir/libcore/lc_opts.c index d34f6c85e..f58107c1f 100644 --- a/ir/libcore/lc_opts.c +++ b/ir/libcore/lc_opts.c @@ -815,6 +815,12 @@ 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[], @@ -823,6 +829,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 +899,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 +942,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 +949,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); } diff --git a/ir/libcore/lc_opts.h b/ir/libcore/lc_opts.h index 191ac8113..671d7bf12 100644 --- a/ir/libcore/lc_opts.h +++ b/ir/libcore/lc_opts.h @@ -312,21 +312,13 @@ int lc_opt_from_single_arg(const lc_opt_entry_t *grp, const lc_arg_env_t *lc_opt_get_arg_env(void); /** - * Standard procedure for options initialization. - * @param cmnt_name Base name for the file. - * @param root The option's root. - * @param arg_prefix A prefix that is added to each option. - * @param argc Number of entries in @p argv. - * @param argv A stadard argument vector. - * * This function tries to open a ini file in the user's homedir * (On win32 this is \Documents and Settings\Application Data) * which is called .rc (on win32 .ini) * * and an ini file in the current directory which is called .ini on * both systems. - * Afterwards, the argument vectors are processed. */ -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 *init_name); #endif