Pārlūkot izejas kodu

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>
Denys Vlasenko 1 gadu atpakaļ
vecāks
revīzija
9225f9684f
2 mainītis faili ar 14 papildinājumiem un 6 dzēšanām
  1. 4 4
      include/dump.h
  2. 10 2
      libbb/dump.c

+ 4 - 4
include/dump.h

@@ -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;

+ 10 - 2
libbb/dump.c

@@ -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);