From 19c2af0c6928b97a2b9f88958ff846e2a087cd84 Mon Sep 17 00:00:00 2001 From: Simeon Voelkel Date: Tue, 12 Aug 2008 12:39:48 +0200 Subject: [PATCH] added section part to parser --- src/backend/configitem.c | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/backend/configitem.c b/src/backend/configitem.c index 1148b3486..a64995aeb 100644 --- a/src/backend/configitem.c +++ b/src/backend/configitem.c @@ -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 {