summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-17 23:53:30 +0200
committerDenys Vlasenko2021-06-17 23:53:30 +0200
commit4d1616179745ee3883a726aaf13468e9c44dff9e (patch)
treebed5bc2f6afc768df587db7058b968f6e920b897 /libbb
parenta0f8076d19d721996b95b64eba95adae011215af (diff)
downloadbusybox-4d1616179745ee3883a726aaf13468e9c44dff9e.zip
busybox-4d1616179745ee3883a726aaf13468e9c44dff9e.tar.gz
xxd: implement -o DISPLAYOFFSET
function old new delta xxd_main 680 710 +30 xstrtoll - 30 +30 bb_dump_dump 1511 1531 +20 rewrite 941 951 +10 packed_usage 33629 33639 +10 .rodata 103250 103252 +2 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 5/0 up/down: 102/0) Total: 102 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/dump.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libbb/dump.c b/libbb/dump.c
index e83633c..8c2a370 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -228,7 +228,8 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
if ((p1[2] != 'd') && (p1[2] != 'o') && (p1[2] != 'x')) {
goto DO_BAD_CONV_CHAR;
}
- *p1 = p1[2];
+ *p1++ = 'l';
+ *p1++ = 'l';
break;
case 'c': /* %_c: chars, \ooo, \n \r \t etc */
pr->flags = F_C;
@@ -558,9 +559,9 @@ static void display(priv_dumper_t* dumper)
if (dumper->eaddress
&& dumper->address >= dumper->eaddress
) {
- if (dumper->pub.eofstring) {
+ if (dumper->pub.xxd_eofstring) {
/* xxd support: requested to not pad incomplete blocks */
- fputs_stdout(dumper->pub.eofstring);
+ fputs_stdout(dumper->pub.xxd_eofstring);
return;
}
if (!(pr->flags & (F_TEXT | F_BPAD)))
@@ -572,7 +573,7 @@ static void display(priv_dumper_t* dumper)
}
switch (pr->flags) {
case F_ADDRESS:
- printf(pr->fmt, (unsigned) dumper->address);
+ printf(pr->fmt, (unsigned long long) dumper->address + dumper->pub.xxd_displayoff);
break;
case F_BPAD:
printf(pr->fmt, "");
@@ -674,7 +675,7 @@ static 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) dumper->eaddress);
+ printf(pr->fmt, (unsigned long long) dumper->eaddress + dumper->pub.xxd_displayoff);
break;
case F_TEXT:
printf(pr->fmt);