changeset 114:cc74a9871a44

Simplify.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 15 Feb 2016 11:11:04 +0200
parents cd97e7517e21
children 6843261b4cd6
files sidinfo.c
diffstat 1 files changed, 15 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/sidinfo.c	Mon Feb 15 11:08:59 2016 +0200
+++ b/sidinfo.c	Mon Feb 15 11:11:04 2016 +0200
@@ -444,9 +444,10 @@
 #define PR(xfmt, xaltfmt, ...) siPrintPSIDInfoLine(outFile, shown, xindex, xfmt, xaltfmt, __VA_ARGS__ )
 
 
-static void siPrintPSIDInformationField(FILE *outFile, const char *filename, const PSIDHeader *psid, BOOL *shown, const int xindex)
+static void siPrintPSIDInformationField(FILE *outFile, const char *filename, const PSIDHeader *psid, BOOL *shown, const PSFStackItem *item)
 {
-    switch (xindex)
+    const PSFOption *opt = &optPSOptions[item->cmd];
+    switch (item->cmd)
     {
         case  0: PR("%s", NULL, filename); break;
         case  1: PR("%s", NULL, psid->magic); break;
@@ -477,30 +478,24 @@
         case 16: PR("%s", NULL, psid->sidCopyright); break;
 
         case 17:
-            {
-                const PSFOption *opt = &optPSOptions[xindex];
-                siPrintFieldPrefix(outFile, opt);
-                th_md5_print(outFile, psid->hash);
-                siPrintFieldSeparator(outFile);
-            }
+            siPrintFieldPrefix(outFile, opt);
+            th_md5_print(outFile, psid->hash);
+            siPrintFieldSeparator(outFile);
             break;
 
         case 18:
+            siPrintFieldPrefix(outFile, opt);
+            if (psid->lengths != NULL)
             {
-                const PSFOption *opt = &optPSOptions[xindex];
-                siPrintFieldPrefix(outFile, opt);
-                if (psid->lengths != NULL)
+                int i;
+                for (i = 0; i < psid->lengths->nlengths; i++)
                 {
-                    int i;
-                    for (i = 0; i < psid->lengths->nlengths; i++)
-                    {
-                        int len = psid->lengths->lengths[i];
-                        fprintf(outFile, "%d:%d%s", len / 60, len % 60,
-                            (i < psid->lengths->nlengths - 1) ? " " : "");
-                    }
+                    int len = psid->lengths->lengths[i];
+                    fprintf(outFile, "%d:%d%s", len / 60, len % 60,
+                        (i < psid->lengths->nlengths - 1) ? " " : "");
                 }
-                siPrintFieldSeparator(outFile);
             }
+            siPrintFieldSeparator(outFile);
             break;
 
     }
@@ -550,7 +545,7 @@
                 break;
 
             default:
-                siPrintPSIDInformationField(outFile, filename, &psid, &shown, item->cmd);
+                siPrintPSIDInformationField(outFile, filename, &psid, &shown, item);
                 break;
         }
     }