summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenis Vlasenko2008-07-16 11:00:16 +0000
committerDenis Vlasenko2008-07-16 11:00:16 +0000
commit55f7912ddaea7c21068a48841a6eb933e5f286ee (patch)
tree8e048772811061a8db2429c3ef99e8205e1de1f6 /coreutils
parent8ddb6410edb0c4e87b4c6b9d0887868977c8eff5 (diff)
downloadbusybox-55f7912ddaea7c21068a48841a6eb933e5f286ee.zip
busybox-55f7912ddaea7c21068a48841a6eb933e5f286ee.tar.gz
libbb: get rid of statics in dump.c; code shrinks a lot too
function old new delta alloc_dumper - 26 +26 hexdump_main 600 601 +1 static.done 1 - -1 static.ateof 1 - -1 bb_dump_vflag 1 - -1 static.savp 4 - -4 static.nextfs 4 - -4 static.curp 4 - -4 exitval 4 - -4 endfu 4 - -4 bb_dump_length 4 - -4 bb_dump_fshead 4 - -4 bb_dump_blocksize 4 - -4 _argv 4 - -4 bb_dump_add 365 358 -7 savaddress 8 - -8 eaddress 8 - -8 bb_dump_skip 8 - -8 address 8 - -8 bb_dump_dump 2748 2672 -76 next 538 445 -93 ------------------------------------------------------------------------------ (add/remove: 1/16 grow/shrink: 1/3 up/down: 27/-247) Total: -220 bytes text data bss dec hex filename 789458 607 6764 796829 c289d busybox_old 789309 601 6696 796606 c27be busybox_unstripped
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/od.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/coreutils/od.c b/coreutils/od.c
index 94a6b95..e4179a3 100644
--- a/coreutils/od.c
+++ b/coreutils/od.c
@@ -24,7 +24,7 @@
#define ishexdigit(c) (isxdigit)(c)
static void
-odoffset(int argc, char ***argvp)
+odoffset(dumper_t *dumper, int argc, char ***argvp)
{
char *num, *p;
int base;
@@ -57,7 +57,7 @@ odoffset(int argc, char ***argvp)
base = 0;
/*
- * bb_dump_skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
+ * skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
* set base.
*/
if (p[0] == '+')
@@ -70,11 +70,13 @@ odoffset(int argc, char ***argvp)
base = 16;
}
- /* bb_dump_skip over the number */
+ /* skip over the number */
if (base == 16)
- for (num = p; ishexdigit(*p); ++p);
+ for (num = p; ishexdigit(*p); ++p)
+ continue;
else
- for (num = p; isdecdigit(*p); ++p);
+ for (num = p; isdecdigit(*p); ++p)
+ continue;
/* check for no number */
if (num == p)
@@ -87,23 +89,23 @@ odoffset(int argc, char ***argvp)
base = 10;
}
- bb_dump_skip = strtol(num, &end, base ? base : 8);
+ dumper->dump_skip = strtol(num, &end, base ? base : 8);
/* if end isn't the same as p, we got a non-octal digit */
if (end != p)
- bb_dump_skip = 0;
+ dumper->dump_skip = 0;
else {
if (*p) {
if (*p == 'b') {
- bb_dump_skip *= 512;
+ dumper->dump_skip *= 512;
++p;
} else if (*p == 'B') {
- bb_dump_skip *= 1024;
+ dumper->dump_skip *= 1024;
++p;
}
}
if (*p)
- bb_dump_skip = 0;
+ dumper->dump_skip = 0;
else {
++*argvp;
/*
@@ -120,9 +122,9 @@ odoffset(int argc, char ***argvp)
}
if (base == 10) {
x_or_d = 'd';
- DO_X_OR_D:
- bb_dump_fshead->nextfu->fmt[TYPE_OFFSET]
- = bb_dump_fshead->nextfs->nextfu->fmt[TYPE_OFFSET]
+ DO_X_OR_D:
+ dumper->fshead->nextfu->fmt[TYPE_OFFSET]
+ = dumper->fshead->nextfs->nextfu->fmt[TYPE_OFFSET]
= x_or_d;
}
}
@@ -161,36 +163,35 @@ int od_main(int argc, char **argv)
int ch;
int first = 1;
char *p;
- bb_dump_vflag = FIRST;
- bb_dump_length = -1;
+ dumper_t *dumper = alloc_dumper();
while ((ch = getopt(argc, argv, od_opts)) > 0) {
if (ch == 'v') {
- bb_dump_vflag = ALL;
+ dumper->dump_vflag = ALL;
} else if (((p = strchr(od_opts, ch)) != NULL) && (*p != '\0')) {
if (first) {
first = 0;
- bb_dump_add("\"%07.7_Ao\n\"");
- bb_dump_add("\"%07.7_ao \"");
+ bb_dump_add(dumper, "\"%07.7_Ao\n\"");
+ bb_dump_add(dumper, "\"%07.7_ao \"");
} else {
- bb_dump_add("\" \"");
+ bb_dump_add(dumper, "\" \"");
}
- bb_dump_add(add_strings[(int)od_o2si[(p-od_opts)]]);
+ bb_dump_add(dumper, add_strings[(int)od_o2si[(p - od_opts)]]);
} else { /* P, p, s, w, or other unhandled */
bb_show_usage();
}
}
- if (!bb_dump_fshead) {
- bb_dump_add("\"%07.7_Ao\n\"");
- bb_dump_add("\"%07.7_ao \" 8/2 \"%06o \" \"\\n\"");
+ if (!dumper->fshead) {
+ bb_dump_add(dumper, "\"%07.7_Ao\n\"");
+ bb_dump_add(dumper, "\"%07.7_ao \" 8/2 \"%06o \" \"\\n\"");
}
argc -= optind;
argv += optind;
- odoffset(argc, &argv);
+ odoffset(dumper, argc, &argv);
- return bb_dump_dump(argv);
+ return bb_dump_dump(dumper, argv);
}
#endif /* ENABLE_DESKTOP */