Mercurial > hg > dmlib
changeset 1110:ea2cc4932714
Improve output of dumpmod.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 04 Mar 2015 01:10:35 +0200 |
parents | c8bcdddf233c |
children | f9a96fc2a932 |
files | tools/dumpmod.c |
diffstat | 1 files changed, 32 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/dumpmod.c Wed Mar 04 00:58:25 2015 +0200 +++ b/tools/dumpmod.c Wed Mar 04 01:10:35 2015 +0200 @@ -112,18 +112,23 @@ static const char jmpMODEffectTable[jmpNMODEffectTable] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +void printEscaped(FILE *f, const char *str) +{ + while (*str) + { + fputc(isprint(*str) ? *str : '*', f); + str++; + } +} + + /* Print a given pattern */ void printPattern(FILE *f, JSSPattern *p) { int i, j; char c; - JSSNote *n; - - if (!p) - return; - - n = p->data; + JSSNote *n = p->data; for (i = 0; i < p->nrows; i++) { @@ -233,16 +238,14 @@ void printExtInstrument(FILE *f, JSSExtInstrument *i) { - if (!i) - { - fprintf(f, "\n"); - return; - } - #ifndef JSS_LIGHT if (i->desc && !optDump) + { fprintf(f, - "Description: '%s'\n", i->desc); + "Description: '"); + printEscaped(f, i->desc); + fprintf(f, "'\n"); + } #endif fprintf(f, "nsamples.......: %i\n" @@ -265,17 +268,16 @@ void printInstrument(FILE *f, JSSInstrument *i) { - if (!i) - { - fprintf(f, "\n"); - return; - } - if (dmVerbosity >= 1) { #ifndef JSS_LIGHT if (i->desc && !optDump) - fprintf(f, "Description: '%s'\n", i->desc); + { + fprintf(f, + "Description: '"); + printEscaped(f, i->desc); + fprintf(f, "'\n"); + } #endif fprintf(f, "size...........: %ld (0x%lx)\n" @@ -306,7 +308,10 @@ { #ifndef JSS_LIGHT if (i->desc && !optDump) - fprintf(f, "%s|", i->desc); + { + printEscaped(f, i->desc); + fprintf(f, "|"); + } #endif fprintf(f, "%8ld|%8ld..%-8ld|%03d|%-2s %-2s %-2s|" @@ -443,8 +448,9 @@ if (optViewPatterns) { for (i = 0; i < mod->npatterns; i++) + if (mod->patterns[i] != NULL) { - printf("\nPattern #%03i:\n", i); + printf("\nPattern #%02x:\n", i); printPattern(stdout, mod->patterns[i]); } } @@ -456,8 +462,9 @@ "---------------\n" ); for (i = 0; i < mod->nextInstruments; i++) + if (mod->extInstruments[i] != NULL) { - printf("#%03d: ", i + 1); + printf("#%02x: ", i + 1); printExtInstrument(stdout, mod->extInstruments[i]); } } @@ -469,8 +476,9 @@ "------------\n" ); for (i = 0; i < mod->ninstruments; i++) + if (mod->instruments[i] != NULL) { - printf("#%03d: ", i + 1); + printf("#%02x: ", i + 1); printInstrument(stdout, mod->instruments[i]); } }