dd: speed measurement. optional.
[oweals/busybox.git] / util-linux / hexdump.c
index 4d2b0592ba3e394671c68c1462a7ae918ec367a0..f3878f44ffefb52d4543bfd1e84780a8a7952b07 100644 (file)
 
 /* This is a NOEXEC applet. Be very careful! */
 
-
 static void bb_dump_addfile(dumper_t *dumper, char *name)
 {
        char *p;
        FILE *fp;
        char *buf;
 
-       fp = xfopen(name, "r");
-
+       fp = xfopen_for_read(name);
        while ((buf = xmalloc_fgetline(fp)) != NULL) {
                p = skip_whitespace(buf);
-
                if (*p && (*p != '#')) {
                        bb_dump_add(dumper, p);
                }
@@ -44,13 +41,13 @@ static const char *const add_strings[] = {
 
 static const char add_first[] ALIGN1 = "\"%07.7_Ax\n\"";
 
-static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:v" USE_FEATURE_HEXDUMP_REVERSE("R");
+static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:v" IF_FEATURE_HEXDUMP_REVERSE("R");
 
 static const struct suffix_mult suffixes[] = {
        { "b", 512 },
        { "k", 1024 },
        { "m", 1024*1024 },
-       { }
+       { "", 0 }
 };
 
 int hexdump_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -131,7 +128,7 @@ int hexdump_main(int argc, char **argv)
 
        do {
                char *buf;
-               fp = xfopen(*argv, "r");
+               fp = xfopen_for_read(*argv);
  jump_in:
                while ((buf = xmalloc_fgetline(fp)) != NULL) {
                        p = buf;