aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-05-26 12:34:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-05-26 12:34:11 +0200
commit3c6f6382eef14b880550cbf28ac5a517d0a075fc (patch)
treefa4a969aabbc2514c13279176add39441b341972
parentaa4d303a3139107919f73cece4eaf85a7dc75db6 (diff)
downloadbusybox-w32-3c6f6382eef14b880550cbf28ac5a517d0a075fc.tar.gz
busybox-w32-3c6f6382eef14b880550cbf28ac5a517d0a075fc.tar.bz2
busybox-w32-3c6f6382eef14b880550cbf28ac5a517d0a075fc.zip
libbb/dump: conditionalize code used only by xxd and od
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/od.c2
-rw-r--r--include/dump.h4
-rw-r--r--libbb/dump.c6
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)
223 223
224 return bb_dump_dump(dumper, argv); 224 return bb_dump_dump(dumper, argv);
225} 225}
226#endif /* ENABLE_DESKTOP */ 226#endif /* !ENABLE_DESKTOP */
227 227
228/*- 228/*-
229 * Copyright (c) 1990 The Regents of the University of California. 229 * 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 {
33 int dump_length; /* max bytes to read */ 33 int dump_length; /* max bytes to read */
34 smallint dump_vflag; /*enum dump_vflag_t*/ 34 smallint dump_vflag; /*enum dump_vflag_t*/
35 FS *fshead; 35 FS *fshead;
36#if ENABLE_XXD
36 const char *xxd_eofstring; 37 const char *xxd_eofstring;
38#endif
39#if ENABLE_OD
37 const char *od_eofstring; 40 const char *od_eofstring;
41#endif
38 off_t address; /* address/offset in stream */ 42 off_t address; /* address/offset in stream */
39 long long xxd_displayoff; 43 long long xxd_displayoff;
40} dumper_t; 44} 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)
563 if (dumper->eaddress 563 if (dumper->eaddress
564 && dumper->pub.address >= dumper->eaddress 564 && dumper->pub.address >= dumper->eaddress
565 ) { 565 ) {
566#if ENABLE_XXD
566 if (dumper->pub.xxd_eofstring) { 567 if (dumper->pub.xxd_eofstring) {
567 /* xxd support: requested to not pad incomplete blocks */ 568 /* xxd support: requested to not pad incomplete blocks */
568 fputs_stdout(dumper->pub.xxd_eofstring); 569 fputs_stdout(dumper->pub.xxd_eofstring);
569 return; 570 return;
570 } 571 }
572#endif
573#if ENABLE_OD
571 if (dumper->pub.od_eofstring) { 574 if (dumper->pub.od_eofstring) {
572 /* od support: requested to not pad incomplete blocks */ 575 /* od support: requested to not pad incomplete blocks */
573 /* ... but do print final offset */ 576 /* ... but do print final offset */
574 fputs_stdout(dumper->pub.od_eofstring); 577 fputs_stdout(dumper->pub.od_eofstring);
575 goto endfu; 578 goto endfu;
576 } 579 }
580#endif
577 if (!(pr->flags & (F_TEXT | F_BPAD))) 581 if (!(pr->flags & (F_TEXT | F_BPAD)))
578 bpad(pr); 582 bpad(pr);
579 } 583 }
@@ -637,7 +641,7 @@ static NOINLINE void display(priv_dumper_t* dumper)
637 goto skip; 641 goto skip;
638 } 642 }
639 printf(pr->fmt, value); 643 printf(pr->fmt, value);
640 skip: 644 IF_OD(skip:)
641 break; 645 break;
642 } 646 }
643 case F_P: 647 case F_P: