irssi: update to 1.0.2
[openadk.git] / package / busybox / patches / 006-od-bloat.patch
blobff501acdb27d84baedf55fa9d727aa51788a0cb8
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
4 @@ -13,210 +13,4 @@
7 #include "libbb.h"
8 -#if ENABLE_DESKTOP
9 -/* This one provides -t (busybox's own build script needs it) */
10 #include "od_bloaty.c"
11 -#else
13 -#include "dump.h"
15 -static void
16 -odoffset(dumper_t *dumper, int argc, char ***argvp)
18 - char *num, *p;
19 - int base;
20 - char *end;
22 - /*
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.
31 - *
32 - * We assumes it's a file if the offset is bad.
33 - */
34 - p = **argvp;
36 - if (!p) {
37 - /* hey someone is probably piping to us ... */
38 - return;
39 - }
41 - if ((*p != '+')
42 - && (argc < 2
43 - || (!isdigit(p[0])
44 - && ((p[0] != 'x') || !isxdigit(p[1])))))
45 - return;
47 - base = 0;
48 - /*
49 - * skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
50 - * set base.
51 - */
52 - if (p[0] == '+')
53 - ++p;
54 - if (p[0] == 'x' && isxdigit(p[1])) {
55 - ++p;
56 - base = 16;
57 - } else if (p[0] == '0' && p[1] == 'x') {
58 - p += 2;
59 - base = 16;
60 - }
62 - /* skip over the number */
63 - if (base == 16)
64 - for (num = p; isxdigit(*p); ++p)
65 - continue;
66 - else
67 - for (num = p; isdigit(*p); ++p)
68 - continue;
70 - /* check for no number */
71 - if (num == p)
72 - return;
74 - /* if terminates with a '.', base is decimal */
75 - if (*p == '.') {
76 - if (base)
77 - return;
78 - base = 10;
79 - }
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 */
84 - if (end != p)
85 - dumper->dump_skip = 0;
86 - else {
87 - if (*p) {
88 - if (*p == 'b') {
89 - dumper->dump_skip *= 512;
90 - ++p;
91 - } else if (*p == 'B') {
92 - dumper->dump_skip *= 1024;
93 - ++p;
94 - }
95 - }
96 - if (*p)
97 - dumper->dump_skip = 0;
98 - else {
99 - ++*argvp;
100 - /*
101 - * If the offset uses a non-octal base, the base of
102 - * the offset is changed as well. This isn't pretty,
103 - * but it's easy.
104 - */
105 -#define TYPE_OFFSET 7
107 - char x_or_d;
108 - if (base == 16) {
109 - x_or_d = 'x';
110 - goto DO_X_OR_D;
112 - if (base == 10) {
113 - x_or_d = 'd';
114 - DO_X_OR_D:
115 - dumper->fshead->nextfu->fmt[TYPE_OFFSET]
116 - = dumper->fshead->nextfs->nextfu->fmt[TYPE_OFFSET]
117 - = x_or_d;
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 = {
143 - 0, 1, 2, 3, 5,
144 - 4, 6, 6, 7, 8,
145 - 9, 0xa, 0xb, 0xa, 0xa,
146 - 0xb, 1, 8, 9,
149 -int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
150 -int od_main(int argc, char **argv)
152 - int ch;
153 - int first = 1;
154 - char *p;
155 - dumper_t *dumper = alloc_dumper();
157 - while ((ch = getopt(argc, argv, od_opts)) > 0) {
158 - if (ch == 'v') {
159 - dumper->dump_vflag = ALL;
160 - } else if (((p = strchr(od_opts, ch)) != NULL) && (*p != '\0')) {
161 - if (first) {
162 - first = 0;
163 - bb_dump_add(dumper, "\"%07.7_Ao\n\"");
164 - bb_dump_add(dumper, "\"%07.7_ao \"");
165 - } else {
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 */
170 - bb_show_usage();
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\"");
178 - argc -= optind;
179 - argv += optind;
181 - odoffset(dumper, argc, &argv);
183 - return bb_dump_dump(dumper, argv);
185 -#endif /* ENABLE_DESKTOP */
187 -/*-
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
193 - * are met:
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
213 - * SUCH DAMAGE.
214 - */