aboutsummaryrefslogtreecommitdiff
path: root/libbb/dump.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-05-25 17:39:28 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-05-25 17:40:20 +0200
commite2287f99fe6f21fd6435ad04340170ad4ba5f6b3 (patch)
tree09224d93a16e18c0f4e31ada2375d7ca9cfab03e /libbb/dump.c
parent64bdd7566c21cb53cb4c384ed52845106529e55f (diff)
downloadbusybox-w32-e2287f99fe6f21fd6435ad04340170ad4ba5f6b3.tar.gz
busybox-w32-e2287f99fe6f21fd6435ad04340170ad4ba5f6b3.tar.bz2
busybox-w32-e2287f99fe6f21fd6435ad04340170ad4ba5f6b3.zip
od: for !DESKTOP, match output more closely to GNU coreutils 9.1, implement -s
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/dump.c')
-rw-r--r--libbb/dump.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/libbb/dump.c b/libbb/dump.c
index fcdee8343..cfb9d94f9 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -187,6 +187,10 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
187 187
188 ++p2; 188 ++p2;
189 ++p1; 189 ++p1;
190 if (*p1 == 'l') { /* %lld etc */
191 ++p2;
192 ++p1;
193 }
190 DO_INT_CONV: 194 DO_INT_CONV:
191 e = strchr(int_convs, *p1); /* "diouxX"? */ 195 e = strchr(int_convs, *p1); /* "diouxX"? */
192 if (!e) 196 if (!e)
@@ -194,7 +198,7 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
194 pr->flags = F_INT; 198 pr->flags = F_INT;
195 if (e > int_convs + 1) /* not d or i? */ 199 if (e > int_convs + 1) /* not d or i? */
196 pr->flags = F_UINT; 200 pr->flags = F_UINT;
197 byte_count_str = "\004\002\001"; 201 byte_count_str = "\010\004\002\001";
198 goto DO_BYTE_COUNT; 202 goto DO_BYTE_COUNT;
199 } else 203 } else
200 if (strchr(int_convs, *p1)) { /* %d etc */ 204 if (strchr(int_convs, *p1)) { /* %d etc */
@@ -601,22 +605,32 @@ static NOINLINE void display(priv_dumper_t* dumper)
601 break; 605 break;
602 } 606 }
603 case F_INT: { 607 case F_INT: {
604 int ival; 608 union {
605 short sval; 609 uint16_t val16;
610 uint32_t val32;
611 uint64_t val64;
612 } u;
613 int value = *bp;
606 614
607 switch (pr->bcnt) { 615 switch (pr->bcnt) {
608 case 1: 616 case 1:
609 printf(pr->fmt, (int) *bp);
610 break; 617 break;
611 case 2: 618 case 2:
612 memcpy(&sval, bp, sizeof(sval)); 619 memcpy(&u.val16, bp, 2);
613 printf(pr->fmt, (int) sval); 620 value = u.val16;
614 break; 621 break;
615 case 4: 622 case 4:
616 memcpy(&ival, bp, sizeof(ival)); 623 memcpy(&u.val32, bp, 4);
617 printf(pr->fmt, ival); 624 value = u.val32;
618 break; 625 break;
626 case 8:
627 memcpy(&u.val64, bp, 8);
628//A hack. Users _must_ use %llX formats to not truncate high bits
629 printf(pr->fmt, (long long) u.val64);
630 goto skip;
619 } 631 }
632 printf(pr->fmt, value);
633 skip:
620 break; 634 break;
621 } 635 }
622 case F_P: 636 case F_P: