improve GFX2_LogHexDump() : dont print consecutive 00's lines
This commit is contained in:
parent
fea7ac6a3c
commit
06d69ac90a
@ -87,9 +87,27 @@ extern void GFX2_LogHexDump(GFX2_Log_priority_T priority, const char * header, c
|
||||
{
|
||||
char line[128];
|
||||
long i;
|
||||
int previous_allzero_count = 0;
|
||||
while (count > 0)
|
||||
{
|
||||
int p = 0, r;
|
||||
int allzero = 1;
|
||||
for (i = 0; i < count && i < 16; i++)
|
||||
{
|
||||
if (data[offset+i] != 0)
|
||||
{
|
||||
allzero = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (previous_allzero_count && allzero)
|
||||
{
|
||||
// prints a single "*" for multiple line of 00's
|
||||
if (previous_allzero_count == 1)
|
||||
GFX2_Log(priority, "*\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
r = snprintf(line + p, sizeof(line) - p, "%s%06lX:", header, offset);
|
||||
if (r < 0)
|
||||
return;
|
||||
@ -116,7 +134,15 @@ extern void GFX2_LogHexDump(GFX2_Log_priority_T priority, const char * header, c
|
||||
line[p++] = data[offset+i]>=32 && data[offset+i]<127 ? data[offset+i] : '.';
|
||||
line[p++] = '\0';
|
||||
GFX2_Log(priority, "%s\n", line);
|
||||
}
|
||||
if (allzero)
|
||||
previous_allzero_count++;
|
||||
else
|
||||
previous_allzero_count = 0;
|
||||
count -= i;
|
||||
offset += i;
|
||||
}
|
||||
// print the ending offset if there was "*"
|
||||
if (previous_allzero_count > 1)
|
||||
GFX2_Log(priority, "%s%06lX\n", header, offset);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user