be consequent: don't warn about config files, simply don't read them by default
authorMatthias Braun <matze@braunis.de>
Tue, 14 Oct 2008 07:32:19 +0000 (07:32 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 14 Oct 2008 07:32:19 +0000 (07:32 +0000)
[r22868]

ir/common/firm.c
ir/libcore/lc_opts.c
ir/libcore/lc_opts.h

index 2084a0b..105296a 100644 (file)
@@ -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)
index d34f6c8..f58107c 100644 (file)
@@ -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);
 }
index 191ac81..671d7bf 100644 (file)
@@ -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 .<ini_name>rc (on win32 <ini_name>.ini)
  *
  * and an ini file in the current directory which is called <ini_name>.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