libbb/dump: make xxd_displayoff member conditional on xxd

With xxd not selected:

function                                             old     new   delta
display                                             1459    1444     -15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2023-05-27 14:51:46 +02:00
parent 6d9427420b
commit 9225f9684f
2 changed files with 14 additions and 6 deletions

View File

@ -33,14 +33,14 @@ typedef struct dumper_t {
int dump_length; /* max bytes to read */
smallint dump_vflag; /*enum dump_vflag_t*/
FS *fshead;
#if ENABLE_XXD
const char *xxd_eofstring;
#endif
#if ENABLE_OD
const char *od_eofstring;
#endif
off_t address; /* address/offset in stream */
#if ENABLE_XXD
const char *xxd_eofstring;
long long xxd_displayoff;
#endif
off_t address; /* address/offset in stream */
} dumper_t;
dumper_t* alloc_dumper(void) FAST_FUNC;

View File

@ -590,7 +590,11 @@ static NOINLINE void display(priv_dumper_t* dumper)
}
switch (pr->flags) {
case F_ADDRESS:
printf(pr->fmt, (unsigned long long) dumper->pub.address + dumper->pub.xxd_displayoff);
printf(pr->fmt, (unsigned long long) dumper->pub.address
#if ENABLE_XXD
+ dumper->pub.xxd_displayoff
#endif
);
break;
case F_BPAD:
printf(pr->fmt, "");
@ -699,7 +703,11 @@ static NOINLINE void display(priv_dumper_t* dumper)
for (pr = dumper->endfu->nextpr; pr; pr = pr->nextpr) {
switch (pr->flags) {
case F_ADDRESS:
printf(pr->fmt, (unsigned long long) dumper->eaddress + dumper->pub.xxd_displayoff);
printf(pr->fmt, (unsigned long long) dumper->eaddress
#if ENABLE_XXD
+ dumper->pub.xxd_displayoff
#endif
);
break;
case F_TEXT:
fputs_stdout(pr->fmt);