changeset 240:f436e16fa6d9

Fixed cosmetic bug in handling of multi-line fields (COMMENT).
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 21 Dec 2004 15:04:04 +0000
parents 7833df935239
children 291715a519e2
files src/xs_stil.c
diffstat 1 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
  }