#define PROGNAME "decodeindex"
static const char *progname = PROGNAME;
-static const unsigned char sopts[] = "VH";
+static const char sopts[] = "VH";
static const struct option lopts[] = {
{ "version", 0, NULL, 'V' },
{ "help", 0, NULL, 'H' },
static void print_bytes(FILE *f, int indent, void *buf, size_t n)
{
fprintf(f, "%*s", indent, "");
+
+ if (n == 0) {
+ printf("(empty)\n");
+ return;
+ }
+
for (size_t i = 0; i < n; i++)
fprintf(f, "%*s%.2hhx", i != 0, "", ((unsigned char *)buf)[i]);
putc('\n', f);
fprintf(stderr, "%s: invalid hex sequence: %s\n",
progname, hex);
goto out;
- } else if (n == 0) {
- fprintf(stderr, "%s: empty argument\n", progname);
- goto out;
} else if (n > sizeof buf) {
fprintf(stderr, "%s: hex sequence too long: %s\n",
progname, hex);