changeset 2432:758223ba6551

Only print grep value lists if verbosity >= 1.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 19 Feb 2020 18:00:49 +0200
parents ca548150de6b
children 2fcd8d712b1e
files tools/fanalyze.c
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/tools/fanalyze.c	Wed Feb 19 01:52:36 2020 +0200
+++ b/tools/fanalyze.c	Wed Feb 19 18:00:49 2020 +0200
@@ -239,7 +239,7 @@
 }
 
 
-void dmPrintGrepValueList(const DMGrepValue *node, const BOOL match, DMSourceFile *file, const size_t offs)
+void dmPrintGrepValueList(FILE *fh, const DMGrepValue *node, const BOOL match, DMSourceFile *file, const size_t offs)
 {
     char mfmt[16];
     unsigned int bsize = dmGrepTypes[node->type].bsize;
@@ -251,20 +251,20 @@
 
     for (int n = 0; n < node->nvalues; n++)
     {
-        const char *veol = (n + 1 < node->nvalues) ? " " : "\n";
+        const char *veol = (n + 1 < node->nvalues) ? " " : "";
 
         if (match)
         {
             Uint32 mval;
             dmGetData(node->type, file, offs + n * bsize, &mval);
-            printf(mfmt, mval, veol);
+            fprintf(fh, mfmt, mval, veol);
         }
         else
         {
             if (node->vwildcards[n])
-                printf("?%s", veol);
+                fprintf(fh, "?%s", veol);
             else
-                printf(mfmt, node->values[n], veol);
+                fprintf(fh, mfmt, node->values[n], veol);
         }
     }
 }
@@ -467,7 +467,8 @@
             printf("Grep %s: ",
                 dmGrepTypes[val.type].name);
 
-            dmPrintGrepValueList(node, FALSE, NULL, 0);
+            dmPrintGrepValueList(stdout, node, FALSE, NULL, 0);
+            printf("\n");
         }
     }
     else
@@ -737,8 +738,13 @@
 
                     if (match)
                     {
-                        printf("%08" DM_PRIx_SIZE_T " : ", offs);
-                        dmPrintGrepValueList(node, TRUE, file, offs);
+                        printf("%08" DM_PRIx_SIZE_T, offs);
+                        if (dmVerbosity >= 1)
+                        {
+                            printf(" : ");
+                            dmPrintGrepValueList(stdout, node, TRUE, file, offs);
+                        }
+                        printf("\n");
                     }
                 }
             }