From f6ffaf1f69b71caf958c8d71ea1decc5ea696b03 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 15 Jul 2013 10:53:17 -0500 Subject: [svn-r23898] HDFFV-8476: Add optional arg to -A for excluding attributes. Merged from trunk. Tested: local linux --- MANIFEST | 2 + tools/h5dump/CMakeLists.txt | 7 +++ tools/h5dump/errfiles/tall-2A0.err | 25 +++++++++ tools/h5dump/h5dump.c | 21 ++++---- tools/h5dump/h5dump.h | 1 + tools/h5dump/h5dump_ddl.c | 25 ++++----- tools/h5dump/h5dump_extern.h | 1 + tools/h5dump/testh5dump.sh.in | 5 ++ tools/lib/h5tools_str.c | 18 +++---- tools/testfiles/h5dump-help.txt | 1 + tools/testfiles/tall-2A0.ddl | 64 ++++++++++++++++++++++++ tools/testfiles/tnofilename-with-packed-bits.ddl | 1 + tools/testfiles/tpbitsIncomplete.ddl | 1 + tools/testfiles/tpbitsLengthExceeded.ddl | 1 + tools/testfiles/tpbitsLengthPositive.ddl | 1 + tools/testfiles/tpbitsMaxExceeded.ddl | 1 + tools/testfiles/tpbitsOffsetExceeded.ddl | 1 + tools/testfiles/tpbitsOffsetNegative.ddl | 1 + 18 files changed, 146 insertions(+), 31 deletions(-) create mode 100644 tools/h5dump/errfiles/tall-2A0.err create mode 100644 tools/testfiles/tall-2A0.ddl diff --git a/MANIFEST b/MANIFEST index 61ba83f..ae4ac4b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1403,6 +1403,7 @@ ./tools/testfiles/tudlink-2.ddl ./tools/testfiles/tattr2.h5 ./tools/testfiles/tall-2A.ddl +./tools/testfiles/tall-2A0.ddl ./tools/testfiles/tall-2B.ddl ./tools/testfiles/tattrcontents1.ddl ./tools/testfiles/tattrcontents2.ddl @@ -1462,6 +1463,7 @@ ./tools/h5dump/errfiles/filter_fail.err ./tools/h5dump/errfiles/tall-1.err ./tools/h5dump/errfiles/tall-2A.err +./tools/h5dump/errfiles/tall-2A0.err ./tools/h5dump/errfiles/tall-2B.err ./tools/h5dump/errfiles/tarray1_big.err ./tools/h5dump/errfiles/tattr-3.err diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index ad9a6a1..f14ff1b 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -51,6 +51,7 @@ IF (BUILD_TESTING) ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-1.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-2.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-2A.ddl + ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-2A0.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-2B.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-3.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-4s.ddl @@ -303,6 +304,7 @@ IF (BUILD_TESTING) ${PROJECT_SOURCE_DIR}/errfiles/filter_fail.err ${PROJECT_SOURCE_DIR}/errfiles/tall-1.err ${PROJECT_SOURCE_DIR}/errfiles/tall-2A.err + ${PROJECT_SOURCE_DIR}/errfiles/tall-2A0.err ${PROJECT_SOURCE_DIR}/errfiles/tall-2B.err ${PROJECT_SOURCE_DIR}/errfiles/tarray1_big.err ${PROJECT_SOURCE_DIR}/errfiles/tattrregR.err @@ -1068,6 +1070,8 @@ IF (BUILD_TESTING) tall-2.out.err tall-2A.out tall-2A.out.err + tall-2A0.out + tall-2A0.out.err tall-2B.out tall-2B.out.err tall-3.out @@ -1502,6 +1506,9 @@ IF (BUILD_TESTING) # test '-A' to suppress data but print attr's ADD_H5ERR_MASK_TEST (tall-2A 0 --enable-error-stack -A tall.h5) + # test '-A' to suppress attr's but print data + ADD_H5ERR_MASK_TEST (tall-2A0 0 --enable-error-stack -A 0 tall.h5) + # test '-r' to print attributes in ASCII instead of decimal ADD_H5ERR_MASK_TEST (tall-2B 0 --enable-error-stack -A -r tall.h5) diff --git a/tools/h5dump/errfiles/tall-2A0.err b/tools/h5dump/errfiles/tall-2A0.err new file mode 100644 index 0000000..ba691d0 --- /dev/null +++ b/tools/h5dump/errfiles/tall-2A0.err @@ -0,0 +1,25 @@ +HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): + #000: (file name) line (number) in H5Oopen(): unable to open object + major: Symbol table + minor: Can't open object + #001: (file name) line (number) in H5O_open_name(): object not found + major: Symbol table + minor: Object not found + #002: (file name) line (number) in H5G_loc_find(): can't find object + major: Symbol table + minor: Object not found + #003: (file name) line (number) in H5G_traverse(): internal path traversal failed + major: Symbol table + minor: Object not found + #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + major: Links + minor: Link traversal failure + #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + major: Links + minor: Link traversal failure + #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + major: Symbol table + minor: Unable to find atom information (already closed?) + #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' + major: Links + minor: Unable to open file diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index ef979b2..9b304bd 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -71,7 +71,7 @@ struct handler_t { */ /* The following initialization makes use of C language cancatenating */ /* "xxx" "yyy" into "xxxyyy". */ -static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:Aq:z:m:RECM:O*"; +static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RECM:O*"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "hel", no_arg, 'h' }, @@ -175,7 +175,7 @@ static struct long_options l_opts[] = { { "xml-n", require_arg, 'X' }, { "xml", no_arg, 'x' }, { "xm", no_arg, 'x' }, - { "onlyattr", no_arg, 'A' }, + { "onlyattr", optional_arg, 'A' }, { "escape", no_arg, 'e' }, { "noindex", no_arg, 'y' }, { "binary", optional_arg, 'b' }, @@ -221,11 +221,6 @@ leave(int ret) * Purpose: Print the usage message about dumper * * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * Pedro Vicente, October 5, 2007. Add -q and -z flags *------------------------------------------------------------------------- */ static void @@ -240,6 +235,7 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " -B, --superblock Print the content of the super block\n"); PRINTVALSTREAM(rawoutstream, " -H, --header Print the header only; no data is displayed\n"); PRINTVALSTREAM(rawoutstream, " -A, --onlyattr Print the header and value of attributes\n"); + PRINTVALSTREAM(rawoutstream, " Optional value 0 suppresses printing attributes.\n"); PRINTVALSTREAM(rawoutstream, " -i, --object-ids Print the object ids\n"); PRINTVALSTREAM(rawoutstream, " -r, --string Print 1-byte integer datasets as ASCII\n"); PRINTVALSTREAM(rawoutstream, " -e, --escape Escape non printing characters\n"); @@ -1093,9 +1089,14 @@ parse_start: last_was_dset = FALSE; break; case 'A': - display_data = FALSE; - display_attr_data = TRUE; - last_was_dset = FALSE; + if ( opt_arg != NULL) { + if(0 == HDatoi(opt_arg)) include_attrs = FALSE; + } + else { + display_data = FALSE; + display_attr_data = TRUE; + last_was_dset = FALSE; + } break; case 'i': display_oid = TRUE; diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h index 7d4f460..7bfead7 100644 --- a/tools/h5dump/h5dump.h +++ b/tools/h5dump/h5dump.h @@ -76,6 +76,7 @@ int display_region = FALSE; /*print region reference data */ int enable_error_stack= FALSE; /* re-enable error stack */ int disable_compact_subset= FALSE; /* disable compact form of subset notation */ int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/ +int include_attrs = TRUE; /* Display attributes */ /* sort parameters */ H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */ diff --git a/tools/h5dump/h5dump_ddl.c b/tools/h5dump/h5dump_ddl.c index 348a293..e18b2f0 100644 --- a/tools/h5dump/h5dump_ddl.c +++ b/tools/h5dump/h5dump_ddl.c @@ -556,19 +556,20 @@ attr_iteration(hid_t gid, unsigned attr_crt_order_flags) { /* attribute iteration: if there is a request to do H5_INDEX_CRT_ORDER and tracking order is set in the group for attributes, then, sort by creation order, otherwise by name */ - - if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { - if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); - } /* end if */ - } /* end if */ - else { - if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) { - error_msg("error getting attribute information\n"); - h5tools_setstatus(EXIT_FAILURE); + if(include_attrs) { + if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) { + if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) { + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); + } /* end if */ } /* end if */ - } /* end else */ + else { + if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) { + error_msg("error getting attribute information\n"); + h5tools_setstatus(EXIT_FAILURE); + } /* end if */ + } /* end else */ + } } /*------------------------------------------------------------------------- diff --git a/tools/h5dump/h5dump_extern.h b/tools/h5dump/h5dump_extern.h index 5a0f2bd..08f9e36 100644 --- a/tools/h5dump/h5dump_extern.h +++ b/tools/h5dump/h5dump_extern.h @@ -76,6 +76,7 @@ extern int display_region; /*print region reference data */ extern int enable_error_stack; /* re-enable error stack */ extern int disable_compact_subset; /* disable compact form of subset notation */ extern int display_packed_bits; /*print 1-8 byte numbers as packed bits*/ +extern int include_attrs; /* Display attributes */ /* sort parameters */ extern H5_index_t sort_by; /*sort_by [creation_order | name] */ diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index a05b477..c90cba4 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -173,6 +173,7 @@ $SRC_H5DUMP_TESTFILES/packedbits.ddl $SRC_H5DUMP_TESTFILES/tall-1.ddl $SRC_H5DUMP_TESTFILES/tall-2.ddl $SRC_H5DUMP_TESTFILES/tall-2A.ddl +$SRC_H5DUMP_TESTFILES/tall-2A0.ddl $SRC_H5DUMP_TESTFILES/tall-2B.ddl $SRC_H5DUMP_TESTFILES/tall-3.ddl $SRC_H5DUMP_TESTFILES/tall-4s.ddl @@ -333,6 +334,7 @@ LIST_ERROR_TEST_FILES=" ${SRC_H5DUMP_ERRORFILES}/filter_fail.err ${SRC_H5DUMP_ERRORFILES}/tall-1.err ${SRC_H5DUMP_ERRORFILES}/tall-2A.err +${SRC_H5DUMP_ERRORFILES}/tall-2A0.err ${SRC_H5DUMP_ERRORFILES}/tall-2B.err ${SRC_H5DUMP_ERRORFILES}/tarray1_big.err ${SRC_H5DUMP_ERRORFILES}/tattr-3.err @@ -1003,6 +1005,9 @@ TOOLTEST tlarge_objname.ddl --enable-error-stack -w157 tlarge_objname.h5 # test '-A' to suppress data but print attr's TOOLTEST4 tall-2A.ddl --enable-error-stack -A tall.h5 +# test '-A' to suppress attr's but print data +TOOLTEST4 tall-2A0.ddl --enable-error-stack -A 0 tall.h5 + # test '-r' to print attributes in ASCII instead of decimal TOOLTEST4 tall-2B.ddl --enable-error-stack -A -r tall.h5 diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index d6ed2f3..9202925 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -1395,24 +1395,24 @@ h5tools_str_replace ( const char *string, const char *substr, const char *replac char *head = NULL; if ( substr == NULL || replacement == NULL ) - return strdup (string); + return HDstrdup (string); - newstr = strdup (string); + newstr = HDstrdup (string); head = newstr; - while ( (tok = strstr ( head, substr ))){ + while ( (tok = HDstrstr ( head, substr ))){ oldstr = newstr; - newstr = HDmalloc ( strlen ( oldstr ) - strlen ( substr ) + strlen ( replacement ) + 1 ); + newstr = HDmalloc ( HDstrlen ( oldstr ) - HDstrlen ( substr ) + HDstrlen ( replacement ) + 1 ); if ( newstr == NULL ){ HDfree (oldstr); return NULL; } - memcpy ( newstr, oldstr, tok - oldstr ); - memcpy ( newstr + (tok - oldstr), replacement, strlen ( replacement ) ); - memcpy ( newstr + (tok - oldstr) + strlen( replacement ), tok + strlen ( substr ), strlen ( oldstr ) - strlen ( substr ) - ( tok - oldstr ) ); - memset ( newstr + strlen ( oldstr ) - strlen ( substr ) + strlen ( replacement ) , 0, 1 ); + HDmemcpy ( newstr, oldstr, tok - oldstr ); + HDmemcpy ( newstr + (tok - oldstr), replacement, HDstrlen ( replacement ) ); + HDmemcpy ( newstr + (tok - oldstr) + HDstrlen( replacement ), tok + HDstrlen ( substr ), HDstrlen ( oldstr ) - HDstrlen ( substr ) - ( tok - oldstr ) ); + HDmemset ( newstr + HDstrlen ( oldstr ) - HDstrlen ( substr ) + HDstrlen ( replacement ) , 0, 1 ); /* move back head right after the last replacement */ - head = newstr + (tok - oldstr) + strlen( replacement ); + head = newstr + (tok - oldstr) + HDstrlen( replacement ); HDfree (oldstr); } diff --git a/tools/testfiles/h5dump-help.txt b/tools/testfiles/h5dump-help.txt index 40510a4..b735b18 100644 --- a/tools/testfiles/h5dump-help.txt +++ b/tools/testfiles/h5dump-help.txt @@ -6,6 +6,7 @@ usage: h5dump [OPTIONS] files -B, --superblock Print the content of the super block -H, --header Print the header only; no data is displayed -A, --onlyattr Print the header and value of attributes + Optional value 0 suppresses printing attributes. -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII -e, --escape Escape non printing characters diff --git a/tools/testfiles/tall-2A0.ddl b/tools/testfiles/tall-2A0.ddl new file mode 100644 index 0000000..e0955f3 --- /dev/null +++ b/tools/testfiles/tall-2A0.ddl @@ -0,0 +1,64 @@ +HDF5 "tall.h5" { +GROUP "/" { + GROUP "g1" { + GROUP "g1.1" { + DATASET "dset1.1.1" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 10, 10 ) / ( 10, 10 ) } + DATA { + (0,0): 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + (1,0): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + (2,0): 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, + (3,0): 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, + (4,0): 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, + (5,0): 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, + (6,0): 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, + (7,0): 0, 7, 14, 21, 28, 35, 42, 49, 56, 63, + (8,0): 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, + (9,0): 0, 9, 18, 27, 36, 45, 54, 63, 72, 81 + } + } + DATASET "dset1.1.2" { + DATATYPE H5T_STD_I32BE + DATASPACE SIMPLE { ( 20 ) / ( 20 ) } + DATA { + (0): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + (17): 17, 18, 19 + } + } + } + GROUP "g1.2" { + EXTERNAL_LINK "extlink" { + TARGETFILE "somefile" + TARGETPATH "somepath" + } + GROUP "g1.2.1" { + SOFTLINK "slink" { + LINKTARGET "somevalue" + } + } + } + } + GROUP "g2" { + DATASET "dset2.1" { + DATATYPE H5T_IEEE_F32BE + DATASPACE SIMPLE { ( 10 ) / ( 10 ) } + DATA { + (0): 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9 + } + } + DATASET "dset2.2" { + DATATYPE H5T_IEEE_F32BE + DATASPACE SIMPLE { ( 3, 5 ) / ( 3, 5 ) } + DATA { + (0,0): 0, 0.1, 0.2, 0.3, 0.4, + (1,0): 0, 0.2, 0.4, 0.6, 0.8, + (2,0): 0, 0.3, 0.6, 0.9, 1.2 + } + } + USERDEFINED_LINK "udlink" { + LINKCLASS 187 + } + } +} +} diff --git a/tools/testfiles/tnofilename-with-packed-bits.ddl b/tools/testfiles/tnofilename-with-packed-bits.ddl index 440e3d9..e8d6d84 100644 --- a/tools/testfiles/tnofilename-with-packed-bits.ddl +++ b/tools/testfiles/tnofilename-with-packed-bits.ddl @@ -6,6 +6,7 @@ usage: h5dump [OPTIONS] files -B, --superblock Print the content of the super block -H, --header Print the header only; no data is displayed -A, --onlyattr Print the header and value of attributes + Optional value 0 suppresses printing attributes. -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII -e, --escape Escape non printing characters diff --git a/tools/testfiles/tpbitsIncomplete.ddl b/tools/testfiles/tpbitsIncomplete.ddl index 758b6b4..06c5613 100644 --- a/tools/testfiles/tpbitsIncomplete.ddl +++ b/tools/testfiles/tpbitsIncomplete.ddl @@ -6,6 +6,7 @@ usage: h5dump [OPTIONS] files -B, --superblock Print the content of the super block -H, --header Print the header only; no data is displayed -A, --onlyattr Print the header and value of attributes + Optional value 0 suppresses printing attributes. -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII -e, --escape Escape non printing characters diff --git a/tools/testfiles/tpbitsLengthExceeded.ddl b/tools/testfiles/tpbitsLengthExceeded.ddl index a85ba49..ffd9910 100644 --- a/tools/testfiles/tpbitsLengthExceeded.ddl +++ b/tools/testfiles/tpbitsLengthExceeded.ddl @@ -6,6 +6,7 @@ usage: h5dump [OPTIONS] files -B, --superblock Print the content of the super block -H, --header Print the header only; no data is displayed -A, --onlyattr Print the header and value of attributes + Optional value 0 suppresses printing attributes. -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII -e, --escape Escape non printing characters diff --git a/tools/testfiles/tpbitsLengthPositive.ddl b/tools/testfiles/tpbitsLengthPositive.ddl index d5a1c88..a54812b 100644 --- a/tools/testfiles/tpbitsLengthPositive.ddl +++ b/tools/testfiles/tpbitsLengthPositive.ddl @@ -6,6 +6,7 @@ usage: h5dump [OPTIONS] files -B, --superblock Print the content of the super block -H, --header Print the header only; no data is displayed -A, --onlyattr Print the header and value of attributes + Optional value 0 suppresses printing attributes. -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII -e, --escape Escape non printing characters diff --git a/tools/testfiles/tpbitsMaxExceeded.ddl b/tools/testfiles/tpbitsMaxExceeded.ddl index e24245c..1a8dd11 100644 --- a/tools/testfiles/tpbitsMaxExceeded.ddl +++ b/tools/testfiles/tpbitsMaxExceeded.ddl @@ -6,6 +6,7 @@ usage: h5dump [OPTIONS] files -B, --superblock Print the content of the super block -H, --header Print the header only; no data is displayed -A, --onlyattr Print the header and value of attributes + Optional value 0 suppresses printing attributes. -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII -e, --escape Escape non printing characters diff --git a/tools/testfiles/tpbitsOffsetExceeded.ddl b/tools/testfiles/tpbitsOffsetExceeded.ddl index 8f58c47..7527131 100644 --- a/tools/testfiles/tpbitsOffsetExceeded.ddl +++ b/tools/testfiles/tpbitsOffsetExceeded.ddl @@ -6,6 +6,7 @@ usage: h5dump [OPTIONS] files -B, --superblock Print the content of the super block -H, --header Print the header only; no data is displayed -A, --onlyattr Print the header and value of attributes + Optional value 0 suppresses printing attributes. -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII -e, --escape Escape non printing characters diff --git a/tools/testfiles/tpbitsOffsetNegative.ddl b/tools/testfiles/tpbitsOffsetNegative.ddl index 6df8cce..21b573d 100644 --- a/tools/testfiles/tpbitsOffsetNegative.ddl +++ b/tools/testfiles/tpbitsOffsetNegative.ddl @@ -6,6 +6,7 @@ usage: h5dump [OPTIONS] files -B, --superblock Print the content of the super block -H, --header Print the header only; no data is displayed -A, --onlyattr Print the header and value of attributes + Optional value 0 suppresses printing attributes. -i, --object-ids Print the object ids -r, --string Print 1-byte integer datasets as ASCII -e, --escape Escape non printing characters -- cgit v0.12