# HG changeset patch # User Matti Hamalainen # Date 1103641444 0 # Node ID f436e16fa6d9bd1f731cd3e98ef5737dfed2eeab # Parent 7833df935239979fdd305173741123e940c272db Fixed cosmetic bug in handling of multi-line fields (COMMENT). diff -r 7833df935239 -r f436e16fa6d9 src/xs_stil.c --- a/src/xs_stil.c Tue Dec 21 15:03:05 2004 +0000 +++ b/src/xs_stil.c Tue Dec 21 15:04:04 2004 +0000 @@ -91,13 +91,16 @@ /* Read database (additively) to given db-structure */ +#define XS_STILDB_MULTI if (isMulti) { isMulti = FALSE; xs_pstrcat(&(tmpNode->subTune[subEntry].pInfo), "\n"); } + + gint xs_stildb_read(t_xs_stildb *db, gchar *dbFilename) { FILE *inFile; - gchar inLine[XS_BUFSIZE + 10]; + gchar inLine[XS_BUF_SIZE + 16]; /* Since we add some chars here and there */ guint lineNum, linePos, eolPos; t_xs_stil_node *tmpNode; - gboolean isError; + gboolean isError, isMulti; gint subEntry; assert(db); @@ -111,12 +114,14 @@ /* Read and parse the data */ lineNum = 0; isError = FALSE; + isMulti = FALSE; tmpNode = NULL; subEntry = 0; while (!feof(inFile) && !isError) { - fgets(inLine, XS_BUFSIZE, inFile); + fgets(inLine, XS_BUF_SIZE, inFile); + inLine[XS_BUF_SIZE-1] = 0; linePos = eolPos = 0; xs_findeol(inLine, &eolPos); inLine[eolPos] = 0; @@ -191,31 +196,45 @@ /* Some other type */ if (strncmp(inLine, " NAME:", 8) == 0) { + XS_STILDB_MULTI + g_free(tmpNode->subTune[subEntry].pName); tmpNode->subTune[subEntry].pName = g_strdup(&inLine[9]); } else if (strncmp(inLine, " AUTHOR:", 8) == 0) { + XS_STILDB_MULTI + g_free(tmpNode->subTune[subEntry].pAuthor); tmpNode->subTune[subEntry].pAuthor = g_strdup(&inLine[9]); } else if (strncmp(inLine, " TITLE:", 8) == 0) { + XS_STILDB_MULTI + inLine[eolPos++] = '\n'; inLine[eolPos++] = 0; xs_pstrcat(&(tmpNode->subTune[subEntry].pInfo), &inLine[2]); } else if (strncmp(inLine, " ARTIST:", 8) == 0) { + XS_STILDB_MULTI + inLine[eolPos++] = '\n'; inLine[eolPos++] = 0; xs_pstrcat(&(tmpNode->subTune[subEntry].pInfo), &inLine[1]); } else if (strncmp(inLine, "COMMENT:", 8) == 0) + { + XS_STILDB_MULTI + + isMulti = TRUE; xs_pstrcat(&(tmpNode->subTune[subEntry].pInfo), inLine); - else + } else if (strncmp(inLine, " ", 8) == 0) + { xs_pstrcat(&(tmpNode->subTune[subEntry].pInfo), &inLine[8]); + } break; }