From 8c1c416d4d0e948befe5436a34c11f2c86bcc745 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sat, 5 Jan 2002 21:18:20 -0500 Subject: [svn-r4784] Purpose: feature add Description: Added ability to h5dumper to dump Group comments. Solution: Stole the code from h5ls that does this and put it into the h5dumper code. Modified the DDL to reflect the newest change. Added a testcase (tgrp_comments.*) to test that it's actually doing the comments correctly. Small modification to H5G.c. The error comment should have said that it couldn't "get" the comment instead of "set" the comment... Platforms tested: Dangermouse, Kelgai, Modi4 --- MANIFEST | 2 ++ doc/html/ddl.html | 17 +++++++++---- release_docs/RELEASE.txt | 2 ++ src/H5G.c | 2 +- tools/h5dump/h5dump.c | 10 +++++++- tools/h5dump/h5dumptst.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ tools/h5dump/testh5dump.sh | 3 +++ 7 files changed, 89 insertions(+), 7 deletions(-) diff --git a/MANIFEST b/MANIFEST index f9ec174..e9e7f3d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1077,6 +1077,8 @@ ./tools/testfiles/tgroup-1.ddl ./tools/testfiles/tgroup-2.ddl ./tools/testfiles/tgroup.h5 +./tools/testfiles/tgrp_comments.ddl +./tools/testfiles/tgrp_comments.h5 ./tools/testfiles/thlink-1.ddl ./tools/testfiles/thlink-2.ddl ./tools/testfiles/thlink-3.ddl diff --git a/doc/html/ddl.html b/doc/html/ddl.html index 474e757..ccfe579 100644 --- a/doc/html/ddl.html +++ b/doc/html/ddl.html @@ -6,7 +6,6 @@ -
@@ -84,8 +83,13 @@ This section contains a brief explanation of the symbols used in the DDL. <super_block_content> ::= TBD -<root_group> ::= GROUP "/" { <unamed_datatype>* <object_id>opt - <group_attribute>* <group_member>* } +<root_group> ::= GROUP "/" { + <unamed_datatype>* + <object_id>opt + <group_comment>opt + <group_attribute>* + <group_member>* + } <datatype> ::= <atomic_type> | <compound_type> | <variable_length_type> | <array_type> @@ -272,10 +276,12 @@ This section contains a brief explanation of the symbols used in the DDL. <hardlink> ::= HARDLINK <path_name> <group> ::= GROUP <group_name> { <hardlink> | <group_info> } + +<group_comment> ::= COMMENT <string_data> <group_name> ::= <identifier> -<group_info> ::= <group_attribute>* <group_member>* +<group_info> ::= <object_id>opt <group_comment>opt <group_attribute>* <group_member>* <group_attribute> ::= <attribute> @@ -404,6 +410,7 @@ GROUP "/" { } } GROUP "group1" { + COMMENT "This is a comment for group1"; DATASET "dset3" { DATATYPE "/type1" DATASPACE SIMPLE { ( 5 ) / ( 5 ) } @@ -519,7 +526,7 @@ GROUP "/" { HDF Help Desk -Last modified: 11 December 2000 +Last modified: 05 January 2002
Describes HDF5 Release 1.4.2, July 2001 diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 72d4199..2723166 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -57,10 +57,12 @@ New Features * Parallel HDF5 now works on HP-UX platforms. * Can use just enable-threadsafe if the C compiler has builtin pthreads support. + * The H5Dumper can now dump comments associated with groups. -WCW 01-05-02 Bug Fixes since HDF5-1.4.2 Release ================================== + * Fixed a bug when reading chunked datasets where the edge of the dataset would be incorrectly detected and generate an assertion failure. * Fixed a bug where reading an entire dataset wasn't being handled diff --git a/src/H5G.c b/src/H5G.c index 73cf947..92470e7 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -660,7 +660,7 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) if ((retval=H5G_get_comment(loc, name, bufsize, buf))<0) { HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, - "unable to set comment value"); + "unable to get comment value"); } FUNC_LEAVE(retval); diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 282c723..6e4db4d 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1564,7 +1564,7 @@ dump_group(hid_t gid, const char *name) { H5G_stat_t statbuf; hid_t dset, type; - char typename[1024], *tmp; + char typename[1024], *tmp, comment[50]; int i, xtype = H5G_UNKNOWN; /* dump all */ tmp = malloc(strlen(prefix) + strlen(name) + 2); @@ -1577,6 +1577,14 @@ dump_group(hid_t gid, const char *name) if (display_oid) dump_oid(gid); + comment[0] = '\0'; + H5Gget_comment(gid, ".", sizeof(comment), comment); + + if (comment[0]) { + indentation(indent); + printf("COMMENT \"%s\"\n", comment); + } + if (!strcmp(name, "/") && unamedtype) /* dump unamed type in root group */ for (i = 0; i < type_table->nobjs; i++) diff --git a/tools/h5dump/h5dumptst.c b/tools/h5dump/h5dumptst.c index 5fd2e17..e9dda05 100644 --- a/tools/h5dump/h5dumptst.c +++ b/tools/h5dump/h5dumptst.c @@ -44,6 +44,7 @@ #define FILE30 "tarray6.h5" #define FILE31 "tarray7.h5" #define FILE32 "tempty.h5" +#define FILE33 "tgrp_comments.h5" #define LENSTR 50 #define LENSTR2 11 @@ -2529,6 +2530,64 @@ static void test_empty(void) ret = H5Fclose(file); } +static void test_group_comments(void) +{ + hid_t fid, group; + + fid = H5Fcreate(FILE33, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + /* / */ + group = H5Gcreate (fid, "/g1", 0); + H5Gset_comment(group, "/g1", "Comment for group /g1"); + H5Gclose(group); + group = H5Gcreate (fid, "/g2", 0); + H5Gset_comment(group, "/g2", "Comment for group /g2"); + H5Gclose(group); + group = H5Gcreate (fid, "/g3", 0); + H5Gset_comment(group, "/g3", "Comment for group /g3"); + H5Gclose(group); + + /* /g1 */ + group = H5Gcreate (fid, "/g1/g1.1", 0); + H5Gset_comment(group, "/g1/g1.1", "Comment for group /g1/g1.1"); + H5Gclose(group); + group = H5Gcreate (fid, "/g1/g1.2", 0); + H5Gset_comment(group, "/g1/g1.2", "Comment for group /g1/g1.2"); + H5Gclose(group); + + /* /g2 */ + group = H5Gcreate (fid, "/g2/g2.1", 0); + H5Gset_comment(group, "/g2/g2.1", "Comment for group /g2/g2.1"); + H5Gclose(group); + + /* /g3 */ + group = H5Gcreate (fid, "/g3/g3.1", 0); + H5Gset_comment(group, "/g3/g3.1", "Comment for group /g3/g3.1"); + H5Gclose(group); + group = H5Gcreate (fid, "/g3/g3.2", 0); + H5Gset_comment(group, "/g3/g3.2", "Comment for group /g3/g3.2"); + H5Gclose(group); + group = H5Gcreate (fid, "/g3/g3.3", 0); + H5Gset_comment(group, "/g3/g3.3", "Comment for group /g3/g3.3"); + H5Gclose(group); + group = H5Gcreate (fid, "/g3/g3.4", 0); + H5Gset_comment(group, "/g3/g3.4", "Comment for group /g3/g3.4"); + H5Gclose(group); + + /* /g2/g2.1 */ + group = H5Gcreate (fid, "/g2/g2.1/g2.1.1", 0); + H5Gset_comment(group, "/g2/g2.1/g2.1.1", "Comment for group /g2/g2.1/g2.1.1"); + H5Gclose(group); + group = H5Gcreate (fid, "/g2/g2.1/g2.1.2", 0); + H5Gset_comment(group, "/g2/g2.1/g2.1.2", "Comment for group /g2/g2.1/g2.1.2"); + H5Gclose(group); + group = H5Gcreate (fid, "/g2/g2.1/g2.1.3", 0); + H5Gset_comment(group, "/g2/g2.1/g2.1.3", "Comment for group /g2/g2.1/g2.1.3"); + H5Gclose(group); + + H5Fclose(fid); +} + int main(void) { test_group(); @@ -2573,6 +2632,7 @@ int main(void) test_array7(); test_empty(); + test_group_comments(); return 0; } diff --git a/tools/h5dump/testh5dump.sh b/tools/h5dump/testh5dump.sh index 55d86fc..4776ce3 100755 --- a/tools/h5dump/testh5dump.sh +++ b/tools/h5dump/testh5dump.sh @@ -147,6 +147,9 @@ TOOLTEST tarray7.ddl tarray7.h5 # test for files with empty data TOOLTEST tempty.ddl tempty.h5 +# test for files with groups that have comments +TOOLTEST tgrp_comments.ddl tgrp_comments.h5 + # test XML TOOLTEST tall.h5.xml --xml tall.h5 TOOLTEST tattr.h5.xml --xml tattr.h5 -- cgit v0.12