aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_cfg.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-03-06 20:31:16 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-03-06 20:31:16 +0000
commitc008748638679f10746c70a7f677c0e8906ffa9e (patch)
treee8d53c15a9184b19109453e56cf4fc8f8cfac6b0 /plugin_cfg.c
parent2f4f59ba2e28ee38f721f09ab6756fd4575b3f78 (diff)
downloadlcd4linux-c008748638679f10746c70a7f677c0e8906ffa9e.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... git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@387 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_cfg.c')
-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;