pmap: fixing the width measurement of extended_pmap with -q
This commit fixes the width measurement of the extended pmap function to work correctly with the -q switch. With no header and no footer only widths of the particular values matter.
This commit is contained in:
parent
c80e93be47
commit
5c513ce582
22
pmap.c
22
pmap.c
@ -306,7 +306,7 @@ static void print_extended_maps (FILE *f)
|
|||||||
offset[NUM_LENGTH], inode[NUM_LENGTH],
|
offset[NUM_LENGTH], inode[NUM_LENGTH],
|
||||||
dev[64], vmflags[VMFLAGS_LENGTH];
|
dev[64], vmflags[VMFLAGS_LENGTH];
|
||||||
int maxw1=0, maxw2=0, maxw3=0, maxw4=0, maxw5=0, maxwv=0;
|
int maxw1=0, maxw2=0, maxw3=0, maxw4=0, maxw5=0, maxwv=0;
|
||||||
int nfields, firstmapping, footer_gap, i, width_of_total;
|
int nfields, firstmapping, footer_gap, i, maxw_;
|
||||||
unsigned KLONG value;
|
unsigned KLONG value;
|
||||||
char *ret, *map_basename, c, has_vmflags = 0;
|
char *ret, *map_basename, c, has_vmflags = 0;
|
||||||
|
|
||||||
@ -359,7 +359,8 @@ static void print_extended_maps (FILE *f)
|
|||||||
listtail = listnode;
|
listtail = listnode;
|
||||||
/* listnode was calloc()ed so all fields are already NULL! */
|
/* listnode was calloc()ed so all fields are already NULL! */
|
||||||
strcpy(listnode->description, detail_desc);
|
strcpy(listnode->description, detail_desc);
|
||||||
listnode->max_width = strlen(detail_desc);
|
if (!q_option) listnode->max_width = strlen(detail_desc);
|
||||||
|
else listnode->max_width = 0;
|
||||||
} else {
|
} else {
|
||||||
/* === LIST EXISTS === */
|
/* === LIST EXISTS === */
|
||||||
if (strcmp(listnode->description, detail_desc) != 0)
|
if (strcmp(listnode->description, detail_desc) != 0)
|
||||||
@ -371,6 +372,11 @@ static void print_extended_maps (FILE *f)
|
|||||||
sscanf(value_str, "%"KLF"u", &listnode->value);
|
sscanf(value_str, "%"KLF"u", &listnode->value);
|
||||||
if (firstmapping == 2) {
|
if (firstmapping == 2) {
|
||||||
listnode->total += listnode->value;
|
listnode->total += listnode->value;
|
||||||
|
if (q_option) {
|
||||||
|
maxw_ = strlen(listnode->value_str);
|
||||||
|
if (maxw_ > listnode->max_width)
|
||||||
|
listnode->max_width = maxw_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
listnode = listnode->next;
|
listnode = listnode->next;
|
||||||
loop_end:
|
loop_end:
|
||||||
@ -393,11 +399,13 @@ loop_end:
|
|||||||
fseek(f, 0, SEEK_SET); /* ... and repeat the process with printing enabled */
|
fseek(f, 0, SEEK_SET); /* ... and repeat the process with printing enabled */
|
||||||
ret = fgets(mapbuf, sizeof mapbuf, f); /* this is not ideal and needs to be redesigned one day */
|
ret = fgets(mapbuf, sizeof mapbuf, f); /* this is not ideal and needs to be redesigned one day */
|
||||||
|
|
||||||
/* calculate width of totals */
|
if (!q_option) {
|
||||||
for (listnode=listhead; listnode!=NULL; listnode=listnode->next) {
|
/* calculate width of totals */
|
||||||
width_of_total = integer_width(listnode->total);
|
for (listnode=listhead; listnode!=NULL; listnode=listnode->next) {
|
||||||
if (width_of_total > listnode->max_width)
|
maxw_ = integer_width(listnode->total);
|
||||||
listnode->max_width = width_of_total;
|
if (maxw_ > listnode->max_width)
|
||||||
|
listnode->max_width = maxw_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user