[AD] Reading config strings var="val"

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


I did an enhancement to src/config.c:get_config_string() to be able to use
var="val" syntax in config files. Diff is in attached file. But it breaks
up a backward compatibility, because when there is "str" it uses static
buffer and it seems working but nobody knows. It can't be added just into
loading of config, because "a","b" can be a","b for get_config_string()
and a,b for get_config_argv.

Stepan Roh
--- config.c.orig	Sun Jan 30 22:46:56 2000
+++ config.c	Thu Feb  3 14:35:57 2000
@@ -658,6 +658,7 @@
    char section_name[256];
    CONFIG_HOOK *hook;
    CONFIG_ENTRY *p;
+   static char tmp_buf[256];
 
    init_config(TRUE);
 
@@ -686,9 +687,13 @@
 	 p = find_config_string(config[0], section_name, name, NULL);
    }
 
-   if (p)
-      return (p->data ? p->data : empty_string);
-   else
+   if (p) {
+      if (p->data && (ugetc (p->data) == '"') && (ugetat (p->data, -1) == '"')) {
+         ustrncpy (tmp_buf, p->data + ucwidth ('"'), ustrlen (p->data) - 2);
+         return tmp_buf;
+      } else
+         return (p->data ? p->data : empty_string);
+   } else
       return def;
 }
 


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