comparison tools/fanalyze.c @ 2431:ca548150de6b

Fix grepping of consecutive values in fanalyze when using > byte size types.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 19 Feb 2020 01:52:36 +0200
parents 190f5caaf1a8
children 758223ba6551
comparison
equal deleted inserted replaced
2430:190f5caaf1a8 2431:ca548150de6b
240 240
241 241
242 void dmPrintGrepValueList(const DMGrepValue *node, const BOOL match, DMSourceFile *file, const size_t offs) 242 void dmPrintGrepValueList(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 246
246 snprintf(mfmt, sizeof(mfmt), "%%%s%d%s%%s", 247 snprintf(mfmt, sizeof(mfmt), "%%%s%d%s%%s",
247 dmGrepDisp[node->disp].fmtPrefix, 248 dmGrepDisp[node->disp].fmtPrefix,
248 dmGrepTypes[node->type].bsize * 2, 249 bsize * 2,
249 dmGrepDisp[node->disp].fmt); 250 dmGrepDisp[node->disp].fmt);
250 251
251 for (int n = 0; n < node->nvalues; n++) 252 for (int n = 0; n < node->nvalues; n++)
252 { 253 {
253 const char *veol = (n + 1 < node->nvalues) ? " " : "\n"; 254 const char *veol = (n + 1 < node->nvalues) ? " " : "\n";
254 255
255 if (match) 256 if (match)
256 { 257 {
257 Uint32 mval; 258 Uint32 mval;
258 dmGetData(node->type, file, offs + n, &mval); 259 dmGetData(node->type, file, offs + n * bsize, &mval);
259 printf(mfmt, mval, veol); 260 printf(mfmt, mval, veol);
260 } 261 }
261 else 262 else
262 { 263 {
263 if (node->vwildcards[n]) 264 if (node->vwildcards[n])
723 BOOL match = TRUE; 724 BOOL match = TRUE;
724 for (int n = 0; n < node->nvalues; n++) 725 for (int n = 0; n < node->nvalues; n++)
725 if (!node->vwildcards[n]) 726 if (!node->vwildcards[n])
726 { 727 {
727 Uint32 mval; 728 Uint32 mval;
728 dmGetData(node->type, file, offs + n, &mval); 729 dmGetData(node->type, file, offs + n * def->bsize, &mval);
729 730
730 if (mval != node->values[n]) 731 if (mval != node->values[n])
731 { 732 {
732 match = FALSE; 733 match = FALSE;
733 break; 734 break;