From dbf5d92605a9db10e3e3cb154d03a515c5d5c5af Mon Sep 17 00:00:00 2001 From: reinelt Date: Sun, 8 May 2005 04:32:45 +0000 Subject: [lcd4linux @ 2005-05-08 04:32:43 by reinelt] CodingStyle added and applied git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@547 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- plugin_cfg.c | 149 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 77 insertions(+), 72 deletions(-) (limited to 'plugin_cfg.c') diff --git a/plugin_cfg.c b/plugin_cfg.c index 2996045..323c04d 100644 --- a/plugin_cfg.c +++ b/plugin_cfg.c @@ -1,4 +1,4 @@ -/* $Id: plugin_cfg.c,v 1.13 2005/03/30 04:57:50 reinelt Exp $ +/* $Id: plugin_cfg.c,v 1.14 2005/05/08 04:32:44 reinelt Exp $ * * plugin for config file access * @@ -23,6 +23,9 @@ * * * $Log: plugin_cfg.c,v $ + * Revision 1.14 2005/05/08 04:32:44 reinelt + * CodingStyle added and applied + * * Revision 1.13 2005/03/30 04:57:50 reinelt * Evaluator speedup: use bsearch for finding functions and variables * @@ -111,89 +114,91 @@ #endif -static void load_variables (void) +static void load_variables(void) { - char *section = "Variables"; - char *list, *l, *p; - char *expression; - void *tree; - RESULT result = {0, 0, 0, NULL}; - - list=cfg_list(section); - l=list; - while (l!=NULL) { - while (*l=='|') l++; - if ((p=strchr(l, '|'))!=NULL) *p='\0'; - if (strchr(l, '.')!=NULL || strchr(l, ':') !=0) { - error ("ignoring variable '%s' from %s: structures not allowed", l, cfg_source()); - } else { - expression=cfg_get_raw (section, l, ""); - if (expression!=NULL && *expression!='\0') { - tree = NULL; - if (Compile(expression, &tree) == 0 && Eval(tree, &result)==0) { - SetVariable (l, &result); - debug ("Variable %s = '%s' (%g)", l, R2S(&result), R2N(&result)); - DelResult (&result); - } else { - error ("error evaluating variable '%s' from %s", list, cfg_source()); - } - DelTree (tree); - } + char *section = "Variables"; + char *list, *l, *p; + char *expression; + void *tree; + RESULT result = { 0, 0, 0, NULL }; + + list = cfg_list(section); + l = list; + while (l != NULL) { + while (*l == '|') + l++; + if ((p = strchr(l, '|')) != NULL) + *p = '\0'; + if (strchr(l, '.') != NULL || strchr(l, ':') != 0) { + error("ignoring variable '%s' from %s: structures not allowed", l, cfg_source()); + } else { + expression = cfg_get_raw(section, l, ""); + if (expression != NULL && *expression != '\0') { + tree = NULL; + if (Compile(expression, &tree) == 0 && Eval(tree, &result) == 0) { + SetVariable(l, &result); + debug("Variable %s = '%s' (%g)", l, R2S(&result), R2N(&result)); + DelResult(&result); + } else { + error("error evaluating variable '%s' from %s", list, cfg_source()); + } + DelTree(tree); + } + } + l = p ? p + 1 : NULL; } - l=p?p+1:NULL; - } - free (list); - + free(list); + } -static void my_cfg (RESULT *result, const int argc, RESULT *argv[]) +static void my_cfg(RESULT * result, const int argc, RESULT * argv[]) { - int i, len; - char *value; - char *buffer; - - /* calculate key length */ - len=0; - for (i=0; i