summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
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 */