Mercurial > hg > dmlib
comparison tools/fanalyze.c @ 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 |
comparison
equal
deleted
inserted
replaced
2431:ca548150de6b | 2432:758223ba6551 |
---|---|
237 } | 237 } |
238 return TRUE; | 238 return TRUE; |
239 } | 239 } |
240 | 240 |
241 | 241 |
242 void dmPrintGrepValueList(const DMGrepValue *node, const BOOL match, DMSourceFile *file, const size_t offs) | 242 void dmPrintGrepValueList(FILE *fh, const DMGrepValue *node, const BOOL match, DMSourceFile *file, const size_t offs) |
243 { | 243 { |
244 char mfmt[16]; | 244 char mfmt[16]; |
245 unsigned int bsize = dmGrepTypes[node->type].bsize; | 245 unsigned int bsize = dmGrepTypes[node->type].bsize; |
246 | 246 |
247 snprintf(mfmt, sizeof(mfmt), "%%%s%d%s%%s", | 247 snprintf(mfmt, sizeof(mfmt), "%%%s%d%s%%s", |
249 bsize * 2, | 249 bsize * 2, |
250 dmGrepDisp[node->disp].fmt); | 250 dmGrepDisp[node->disp].fmt); |
251 | 251 |
252 for (int n = 0; n < node->nvalues; n++) | 252 for (int n = 0; n < node->nvalues; n++) |
253 { | 253 { |
254 const char *veol = (n + 1 < node->nvalues) ? " " : "\n"; | 254 const char *veol = (n + 1 < node->nvalues) ? " " : ""; |
255 | 255 |
256 if (match) | 256 if (match) |
257 { | 257 { |
258 Uint32 mval; | 258 Uint32 mval; |
259 dmGetData(node->type, file, offs + n * bsize, &mval); | 259 dmGetData(node->type, file, offs + n * bsize, &mval); |
260 printf(mfmt, mval, veol); | 260 fprintf(fh, mfmt, mval, veol); |
261 } | 261 } |
262 else | 262 else |
263 { | 263 { |
264 if (node->vwildcards[n]) | 264 if (node->vwildcards[n]) |
265 printf("?%s", veol); | 265 fprintf(fh, "?%s", veol); |
266 else | 266 else |
267 printf(mfmt, node->values[n], veol); | 267 fprintf(fh, mfmt, node->values[n], veol); |
268 } | 268 } |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 | 272 |
465 if (mode == FA_GREP) | 465 if (mode == FA_GREP) |
466 { | 466 { |
467 printf("Grep %s: ", | 467 printf("Grep %s: ", |
468 dmGrepTypes[val.type].name); | 468 dmGrepTypes[val.type].name); |
469 | 469 |
470 dmPrintGrepValueList(node, FALSE, NULL, 0); | 470 dmPrintGrepValueList(stdout, node, FALSE, NULL, 0); |
471 printf("\n"); | |
471 } | 472 } |
472 } | 473 } |
473 else | 474 else |
474 { | 475 { |
475 ret = dmError(DMERR_BOUNDS, | 476 ret = dmError(DMERR_BOUNDS, |
735 } | 736 } |
736 } | 737 } |
737 | 738 |
738 if (match) | 739 if (match) |
739 { | 740 { |
740 printf("%08" DM_PRIx_SIZE_T " : ", offs); | 741 printf("%08" DM_PRIx_SIZE_T, offs); |
741 dmPrintGrepValueList(node, TRUE, file, offs); | 742 if (dmVerbosity >= 1) |
743 { | |
744 printf(" : "); | |
745 dmPrintGrepValueList(stdout, node, TRUE, file, offs); | |
746 } | |
747 printf("\n"); | |
742 } | 748 } |
743 } | 749 } |
744 } | 750 } |
745 } | 751 } |
746 } | 752 } |