Commit 99742544 99742544152a9c8bfea535120f54039dffe4eb1b by Sergey Poznyakoff

Bugfixes.

* libcfg/acl.c (parsearg): Initialize size.
* mailbox/cfg_driver.c (mu_cfg_assert_value_type): Bugfix.
* mailbox/cfg_lexer.l (mu_get_config): Close file.
* mailbox/cfg_parser.y: Fix array creation.
1 parent 7c8e01ff
2008-08-19 Sergey Poznyakoff <gray@gnu.org.ua>
* libcfg/acl.c (parsearg): Initialize size.
* mailbox/cfg_driver.c (mu_cfg_assert_value_type): Bugfix.
* mailbox/cfg_lexer.l (mu_get_config): Close file.
* mailbox/cfg_parser.y: Fix array creation.
Change configuration file parser based on the lexer/parser from
GNU Dico.
......
......@@ -47,6 +47,7 @@
#include <mailutils/mutil.h>
#include <mailutils/nls.h>
#include <mailutils/observer.h>
#include <mailutils/opool.h>
#include <mailutils/parse822.h>
#include <mailutils/pop3.h>
#include <mailutils/property.h>
......
......@@ -162,7 +162,7 @@ parsearg (mu_debug_t err, mu_config_value_t *val, struct netdef *pnd,
*prest = NULL;
else
{
size_t size;
size_t size = 0;
int i;
char *buf;
......
......@@ -649,14 +649,40 @@ mu_parse_config (const char *file, const char *progname,
return rc;
}
static const char *
_first_value_ptr (mu_config_value_t *val)
{
switch (val->type)
{
case MU_CFG_STRING:
return val->v.string;
case MU_CFG_ARRAY:
return _first_value_ptr (val->v.arg.v);
case MU_CFG_LIST:
mu_list_get (val->v.list, 0, (void**) &val);
return _first_value_ptr (val);
}
return "";
}
int
mu_cfg_assert_value_type (mu_config_value_t *val, int type, mu_debug_t debug)
{
if (val->type != MU_CFG_STRING)
if (!val)
{
mu_cfg_format_error (debug, MU_DEBUG_ERROR,
_("required argument missing"));
return 1;
}
if (val->type != type)
{
/* FIXME */
mu_cfg_format_error (debug, MU_DEBUG_ERROR,
_("expected string value"));
_("unexpected value: %s"),
_first_value_ptr (val));
return 1;
}
return 0;
......
......@@ -324,7 +324,7 @@ mu_get_config (const char *file, const char *progname,
mu_cfg_locus.line = 1;
yyrestart (fp);
rc = mu_cfg_parse (&parse_tree);
fclose (fp);
if (rc == 0)
rc = mu_cfg_tree_reduce (parse_tree, progname, progparam, flags,
target_ptr);
......
......@@ -268,7 +268,11 @@ vallist : vlist
}
for (i = 0; i < n; i++)
mu_list_get ($1, i, (void **) &val.v.arg.v[i]);
{
mu_config_value_t *v;
mu_list_get ($1, i, (void **) &v);
val.v.arg.v[i] = *v;
}
$$ = config_value_dup (&val);
}
mu_list_destroy (&$1);
......