From 1a66b58fcb15dfecb3665a9abb3f6317fd237cc8 Mon Sep 17 00:00:00 2001 From: Simeon Voelkel Date: Tue, 12 Aug 2008 10:29:05 +0200 Subject: [PATCH] added CONFIG_SYNTAX errors --- src/backend/configitem.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/backend/configitem.c b/src/backend/configitem.c index bf413e7e5..075304c37 100644 --- a/src/backend/configitem.c +++ b/src/backend/configitem.c @@ -190,6 +190,7 @@ lumiera_configitem_parse (LumieraConfigitem self, const char* line) * */ char* itr = self->line; + bool faultless = true; /*skip leading whitespaces*/ while (*itr && isspace (*itr)) @@ -199,6 +200,9 @@ lumiera_configitem_parse (LumieraConfigitem self, const char* line) if (!*itr || *itr == '#' ) { /*this is an empty line or a a comment*/ + self->key = NULL; + self->keysize = 0; + self->delim = NULL; } else if (*itr == '@' ) { @@ -218,7 +222,17 @@ lumiera_configitem_parse (LumieraConfigitem self, const char* line) /*now look for the end of the key and set the keysize*/ self->key_size = strspn (itr, LUMIERA_CONFIG_KEY_CHARS); - TODO ("if(self->keysize==0) then key_syntax_error"); + if ( self->keysize==0 ) + { + /*Obviously a malformed "key"; treat this line like a comment*/ + self->key = NULL; + self->keysize = 0; + self->delim = NULL; + + LUMIERA_ERROR_SET (config_item, CONFIG_SYNTAX); + + faultless = false; + } /* skip blanks */ itr += self->key_size; @@ -234,10 +248,21 @@ lumiera_configitem_parse (LumieraConfigitem self, const char* line) self->delim = itr; } else - TODO ("syntax error"); + { + /*this is not a valid configentry; treat this line like a comment*/ + self->key = NULL; + self->keysize = 0; + self->delim = NULL; - /* TODO only if still everything ok */ - self->vtable = &lumiera_configentry_funcs; // MOCKUP pretend this is a configentry + LUMIERA_ERROR_SET (config_item, CONFIG_SYNTAX); + faultless = false; + } + + /*just set vtable if we are sure we had no syntax-error*/ + if (faultless) + { + self->vtable = &lumiera_configentry_funcs; // MOCKUP pretend this is a configentry + } }