1 diff -Nur busybox-1.18.1.orig/coreutils/od.c busybox-1.18.1/coreutils/od.c
2 --- busybox-1.18.1.orig/coreutils/od.c 2010-12-20 01:41:26.000000000 +0100
3 +++ busybox-1.18.1/coreutils/od.c 2010-12-25 23:18:48.000000000 +0100
9 -/* This one provides -t (busybox's own build script needs it) */
10 #include "od_bloaty.c"
16 -odoffset(dumper_t *dumper, int argc, char ***argvp)
23 - * The offset syntax of od(1) was genuinely bizarre. First, if
24 - * it started with a plus it had to be an offset. Otherwise, if
25 - * there were at least two arguments, a number or lower-case 'x'
26 - * followed by a number makes it an offset. By default it was
27 - * octal; if it started with 'x' or '0x' it was hex. If it ended
28 - * in a '.', it was decimal. If a 'b' or 'B' was appended, it
29 - * multiplied the number by 512 or 1024 byte units. There was
30 - * no way to assign a block count to a hex offset.
32 - * We assumes it's a file if the offset is bad.
37 - /* hey someone is probably piping to us ... */
44 - && ((p[0] != 'x') || !isxdigit(p[1])))))
49 - * skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
54 - if (p[0] == 'x' && isxdigit(p[1])) {
57 - } else if (p[0] == '0' && p[1] == 'x') {
62 - /* skip over the number */
64 - for (num = p; isxdigit(*p); ++p)
67 - for (num = p; isdigit(*p); ++p)
70 - /* check for no number */
74 - /* if terminates with a '.', base is decimal */
81 - dumper->dump_skip = strtol(num, &end, base ? base : 8);
83 - /* if end isn't the same as p, we got a non-octal digit */
85 - dumper->dump_skip = 0;
89 - dumper->dump_skip *= 512;
91 - } else if (*p == 'B') {
92 - dumper->dump_skip *= 1024;
97 - dumper->dump_skip = 0;
101 - * If the offset uses a non-octal base, the base of
102 - * the offset is changed as well. This isn't pretty,
105 -#define TYPE_OFFSET 7
115 - dumper->fshead->nextfu->fmt[TYPE_OFFSET]
116 - = dumper->fshead->nextfs->nextfu->fmt[TYPE_OFFSET]
124 -static const char *const add_strings[] = {
125 - "16/1 \"%3_u \" \"\\n\"", /* a */
126 - "8/2 \" %06o \" \"\\n\"", /* B, o */
127 - "16/1 \"%03o \" \"\\n\"", /* b */
128 - "16/1 \"%3_c \" \"\\n\"", /* c */
129 - "8/2 \" %05u \" \"\\n\"", /* d */
130 - "4/4 \" %010u \" \"\\n\"", /* D */
131 - "2/8 \" %21.14e \" \"\\n\"", /* e (undocumented in od), F */
132 - "4/4 \" %14.7e \" \"\\n\"", /* f */
133 - "4/4 \" %08x \" \"\\n\"", /* H, X */
134 - "8/2 \" %04x \" \"\\n\"", /* h, x */
135 - "4/4 \" %11d \" \"\\n\"", /* I, L, l */
136 - "8/2 \" %6d \" \"\\n\"", /* i */
137 - "4/4 \" %011o \" \"\\n\"", /* O */
140 -static const char od_opts[] ALIGN1 = "aBbcDdeFfHhIiLlOoXxv";
142 -static const char od_o2si[] ALIGN1 = {
145 - 9, 0xa, 0xb, 0xa, 0xa,
149 -int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
150 -int od_main(int argc, char **argv)
155 - dumper_t *dumper = alloc_dumper();
157 - while ((ch = getopt(argc, argv, od_opts)) > 0) {
159 - dumper->dump_vflag = ALL;
160 - } else if (((p = strchr(od_opts, ch)) != NULL) && (*p != '\0')) {
163 - bb_dump_add(dumper, "\"%07.7_Ao\n\"");
164 - bb_dump_add(dumper, "\"%07.7_ao \"");
166 - bb_dump_add(dumper, "\" \"");
168 - bb_dump_add(dumper, add_strings[(int)od_o2si[(p - od_opts)]]);
169 - } else { /* P, p, s, w, or other unhandled */
173 - if (!dumper->fshead) {
174 - bb_dump_add(dumper, "\"%07.7_Ao\n\"");
175 - bb_dump_add(dumper, "\"%07.7_ao \" 8/2 \"%06o \" \"\\n\"");
181 - odoffset(dumper, argc, &argv);
183 - return bb_dump_dump(dumper, argv);
185 -#endif /* ENABLE_DESKTOP */
188 - * Copyright (c) 1990 The Regents of the University of California.
189 - * All rights reserved.
191 - * Redistribution and use in source and binary forms, with or without
192 - * modification, are permitted provided that the following conditions
194 - * 1. Redistributions of source code must retain the above copyright
195 - * notice, this list of conditions and the following disclaimer.
196 - * 2. Redistributions in binary form must reproduce the above copyright
197 - * notice, this list of conditions and the following disclaimer in the
198 - * documentation and/or other materials provided with the distribution.
199 - * 3. Neither the name of the University nor the names of its contributors
200 - * may be used to endorse or promote products derived from this software
201 - * without specific prior written permission.
203 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
204 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
205 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
206 - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
207 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
208 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
209 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
210 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
211 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
212 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF