# HG changeset patch # User Matti Hamalainen # Date 1455527464 -7200 # Node ID cc74a9871a44aab76043cf07da4542b7af758d58 # Parent cd97e7517e218627ffd0e469574da7281bd794e8 Simplify. diff -r cd97e7517e21 -r cc74a9871a44 sidinfo.c --- 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; } }