diff -pur cdrdao-1.1.9/dao/Settings.cc cdrdao-1.1.9-fixed/dao/Settings.cc --- cdrdao-1.1.9/dao/Settings.cc 2004-06-05 21:40:52.000000000 +0200 +++ cdrdao-1.1.9-fixed/dao/Settings.cc 2005-02-05 22:35:02.958248808 +0100 @@ -186,33 +186,33 @@ int SettingsImpl::read(FILE *fp) while (fgets(buf, MAX_LINE_LENGTH, fp) != NULL) { // handle comment if ((p = strchr(buf, '#')) != NULL) - *p = 0; + continue; if ((p = strchr(buf, ':')) != NULL) { *p++ = 0; p1 = buf; while (*p1 != 0 && isspace(*p1)) - p1++; + p1++; name = p1; while (*p1 != 0 && !isspace(*p1)) - p1++; + p1++; *p1 = 0; while (*p != 0 && isspace(*p)) - p++; + p++; // strip off trailing white space if ((n = strlen(p)) > 0) { - for (p1 = p + n - 1; p1 >= p; p1--) { - if (isspace(*p1)) { - *p1 = 0; - } - } + for (p1 = p + n - 1; p1 >= p; p1--) { + if (isspace(*p1)) { + *p1 = 0; + } + } } - + parseAndSetValue(name, p); } } @@ -230,20 +230,24 @@ void SettingsImpl::parseAndSetValue(char return; if (*valStr == '"') { - val = p = valStr + 1; - - while (*p != 0 && *p != '"') - p++; - - if (*p == '"') { - *p = 0; - + val = valStr + 1; + p = val + strlen(val)-1; + if (*p != '"') { + fprintf(stderr,"Error in string constant '%s'\n", valStr); + } else { + *p=0; set(name, val); } - } - else { - intValue = strtol(valStr, NULL, 0); - set(name, intValue); + + } else { /* valSTR is numeric? */ + char * end = NULL; + errno=0; + intValue = strtol(valStr, &end, 0); + if(errno != 0 || !end || *end) { + fprintf(stderr,"Error parsing numeric option '%s' (missing quotes?)\n", + valStr); + } else + set(name, intValue); } }