From c2a65d0a2b843ac16bfce571efda3403a3f3e65f Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Fri, 31 Oct 2008 13:22:19 -0500 Subject: [svn-r16012] Bug fix When -b was requested and no -o (file name) binary output was made to stdout Had a check after command line parsing to verify if -o is present, otherwise exit Tested: windows, linux --- tools/h5dump/h5dump.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index fe653fb..19a26b4 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -78,6 +78,8 @@ static char *prefix; static const char *driver = NULL; /* The driver to open the file with. */ static const h5dump_header_t *dump_header_format; static const char *fp_format = NULL; +const char *outfname=NULL; + /* things to display or which are set via command line parameters */ @@ -3852,10 +3854,6 @@ parse_command_line(int argc, const char *argv[]) struct handler_t *hand, *last_dset = NULL; int i, opt, last_was_dset = FALSE; - /* some logic to handle both -o and -b order */ - const char *outfname=NULL; - bin_form = -1; - /* no arguments */ if (argc == 1) { usage(progname); @@ -3979,7 +3977,7 @@ parse_start: case 'o': - if (bin_form > 0 ) + if ( bin_output ) { if (set_output_file(opt_arg, 1) < 0){ usage(progname); @@ -4265,6 +4263,12 @@ main(int argc, const char *argv[]) h5tools_init(); hand = parse_command_line(argc, argv); + if ( bin_output && outfname == NULL ) + { + error_msg(progname, "binary output requires a file name, use -o \n"); + leave(EXIT_FAILURE); + } + /* Check for conflicting options */ if (doxml) { if (!display_all) { -- cgit v0.12