# HG changeset patch # User Matti Hamalainen # Date 1174749063 0 # Node ID 7fcaf6b59b20de1e1f9c3642edfd7b746a41d816 # Parent 1f7a4ce04cb9dc1cdcd3ecdebdfc459ee6dcf715 Cleanups. diff -r 1f7a4ce04cb9 -r 7fcaf6b59b20 src/xs_config.c --- a/src/xs_config.c Sat Mar 24 14:29:00 2007 +0000 +++ b/src/xs_config.c Sat Mar 24 15:11:03 2007 +0000 @@ -397,10 +397,23 @@ /* Filter exporting and importing. These functions export/import * filter settings to/from SIDPlay2 INI-type files. */ +static gboolean xs_fgetitem(gchar *inLine, size_t *linePos, gchar sep, gchar *tmpStr, size_t tmpMax) +{ + size_t i; + for (i = 0; i < tmpMax && inLine[*linePos] && + !isspace(inLine[*linePos]) && + inLine[*linePos] != sep; i++, (*linePos)++) + tmpStr[i] = inLine[*linePos]; + tmpStr[i] = 0; + xs_findnext(inLine, linePos); + return (inLine[*linePos] == sep); +} + static gboolean xs_filters_import(gchar *pcFilename, t_xs_sid2_filter **pFilters, gint *nFilters) { FILE *inFile; - gchar inLine[XS_BUF_SIZE], tmpStr[256], *sectName; + gchar inLine[XS_BUF_SIZE], tmpStr[XS_BUF_SIZE]; + gchar *sectName = NULL; gboolean sectBegin; size_t lineNum, i; t_xs_sid2_filter *f; @@ -421,30 +434,31 @@ xs_findnext(inLine, &linePos); if (isalpha(inLine[linePos]) && sectBegin) { /* A new key/value pair */ - i = 0; - while (i < 256 && inLine[linePos] && !isspace(inLine[linePos]) && inLine[linePos] != '=') { - tmpStr[i++] = inLine[linePos++]; - } - tmpStr[i] = 0; - xs_findnext(inLine, &linePos); - if (inLine[linePos] != '=') { + if (!xs_fgetitem(inLine, &linePos, '=', tmpStr, XS_BUF_SIZE)) { fprintf(stderr, "invalid line: %s [expect =']'", inLine); } else { linePos++; xs_findnext(inLine, &linePos); - if (!isdigit(inLine[linePos])) { - fprintf(stderr, "expected numeric: %s\n", inLine); + if (!strncmp(tmpStr, "points", 6)) { + fprintf(stderr, "points=%s\n", &inLine[linePos]); + } else if (!strncmp(tmpStr, "point", 5)) { + } else if (!strncmp(tmpStr, "type", 4)) { } else { - + fprintf(stderr, "warning: ukn def: %s @ %s\n", + tmpStr, sectName); } } } else if (inLine[linePos] == '[') { + /* Check for existing section */ + if (sectBegin) { + fprintf(stderr, "filter ends: %s\n", sectName); + g_free(sectName); + } + /* New filter(?) section starts */ linePos++; - i = 0; - while (i < 256 && inLine[linePos] && inLine[linePos] != ']') { - tmpStr[i++] = inLine[linePos++]; - } + for (i = 0; i < XS_BUF_SIZE && inLine[linePos] && inLine[linePos] != ']'; i++, linePos++) + tmpStr[i] = inLine[linePos]; tmpStr[i] = 0; if (inLine[linePos] != ']') { @@ -717,10 +731,11 @@ } /* Get filter settings */ - if (!xs_curve_get_points(XS_CURVE(LUW(""), &xs_cfg.sid2Filter.points, &xs_cfg.sid2Filter.npoints)) { - // FIXME + /* + if (!xs_curve_get_points(XS_CURVE(LUW("")), &xs_cfg.sid2Filter.points, &xs_cfg.sid2Filter.npoints)) { xs_error(_("Warning: Could not get filter curve widget points!\n")); } + */ /* Release lock */ XS_MUTEX_UNLOCK(xs_cfg);