# HG changeset patch # User Matti Hamalainen # Date 1451167388 -7200 # Node ID 0d01efc3c8032aa0d0ebce028548437913236d3f # Parent 6916aaeda9410802aab136ba1280534952ce9874 Factor escape printing to a separate function. diff -r 6916aaeda941 -r 0d01efc3c803 sidinfo.c --- a/sidinfo.c Sat Dec 26 23:22:43 2015 +0200 +++ b/sidinfo.c Sun Dec 27 00:03:08 2015 +0200 @@ -605,6 +605,29 @@ } +static void siPrintStrEscapes(FILE *outFile, const char *str) +{ + while (*str) + { + if (*str == '\\') + { + str++; + switch (*str) + { + case 'n': fputc('\n', outFile); break; + case 'r': fputc('\r', outFile); break; + case 't': fputc('\r', outFile); break; + case '\\': fputc('\\', outFile); break; + } + } + else + fputc(*str, outFile); + + str++; + } +} + + static void siPrintFieldPrefix(FILE *outFile, const char *name) { if (!optNoNamePrefix && !optFormat.nitems) @@ -720,27 +743,7 @@ switch (item->cmd) { case -1: - { - char *str = item->str; - while (*str) - { - if (*str == '\\') - { - str++; - switch (*str) - { - case 'n': fputc('\n', outFile); break; - case 'r': fputc('\r', outFile); break; - case 't': fputc('\r', outFile); break; - case '\\': fputc('\\', outFile); break; - } - } - else - fputc(*str, outFile); - - str++; - } - } + siPrintStrEscapes(outFile, item->str); break; case -2: @@ -749,6 +752,7 @@ default: siPrintPSIDInformationField(outFile, filename, &psid, &shown, item->cmd); + break; } } }