From 3c6f6382eef14b880550cbf28ac5a517d0a075fc Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 26 May 2023 12:34:11 +0200 Subject: libbb/dump: conditionalize code used only by xxd and od Signed-off-by: Denys Vlasenko --- coreutils/od.c | 2 +- include/dump.h | 4 ++++ libbb/dump.c | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/coreutils/od.c b/coreutils/od.c index 3fd241d51..46aba5a7c 100644 --- a/coreutils/od.c +++ b/coreutils/od.c @@ -223,7 +223,7 @@ int od_main(int argc, char **argv) return bb_dump_dump(dumper, argv); } -#endif /* ENABLE_DESKTOP */ +#endif /* !ENABLE_DESKTOP */ /*- * Copyright (c) 1990 The Regents of the University of California. diff --git a/include/dump.h b/include/dump.h index 11dcf4523..8fb92f07b 100644 --- a/include/dump.h +++ b/include/dump.h @@ -33,8 +33,12 @@ 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 */ long long xxd_displayoff; } dumper_t; diff --git a/libbb/dump.c b/libbb/dump.c index 77d76611b..21c6c7083 100644 --- a/libbb/dump.c +++ b/libbb/dump.c @@ -563,17 +563,21 @@ static NOINLINE void display(priv_dumper_t* dumper) if (dumper->eaddress && dumper->pub.address >= dumper->eaddress ) { +#if ENABLE_XXD if (dumper->pub.xxd_eofstring) { /* xxd support: requested to not pad incomplete blocks */ fputs_stdout(dumper->pub.xxd_eofstring); return; } +#endif +#if ENABLE_OD if (dumper->pub.od_eofstring) { /* od support: requested to not pad incomplete blocks */ /* ... but do print final offset */ fputs_stdout(dumper->pub.od_eofstring); goto endfu; } +#endif if (!(pr->flags & (F_TEXT | F_BPAD))) bpad(pr); } @@ -637,7 +641,7 @@ static NOINLINE void display(priv_dumper_t* dumper) goto skip; } printf(pr->fmt, value); - skip: + IF_OD(skip:) break; } case F_P: -- cgit v1.2.3-55-g6feb