libbb/dump: conditionalize code used only by xxd and od
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
aa4d303a31
commit
3c6f6382ee
3 changed files with 10 additions and 2 deletions
|
@ -223,7 +223,7 @@ int od_main(int argc, char **argv)
|
||||||
|
|
||||||
return bb_dump_dump(dumper, argv);
|
return bb_dump_dump(dumper, argv);
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_DESKTOP */
|
#endif /* !ENABLE_DESKTOP */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990 The Regents of the University of California.
|
* Copyright (c) 1990 The Regents of the University of California.
|
||||||
|
|
|
@ -33,8 +33,12 @@ typedef struct dumper_t {
|
||||||
int dump_length; /* max bytes to read */
|
int dump_length; /* max bytes to read */
|
||||||
smallint dump_vflag; /*enum dump_vflag_t*/
|
smallint dump_vflag; /*enum dump_vflag_t*/
|
||||||
FS *fshead;
|
FS *fshead;
|
||||||
|
#if ENABLE_XXD
|
||||||
const char *xxd_eofstring;
|
const char *xxd_eofstring;
|
||||||
|
#endif
|
||||||
|
#if ENABLE_OD
|
||||||
const char *od_eofstring;
|
const char *od_eofstring;
|
||||||
|
#endif
|
||||||
off_t address; /* address/offset in stream */
|
off_t address; /* address/offset in stream */
|
||||||
long long xxd_displayoff;
|
long long xxd_displayoff;
|
||||||
} dumper_t;
|
} dumper_t;
|
||||||
|
|
|
@ -563,17 +563,21 @@ static NOINLINE void display(priv_dumper_t* dumper)
|
||||||
if (dumper->eaddress
|
if (dumper->eaddress
|
||||||
&& dumper->pub.address >= dumper->eaddress
|
&& dumper->pub.address >= dumper->eaddress
|
||||||
) {
|
) {
|
||||||
|
#if ENABLE_XXD
|
||||||
if (dumper->pub.xxd_eofstring) {
|
if (dumper->pub.xxd_eofstring) {
|
||||||
/* xxd support: requested to not pad incomplete blocks */
|
/* xxd support: requested to not pad incomplete blocks */
|
||||||
fputs_stdout(dumper->pub.xxd_eofstring);
|
fputs_stdout(dumper->pub.xxd_eofstring);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if ENABLE_OD
|
||||||
if (dumper->pub.od_eofstring) {
|
if (dumper->pub.od_eofstring) {
|
||||||
/* od support: requested to not pad incomplete blocks */
|
/* od support: requested to not pad incomplete blocks */
|
||||||
/* ... but do print final offset */
|
/* ... but do print final offset */
|
||||||
fputs_stdout(dumper->pub.od_eofstring);
|
fputs_stdout(dumper->pub.od_eofstring);
|
||||||
goto endfu;
|
goto endfu;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (!(pr->flags & (F_TEXT | F_BPAD)))
|
if (!(pr->flags & (F_TEXT | F_BPAD)))
|
||||||
bpad(pr);
|
bpad(pr);
|
||||||
}
|
}
|
||||||
|
@ -637,7 +641,7 @@ static NOINLINE void display(priv_dumper_t* dumper)
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
printf(pr->fmt, value);
|
printf(pr->fmt, value);
|
||||||
skip:
|
IF_OD(skip:)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case F_P:
|
case F_P:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue