*/
#include "libbb.h"
-#include <getopt.h>
#define assert(a) ((void)0)
static void
print_named_ascii(size_t n_bytes, const char *block,
- const char *unused_fmt_string ATTRIBUTE_UNUSED)
+ const char *unused_fmt_string UNUSED_PARAM)
{
/* Names for some non-printing characters. */
static const char charname[33][3] ALIGN1 = {
static void
print_ascii(size_t n_bytes, const char *block,
- const char *unused_fmt_string ATTRIBUTE_UNUSED)
+ const char *unused_fmt_string UNUSED_PARAM)
{
// buf[N] pos: 01234 56789
char buf[12] = " x\0 0xx\0";
}
/* If S points to a single valid modern od format string, put
- a description of that format in *TSPEC, make *NEXT point at the
- character following the just-decoded format (if *NEXT is non-NULL),
- and return zero. For example, if S were "d4afL"
- *NEXT would be set to "afL" and *TSPEC would be
+ a description of that format in *TSPEC, return pointer to
+ character following the just-decoded format.
+ For example, if S were "d4afL", we will return a rtp to "afL"
+ and *TSPEC would be
{
fmt = SIGNED_DECIMAL;
size = INT or LONG; (whichever integral_type_size[4] resolves to)
S_ORIG is solely for reporting errors. It should be the full format
string argument. */
-static void
-decode_one_format(const char *s_orig, const char *s, const char **next,
- struct tspec *tspec)
+static const char *
+decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
{
enum size_spec size_spec;
unsigned size;
unsigned field_width = 0;
int pos;
- assert(tspec != NULL);
switch (*s) {
case 'd':
s = end;
}
} else {
- static const uint8_t CSIL_sizeof[] = {
+ static const uint8_t CSIL_sizeof[4] = {
sizeof(char),
sizeof(short),
sizeof(int),
sizeof(long),
};
size = CSIL_sizeof[p - CSIL];
+ s++; /* skip C/S/I/L */
}
#define ISPEC_TO_FORMAT(Spec, Min_format, Long_format, Max_format) \
if (tspec->hexl_mode_trailer)
s++;
- if (next != NULL)
- *next = s;
+ return s;
}
/* Decode the modern od format string S. Append the decoded
struct tspec tspec;
const char *next;
- decode_one_format(s_orig, s, &next, &tspec);
+ next = decode_one_format(s_orig, s, &tspec);
assert(s != next);
s = next;
+ spec = xrealloc_vector(spec, 4, n_specs);
+ memcpy(&spec[n_specs], &tspec, sizeof(spec[0]));
n_specs++;
- spec = xrealloc(spec, n_specs * sizeof(*spec));
- memcpy(&spec[n_specs-1], &tspec, sizeof *spec);
}
}
typedef void FN_format_address(off_t address, char c);
static void
-format_address_none(off_t address ATTRIBUTE_UNUSED, char c ATTRIBUTE_UNUSED)
+format_address_none(off_t address UNUSED_PARAM, char c UNUSED_PARAM)
{
}
printf(address_fmt, address);
}
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
/* only used with --traditional */
static void
format_address_paren(off_t address, char c)
return l_c_m;
}
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
/* If S is a valid traditional offset specification with an optional
leading '+' return nonzero and set *OFFSET to the offset it denotes. */
static const struct suffix_mult Bb[] = {
{ "B", 1024 },
{ "b", 512 },
- { }
+ { "", 0 }
};
char *p;
int radix;
{ "b", 512 },
{ "k", 1024 },
{ "m", 1024*1024 },
- { }
+ { "", 0 }
};
enum {
OPT_A = 1 << 0,
OPT_s = 1 << 15,
OPT_S = 1 << 16,
OPT_w = 1 << 17,
- OPT_traditional = (1 << 18) * ENABLE_GETOPT_LONG,
+ OPT_traditional = (1 << 18) * ENABLE_LONG_OPTS,
};
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
static const char od_longopts[] ALIGN1 =
"skip-bytes\0" Required_argument "j"
"address-radix\0" Required_argument "A"
/* Parse command line */
opt_complementary = "w+:t::"; /* -w N, -t is a list */
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
applet_long_options = od_longopts;
#endif
opt = getopt32(argv, "A:N:abcdfhij:lot:vxsS:"
if (opt & OPT_o) decode_format_string("o2");
//if (opt & OPT_t)...
while (lst_t) {
- decode_format_string(lst_t->data);
- lst_t = lst_t->link;
+ decode_format_string(llist_pop(&lst_t));
}
if (opt & OPT_v) verbose = 1;
if (opt & OPT_x) decode_format_string("x2");
* FIXME: POSIX 1003.1-2001 with XSI requires support for the
* traditional syntax even if --traditional is not given. */
-#if ENABLE_GETOPT_LONG
+#if ENABLE_LONG_OPTS
if (opt & OPT_traditional) {
off_t o1, o2;