Merge branch 'configloader_devel' of git://git.lumiera.org/lumiera/simeon into backend_devel
* 'configloader_devel' of git://git.lumiera.org/lumiera/simeon: (24 commits) Added directive-parser and tests for a content-check of a parsed configitem Fixed configitem_move, first parsing tests pass now FIX: Remove llist_move again and put a note to list_relocate, add test WIP: add config_lookup skeleton filedescriptor fixup for new copy func in cuckoo add a custom copy function to the cuckoo hash fixes after the cuckoo update in filedescriptor.c Cuckoo hash update Added two very simple tests for configitem Typo fix Fix for section-parser added section part to parser parser improvements, compiles now added CONFIG_SYNTAX errors typo fix and redundant comment removal add configitem and configentry to the build system give the charsets for config keys some constants fix to make parser mockup compileable, little simplified WIP: started low-level parser more functional mockup of the configitem bootstrap ... Conflicts: src/backend/config.c src/backend/config.h src/backend/config_lookup.c src/backend/config_lookup.h src/backend/configitem.c src/backend/configitem.h src/backend/filedescriptor.c src/lib/cuckoo.c src/lib/cuckoo.h tests/22config_highlevel.tests tests/backend/test-config.c
This commit is contained in:
commit
c4e6cd3c51
4 changed files with 158 additions and 2 deletions
|
|
@ -107,7 +107,6 @@ lumiera_configitem_new (const char* line)
|
|||
? tmp.vtable->new (&tmp)
|
||||
: lumiera_configitem_move (lumiera_malloc (sizeof (*self)), &tmp);
|
||||
|
||||
TRACE (config_item, "key size of %s is %d", tmp.key, tmp.key_size);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
@ -215,6 +214,60 @@ lumiera_configitem_parse (LumieraConfigitem self, const char* line)
|
|||
else if (*itr == '@' )
|
||||
{
|
||||
/*this is a directive*/
|
||||
|
||||
/*itr points now to @*/
|
||||
self->key = itr;
|
||||
|
||||
/*check whether there are illegal whitespaces after @*/
|
||||
itr++;
|
||||
if (*itr && !isspace(*itr))
|
||||
{
|
||||
/*now look for the end of the directive and set the keysize*/
|
||||
self->key_size = strspn (itr, LUMIERA_CONFIG_KEY_CHARS);
|
||||
|
||||
itr += self->key_size;
|
||||
|
||||
/*we need a key with a length greather than zero and
|
||||
* either the end of the line
|
||||
* or a whitespace after the key */
|
||||
|
||||
if ( self->key_size && ( !*itr || (*itr && isspace(*itr)) ))
|
||||
{
|
||||
/*look for given arguments*/
|
||||
|
||||
/*skip blanks*/
|
||||
while (*itr && isspace (*itr))
|
||||
itr++;
|
||||
|
||||
if (*itr)
|
||||
{
|
||||
/*there are arguments given, thus set delim*/
|
||||
self->delim = itr - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*no arguments were given*/
|
||||
self->delim = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*malformed lines shall be treated like if they were comments*/
|
||||
self->key = NULL;
|
||||
self->key_size = 0;
|
||||
|
||||
LUMIERA_ERROR_SET (config_item, CONFIG_SYNTAX);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*there occurred already an error right after the @!*/
|
||||
/*malformed lines shall be treated like if they were comments*/
|
||||
self->key = NULL;
|
||||
self->key_size = 0;
|
||||
|
||||
LUMIERA_ERROR_SET (config_item, CONFIG_SYNTAX);
|
||||
}
|
||||
}
|
||||
else if (*itr == '[' )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -128,3 +128,65 @@ END
|
|||
|
||||
PLANNED "bool set" <<END
|
||||
END
|
||||
|
||||
TEST "create configitem with empty line" configitem_simple_ctor_dtor '' <<END
|
||||
END
|
||||
|
||||
TEST "create configitem with blank line" configitem_simple_ctor_dtor $' \t \t' <<END
|
||||
END
|
||||
|
||||
TEST "create configitem with comment" configitem_simple_ctor_dtor $' #\t comment bla' <<END
|
||||
END
|
||||
|
||||
TEST "create configitem with section" configitem_simple_ctor_dtor $'\t[prefix suffix ] bla' <<END
|
||||
END
|
||||
|
||||
TEST "create configitem with directive" configitem_simple_ctor_dtor $' @include \t\t file \t' <<END
|
||||
END
|
||||
|
||||
TEST "create configitem with configentry" configitem_simple_ctor_dtor $' key \t=\t value' <<END
|
||||
END
|
||||
|
||||
TEST "create configitem with configentry (redirect)" configitem_simple_ctor_dtor $'keya <\t\t keyb ' <<END
|
||||
END
|
||||
|
||||
TEST "check content of configitem with empty line" configitem_simple_content_check $'' << END
|
||||
END
|
||||
|
||||
TEST "check content of configitem with comment" configitem_simple_content_check $'\t #comment bla' << END
|
||||
out: item->line = ' #comment bla'
|
||||
END
|
||||
|
||||
TEST "check content of configitem with section" configitem_simple_content_check $'[ key.foo suffix.bar ] ' << END
|
||||
out: item->line = '[ key.foo suffix.bar ] '
|
||||
out: item->key_size = '7'
|
||||
out: item->key = 'key.foo suffix.bar ] '
|
||||
out: item->delim = ' suffix.bar ] '
|
||||
END
|
||||
|
||||
TEST "check content of configitem with directive (without argument)" configitem_simple_content_check $'\t @directive ' << END
|
||||
out: item->line = ' @directive '
|
||||
out: item->key_size = '9'
|
||||
out: item->key = '@directive '
|
||||
END
|
||||
|
||||
TEST "check content of configitem with directive (with argument)" configitem_simple_content_check $'\t @directive \targument' << END
|
||||
out: item->line = ' @directive argument'
|
||||
out: item->key_size = '9'
|
||||
out: item->key = '@directive argument'
|
||||
out: item->delim = ' argument'
|
||||
END
|
||||
|
||||
TEST "check content of configitem with configentry" configitem_simple_content_check $' \t\t key.foo \t\t=\tbar' << END
|
||||
out: item->line = ' key.foo = bar'
|
||||
out: item->key_size = '7'
|
||||
out: item->key = 'key.foo = bar'
|
||||
out: item->delim = '= bar'
|
||||
END
|
||||
|
||||
TEST "check content of configitem with configentry (redirect)" configitem_simple_content_check $' \t\t key.foo \t\t<\tkey.bar' << END
|
||||
out: item->line = ' key.foo < key.bar'
|
||||
out: item->key_size = '7'
|
||||
out: item->key = 'key.foo < key.bar'
|
||||
out: item->delim = '< key.bar'
|
||||
END
|
||||
|
|
|
|||
|
|
@ -178,4 +178,45 @@ TEST ("word_get")
|
|||
lumiera_config_destroy ();
|
||||
}
|
||||
|
||||
TEST ("configitem_simple_ctor_dtor")
|
||||
{
|
||||
REQUIRE (argv[2]);
|
||||
lumiera_config_init ("./");
|
||||
|
||||
LumieraConfigitem item;
|
||||
|
||||
item = lumiera_configitem_new (argv[2]);
|
||||
|
||||
lumiera_config_destroy ();
|
||||
}
|
||||
|
||||
TEST ("configitem_simple_content_check")
|
||||
{
|
||||
REQUIRE (argv[2]);
|
||||
lumiera_config_init ("./");
|
||||
|
||||
LumieraConfigitem item;
|
||||
|
||||
item = lumiera_configitem_new (argv[2]);
|
||||
|
||||
if ( item->line )
|
||||
{
|
||||
printf("item->line = '%s'\n", item->line);
|
||||
}
|
||||
if ( item->key_size )
|
||||
{
|
||||
printf("item->key_size = '%zi'\n", item->key_size);
|
||||
}
|
||||
if ( item->key )
|
||||
{
|
||||
printf("item->key = '%s'\n", item->key);
|
||||
}
|
||||
if ( item->delim )
|
||||
{
|
||||
printf("item->delim = '%s'\n", item->delim);
|
||||
}
|
||||
|
||||
lumiera_config_destroy ();
|
||||
}
|
||||
|
||||
TESTS_END
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
test-llist.c - test the linked lis lib
|
||||
test-llist.c - test the linked list lib
|
||||
|
||||
Copyright (C) Lumiera.org
|
||||
2008, Christian Thaeter <ct@pipapo.org>
|
||||
|
|
|
|||
Loading…
Reference in a new issue