aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_cfg.c
diff options
context:
space:
mode:
authorreinelt <>2004-03-06 20:31:16 +0000
committerreinelt <>2004-03-06 20:31:16 +0000
commit2f5e70edeffe4eb649d3a0577e3913cc5fcda6d7 (patch)
treee8d53c15a9184b19109453e56cf4fc8f8cfac6b0 /plugin_cfg.c
parentf2539b94c0c65abd21168a509a27228696b7f4ee (diff)
downloadlcd4linux-2f5e70edeffe4eb649d3a0577e3913cc5fcda6d7.tar.gz
[lcd4linux @ 2004-03-06 20:31:16 by reinelt]
Complete rewrite of the evaluator to get rid of the code from mark Morley (because of license issues). The new Evaluator does a pre-compile of expressions, and stores them in trees. Therefore it should be reasonable faster...
Diffstat (limited to '')
-rw-r--r--plugin_cfg.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugin_cfg.c b/plugin_cfg.c
index cf81d10..5a853fb 100644
--- a/plugin_cfg.c
+++ b/plugin_cfg.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_cfg.c,v 1.6 2004/03/03 03:47:04 reinelt Exp $
+/* $Id: plugin_cfg.c,v 1.7 2004/03/06 20:31:16 reinelt Exp $
*
* plugin for config file access
*
@@ -23,6 +23,12 @@
*
*
* $Log: plugin_cfg.c,v $
+ * Revision 1.7 2004/03/06 20:31:16 reinelt
+ * Complete rewrite of the evaluator to get rid of the code
+ * from mark Morley (because of license issues).
+ * The new Evaluator does a pre-compile of expressions, and
+ * stores them in trees. Therefore it should be reasonable faster...
+ *
* Revision 1.6 2004/03/03 03:47:04 reinelt
* big patch from Martin Hejl:
* - use qprintf() where appropriate
@@ -79,9 +85,10 @@
static void load_variables (void)
{
- char *section="Variables";
+ char *section = "Variables";
char *list, *l, *p;
char *expression;
+ void *tree;
RESULT result = {0, 0.0, NULL};
list=cfg_list(section);
@@ -94,13 +101,15 @@ static void load_variables (void)
} else {
expression=cfg_get_raw (section, l, "");
if (expression!=NULL && *expression!='\0') {
- if (Eval(expression, &result)==0) {
+ tree = NULL;
+ if (Compile(expression, &tree) == 0 && Eval(tree, &result)==0) {
debug ("Variable %s = '%s' (%f)", l, R2S(&result), R2N(&result));
SetVariable (l, &result);
DelResult (&result);
} else {
error ("error evaluating variable '%s' from %s", list, cfg_source());
}
+ DelTree (tree);
}
}
l=p?p+1:NULL;