Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-05-26 00:48:13 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-05-26 00:48:13 +0300
commit0c3270f7e55e0ca7b8d664851468511d2c8995cf (patch)
treefdaf00c6f2db56cab992eec0d556b3ef0db61381 /libbb
parent6882a933cf078be35f4eb93963365549d43cb497 (diff)
od: stop printing extra trailing spaces
function old new delta .rodata 104598 104613 +15 display 1475 1485 +10 od_main 549 556 +7 rewrite 971 967 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 32/-4) Total: 28 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/dump.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/libbb/dump.c b/libbb/dump.c
index cfb9d94f9..77d76611b 100644
--- a/libbb/dump.c
+++ b/libbb/dump.c
@@ -242,7 +242,7 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
pr->flags = F_P;
*p1 = 'c';
goto DO_BYTE_COUNT_1;
- case 'u': /* %_p: chars, 'nul', 'esc' etc for nonprintable */
+ case 'u': /* %_u: chars, 'nul', 'esc' etc for nonprintable */
pr->flags = F_U;
/* *p1 = 'c'; set in conv_u */
goto DO_BYTE_COUNT_1;
@@ -322,8 +322,7 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
p2 = NULL;
for (p1 = pr->fmt; *p1; ++p1)
p2 = isspace(*p1) ? p1 : NULL;
- if (p2)
- pr->nospace = p2;
+ pr->nospace = p2;
}
}
}
@@ -477,7 +476,7 @@ static void bpad(PR *pr)
static const char conv_str[] ALIGN1 =
"\0" "\\""0""\0"
- "\007""\\""a""\0" /* \a */
+ "\007""\\""a""\0"
"\b" "\\""b""\0"
"\f" "\\""f""\0"
"\n" "\\""n""\0"
@@ -539,7 +538,6 @@ static void conv_u(PR *pr, unsigned char *p)
static NOINLINE void display(priv_dumper_t* dumper)
{
unsigned char *bp;
- unsigned char savech = '\0';
while ((bp = get(dumper)) != NULL) {
FS *fs;
@@ -560,6 +558,8 @@ static NOINLINE void display(priv_dumper_t* dumper)
PR *pr;
for (pr = fu->nextpr; pr; dumper->pub.address += pr->bcnt,
bp += pr->bcnt, pr = pr->nextpr) {
+ unsigned char savech;
+
if (dumper->eaddress
&& dumper->pub.address >= dumper->eaddress
) {
@@ -568,9 +568,16 @@ static NOINLINE void display(priv_dumper_t* dumper)
fputs_stdout(dumper->pub.xxd_eofstring);
return;
}
+ 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;
+ }
if (!(pr->flags & (F_TEXT | F_BPAD)))
bpad(pr);
}
+ savech = '\0';
if (cnt == 1 && pr->nospace) {
savech = *pr->nospace;
*pr->nospace = '\0';
@@ -665,7 +672,7 @@ static NOINLINE void display(priv_dumper_t* dumper)
break;
}
}
- if (cnt == 1 && pr->nospace) {
+ if (savech) {
*pr->nospace = savech;
}
}
@@ -673,7 +680,7 @@ static NOINLINE void display(priv_dumper_t* dumper)
}
}
}
-
+ endfu:
if (dumper->endfu) {
PR *pr;
/*