added section part to parser

This commit is contained in:
Simeon Voelkel 2008-08-12 12:39:48 +02:00
parent e86ef0ba75
commit 19c2af0c69

View file

@ -208,6 +208,70 @@ lumiera_configitem_parse (LumieraConfigitem self, const char* line)
else if (*itr == '[' )
{
/*this is a section*/
/*skip blanks before prefix*/
while (*itr && isspace(*itr))
itr++;
/*itr points now to the begin of the key*/
self->key = itr;
/*now look for the end of the key and set the keysize*/
self->key_size = strspn (itr, LUMIERA_CONFIG_KEY_CHARS);
itr += self->key_size;
/*if the line ends ends with prefix] delim points to ]
* and not the last (blank) character before the final square bracket*/
if (self->key_size && *itr && *itr == ']')
{
self->delim = itr;
TODO("self->vtable = &lumiera_configsection_funcs;");
}
else if (self->key_size && *itr && isspace(*itr))
{
/* skip blanks until we reach the suffix or the final square bracket*/
while (*itr && isspace(*itr))
itr++;
if (*itr && *itr == ']')
{
/*final square bracket reached, so place delim one char before the
* actual position which must be a whitespace: no extra check necessary*/
self->delim = itr - 1;
TODO("self->vtable = &lumiera_configsection_funcs;");
}
else if (*itr)
{
TODO("check wheter suffix is made of legal characters");
/*delim points to the last whitespace before the actual position;
* no extra check needed*/
self->delim = itr - 1;
TODO("self->vtable = &lumiera_configsection_funcs;");
}
else
{
/*malformed section line, treat this line like a comment*/
self->key = NULL;
self->key_size = 0;
LUMIERA_ERROR_SET (config_item, CONFIG_SYNTAX);
}
}
else
{
/*error: either *itr is false, points neither to a blank nor to a closed square
* bracket or the key_size is zero*/
/*treat this line like a comment*/
self->key = NULL;
self->key_size = 0;
LUMIERA_ERROR_SET (config_item, CONFIG_SYNTAX);
}
}
else
{