006-od-bloat.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 @@
  5. #include "libbb.h"
  6. -#if ENABLE_DESKTOP
  7. -/* This one provides -t (busybox's own build script needs it) */
  8. #include "od_bloaty.c"
  9. -#else
  10. -
  11. -#include "dump.h"
  12. -
  13. -static void
  14. -odoffset(dumper_t *dumper, int argc, char ***argvp)
  15. -{
  16. - char *num, *p;
  17. - int base;
  18. - char *end;
  19. -
  20. - /*
  21. - * The offset syntax of od(1) was genuinely bizarre. First, if
  22. - * it started with a plus it had to be an offset. Otherwise, if
  23. - * there were at least two arguments, a number or lower-case 'x'
  24. - * followed by a number makes it an offset. By default it was
  25. - * octal; if it started with 'x' or '0x' it was hex. If it ended
  26. - * in a '.', it was decimal. If a 'b' or 'B' was appended, it
  27. - * multiplied the number by 512 or 1024 byte units. There was
  28. - * no way to assign a block count to a hex offset.
  29. - *
  30. - * We assumes it's a file if the offset is bad.
  31. - */
  32. - p = **argvp;
  33. -
  34. - if (!p) {
  35. - /* hey someone is probably piping to us ... */
  36. - return;
  37. - }
  38. -
  39. - if ((*p != '+')
  40. - && (argc < 2
  41. - || (!isdigit(p[0])
  42. - && ((p[0] != 'x') || !isxdigit(p[1])))))
  43. - return;
  44. -
  45. - base = 0;
  46. - /*
  47. - * skip over leading '+', 'x[0-9a-fA-f]' or '0x', and
  48. - * set base.
  49. - */
  50. - if (p[0] == '+')
  51. - ++p;
  52. - if (p[0] == 'x' && isxdigit(p[1])) {
  53. - ++p;
  54. - base = 16;
  55. - } else if (p[0] == '0' && p[1] == 'x') {
  56. - p += 2;
  57. - base = 16;
  58. - }
  59. -
  60. - /* skip over the number */
  61. - if (base == 16)
  62. - for (num = p; isxdigit(*p); ++p)
  63. - continue;
  64. - else
  65. - for (num = p; isdigit(*p); ++p)
  66. - continue;
  67. -
  68. - /* check for no number */
  69. - if (num == p)
  70. - return;
  71. -
  72. - /* if terminates with a '.', base is decimal */
  73. - if (*p == '.') {
  74. - if (base)
  75. - return;
  76. - base = 10;
  77. - }
  78. -
  79. - dumper->dump_skip = strtol(num, &end, base ? base : 8);
  80. -
  81. - /* if end isn't the same as p, we got a non-octal digit */
  82. - if (end != p)
  83. - dumper->dump_skip = 0;
  84. - else {
  85. - if (*p) {
  86. - if (*p == 'b') {
  87. - dumper->dump_skip *= 512;
  88. - ++p;
  89. - } else if (*p == 'B') {
  90. - dumper->dump_skip *= 1024;
  91. - ++p;
  92. - }
  93. - }
  94. - if (*p)
  95. - dumper->dump_skip = 0;
  96. - else {
  97. - ++*argvp;
  98. - /*
  99. - * If the offset uses a non-octal base, the base of
  100. - * the offset is changed as well. This isn't pretty,
  101. - * but it's easy.
  102. - */
  103. -#define TYPE_OFFSET 7
  104. - {
  105. - char x_or_d;
  106. - if (base == 16) {
  107. - x_or_d = 'x';
  108. - goto DO_X_OR_D;
  109. - }
  110. - if (base == 10) {
  111. - x_or_d = 'd';
  112. - DO_X_OR_D:
  113. - dumper->fshead->nextfu->fmt[TYPE_OFFSET]
  114. - = dumper->fshead->nextfs->nextfu->fmt[TYPE_OFFSET]
  115. - = x_or_d;
  116. - }
  117. - }
  118. - }
  119. - }
  120. -}
  121. -
  122. -static const char *const add_strings[] = {
  123. - "16/1 \"%3_u \" \"\\n\"", /* a */
  124. - "8/2 \" %06o \" \"\\n\"", /* B, o */
  125. - "16/1 \"%03o \" \"\\n\"", /* b */
  126. - "16/1 \"%3_c \" \"\\n\"", /* c */
  127. - "8/2 \" %05u \" \"\\n\"", /* d */
  128. - "4/4 \" %010u \" \"\\n\"", /* D */
  129. - "2/8 \" %21.14e \" \"\\n\"", /* e (undocumented in od), F */
  130. - "4/4 \" %14.7e \" \"\\n\"", /* f */
  131. - "4/4 \" %08x \" \"\\n\"", /* H, X */
  132. - "8/2 \" %04x \" \"\\n\"", /* h, x */
  133. - "4/4 \" %11d \" \"\\n\"", /* I, L, l */
  134. - "8/2 \" %6d \" \"\\n\"", /* i */
  135. - "4/4 \" %011o \" \"\\n\"", /* O */
  136. -};
  137. -
  138. -static const char od_opts[] ALIGN1 = "aBbcDdeFfHhIiLlOoXxv";
  139. -
  140. -static const char od_o2si[] ALIGN1 = {
  141. - 0, 1, 2, 3, 5,
  142. - 4, 6, 6, 7, 8,
  143. - 9, 0xa, 0xb, 0xa, 0xa,
  144. - 0xb, 1, 8, 9,
  145. -};
  146. -
  147. -int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  148. -int od_main(int argc, char **argv)
  149. -{
  150. - int ch;
  151. - int first = 1;
  152. - char *p;
  153. - dumper_t *dumper = alloc_dumper();
  154. -
  155. - while ((ch = getopt(argc, argv, od_opts)) > 0) {
  156. - if (ch == 'v') {
  157. - dumper->dump_vflag = ALL;
  158. - } else if (((p = strchr(od_opts, ch)) != NULL) && (*p != '\0')) {
  159. - if (first) {
  160. - first = 0;
  161. - bb_dump_add(dumper, "\"%07.7_Ao\n\"");
  162. - bb_dump_add(dumper, "\"%07.7_ao \"");
  163. - } else {
  164. - bb_dump_add(dumper, "\" \"");
  165. - }
  166. - bb_dump_add(dumper, add_strings[(int)od_o2si[(p - od_opts)]]);
  167. - } else { /* P, p, s, w, or other unhandled */
  168. - bb_show_usage();
  169. - }
  170. - }
  171. - if (!dumper->fshead) {
  172. - bb_dump_add(dumper, "\"%07.7_Ao\n\"");
  173. - bb_dump_add(dumper, "\"%07.7_ao \" 8/2 \"%06o \" \"\\n\"");
  174. - }
  175. -
  176. - argc -= optind;
  177. - argv += optind;
  178. -
  179. - odoffset(dumper, argc, &argv);
  180. -
  181. - return bb_dump_dump(dumper, argv);
  182. -}
  183. -#endif /* ENABLE_DESKTOP */
  184. -
  185. -/*-
  186. - * Copyright (c) 1990 The Regents of the University of California.
  187. - * All rights reserved.
  188. - *
  189. - * Redistribution and use in source and binary forms, with or without
  190. - * modification, are permitted provided that the following conditions
  191. - * are met:
  192. - * 1. Redistributions of source code must retain the above copyright
  193. - * notice, this list of conditions and the following disclaimer.
  194. - * 2. Redistributions in binary form must reproduce the above copyright
  195. - * notice, this list of conditions and the following disclaimer in the
  196. - * documentation and/or other materials provided with the distribution.
  197. - * 3. Neither the name of the University nor the names of its contributors
  198. - * may be used to endorse or promote products derived from this software
  199. - * without specific prior written permission.
  200. - *
  201. - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  202. - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  203. - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  204. - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  205. - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  206. - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  207. - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  208. - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  209. - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  210. - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  211. - * SUCH DAMAGE.
  212. - */