diff sidinfo.c @ 311:ee56f1f2b528

Change how the STIL subtune are handled internally. Also fix a bug that caused the _last_ STIL field of each subtune not to be printed at all :S
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 11 Jan 2020 14:25:23 +0200
parents ff93c168c4aa
children b3d46806787d
line wrap: on
line diff
--- a/sidinfo.c	Sat Jan 11 13:51:02 2020 +0200
+++ b/sidinfo.c	Sat Jan 11 14:25:23 2020 +0200
@@ -1182,18 +1182,16 @@
 
                 // We need to count the number of fields to be outputted
                 // beforehand, so we can know when we are at the last one
-                for (int nsubtune = 0; nsubtune < psid->stil->nsubtunes; nsubtune++)
-                if (psid->stil->subtunes[nsubtune] != NULL)
+                for (size_t nsubtune = 0; nsubtune < psid->stil->nsubtunes; nsubtune++)
                 {
-                    SIDLibSTILSubTune *subtune = psid->stil->subtunes[nsubtune];
+                    SIDLibSTILSubTune *subtune = &psid->stil->subtunes[nsubtune];
                     for (int nfield = 0; nfield < STF_LAST; nfield++)
                         nfieldcount += subtune->fields[nfield].ndata;
                 }
 
-                for (int nsubtune = 0; nsubtune < psid->stil->nsubtunes; nsubtune++)
-                if (psid->stil->subtunes[nsubtune] != NULL)
+                for (size_t nsubtune = 0; nsubtune < psid->stil->nsubtunes; nsubtune++)
                 {
-                    SIDLibSTILSubTune *subtune = psid->stil->subtunes[nsubtune];
+                    SIDLibSTILSubTune *subtune = &psid->stil->subtunes[nsubtune];
                     int maxdata = 0;
 
                     // For each subtune we need to check the max number of field data items
@@ -1214,7 +1212,7 @@
                             if (nsubtune > 0)
                             {
                                 snprintf(tmp, sizeof(tmp), "STIL#%d/%s",
-                                    nsubtune, sidlib_stil_fields[nfield]);
+                                    subtune->tune, sidlib_stil_fields[nfield]);
                             }
                             else
                             {