[AD] patch for config.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


With this patch the configuration routines will try to set variables
in the config_override file first (if it's open), if not, it will use
the current Allegro configuration file.

This is useful to make an override_config_file("myfile.cfg") at the
beginning of your program without use pop/push config states everytime
you want to set a variable.

The override_config_file(NULL) closes the config_override file (this
should be documented).

-- 
http://www.davidcapello.com.ar
Index: config.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/config.c,v
retrieving revision 1.26
diff -u -r1.26 config.c
--- config.c	7 Aug 2004 22:43:49 -0000	1.26
+++ config.c	31 Oct 2004 01:26:14 -0000
@@ -527,8 +527,14 @@
  */
 void override_config_file(AL_CONST char *filename)
 {
-   ASSERT(filename);
-   load_config_file(&config_override, filename, NULL);
+   /* load other configuration file to override settings */
+   if (filename)
+      load_config_file(&config_override, filename, filename);
+   /* destroy the current one */
+   else if (config_override) {
+      destroy_config(config_override);
+      config_override = NULL;
+   }
 }
 
 
@@ -1030,6 +1036,8 @@
    /* decide which config file to use */
    if ((ugetc(name) == '#') || ((ugetc(section_name) == '[') && (ugetat(section_name, 1) == '#')))
       the_config = system_config;
+   else if (config_override)
+      the_config = config_override;
    else
       the_config = config[0];
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/