summaryrefslogtreecommitdiffstats
path: root/tools/h5dump
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2013-04-18 18:23:51 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2013-04-18 18:23:51 (GMT)
commit6ee0e05fb94445551840fcb80b9b1c254c736799 (patch)
tree0acf68cdc69dae2ff0e2a72b36e4efb6f8fbfd06 /tools/h5dump
parent94f89911545edce6fc9ebde2c83357cbda0bbd70 (diff)
downloadhdf5-6ee0e05fb94445551840fcb80b9b1c254c736799.zip
hdf5-6ee0e05fb94445551840fcb80b9b1c254c736799.tar.gz
hdf5-6ee0e05fb94445551840fcb80b9b1c254c736799.tar.bz2
[svn-r23599] Bring revisions 22802 : 23085 from trunk to revise_chunks.
h5committested.
Diffstat (limited to 'tools/h5dump')
-rw-r--r--tools/h5dump/CMakeLists.txt6
-rw-r--r--tools/h5dump/h5dump.c20
-rw-r--r--tools/h5dump/h5dump_xml.c3
-rw-r--r--tools/h5dump/h5dump_xml.h8
-rw-r--r--tools/h5dump/h5dumpgentest.c64
-rw-r--r--tools/h5dump/testh5dump.sh.in4
6 files changed, 82 insertions, 23 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt
index 8bd684e..e1ade89 100644
--- a/tools/h5dump/CMakeLists.txt
+++ b/tools/h5dump/CMakeLists.txt
@@ -160,6 +160,7 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/tsaf.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarintsize.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarattrintsize.ddl
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarstring.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tscaleoffset.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tshuffle.ddl
${HDF5_TOOLS_SRC_DIR}/testfiles/tslink-1.ddl
@@ -263,6 +264,7 @@ IF (BUILD_TESTING)
${HDF5_TOOLS_SRC_DIR}/testfiles/tsaf.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarintsize.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarattrintsize.h5
+ ${HDF5_TOOLS_SRC_DIR}/testfiles/tscalarstring.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tslink.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tsplit_file-m.h5
${HDF5_TOOLS_SRC_DIR}/testfiles/tsplit_file-r.h5
@@ -1023,6 +1025,8 @@ IF (BUILD_TESTING)
tscalarintsize.out.err
tscalarattrintsize.out
tscalarattrintsize.out.err
+ tscalarstring.out
+ tscalarstring.out.err
tscaleoffset.out
tscaleoffset.out.err
tshuffle.out
@@ -1094,6 +1098,8 @@ IF (BUILD_TESTING)
ADD_H5_TEST (tcmpdattrintsize 0 --enable-error-stack tcmpdattrintsize.h5)
# test for signed/unsigned scalar attributes
ADD_H5_TEST (tscalarattrintsize 0 --enable-error-stack tscalarattrintsize.h5)
+ # test for string scalar dataset and attribute
+ ADD_H5_TEST (tscalarstring 0 --enable-error-stack tscalarstring.h5)
# test for displaying groups
ADD_H5_TEST (tgroup-1 0 --enable-error-stack tgroup.h5)
# test for displaying the selected groups
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 2921fb9..34b8bc4 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -932,7 +932,7 @@ parse_mask_list(const char *h_list)
static void
free_handler(struct handler_t *hand, int len)
{
- register int i;
+ int i;
if(hand) {
for (i = 0; i < len; i++) {
@@ -997,7 +997,7 @@ parse_command_line(int argc, const char *argv[])
/* this will be plenty big enough to hold the info */
if((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t)))==NULL) {
- goto error;
+ goto error;
}
/* parse command line options */
@@ -1054,7 +1054,7 @@ parse_start:
break;
case 'w':
h5tools_nCols = HDatoi(opt_arg);
- if (h5tools_nCols==0) {
+ if (h5tools_nCols <= 0) {
h5tools_nCols = 65535;
}
last_was_dset = FALSE;
@@ -1293,7 +1293,7 @@ parse_start:
if (s->count.data) {
HDfree(s->count.data);
s->count.data = NULL;
- }
+ }
parse_hsize_list(opt_arg, &s->count);
break;
case 'k':
@@ -1356,6 +1356,7 @@ error:
return hand;
}
+
/*-------------------------------------------------------------------------
* Function: main
@@ -1423,6 +1424,7 @@ main(int argc, const char *argv[])
/* Initialize h5tools lib */
h5tools_init();
+
/* Disable tools error reporting */
H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
@@ -1449,28 +1451,28 @@ main(int argc, const char *argv[])
"to display selected objects");
h5tools_setstatus(EXIT_FAILURE);
goto done;
- }
+ }
else if (display_bb) {
error_msg("option \"%s\" not available for XML\n", "--boot-block");
h5tools_setstatus(EXIT_FAILURE);
goto done;
- }
+ }
else if (display_oid == 1) {
error_msg("option \"%s\" not available for XML\n", "--object-ids");
h5tools_setstatus(EXIT_FAILURE);
goto done;
- }
+ }
else if (display_char == TRUE) {
error_msg("option \"%s\" not available for XML\n", "--string");
h5tools_setstatus(EXIT_FAILURE);
goto done;
- }
+ }
else if (usingdasho) {
error_msg("option \"%s\" not available for XML\n", "--output");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
- }
+ }
else {
if (xml_dtd_uri) {
warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri);
diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c
index 1a29659..28264e7 100644
--- a/tools/h5dump/h5dump_xml.c
+++ b/tools/h5dump/h5dump_xml.c
@@ -3761,7 +3761,8 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
/* Print information about storage layout */
if (H5D_CHUNKED == H5Pget_layout(dcpl)) {
maxdims = H5Sget_simple_extent_ndims(space);
- chsize = (hsize_t *) HDmalloc(maxdims * sizeof(hsize_t));
+ HDassert(maxdims >= 0);
+ chsize = (hsize_t *)HDmalloc((size_t)maxdims * sizeof(hsize_t));
ctx.indent_level++;
dump_indent += COL;
diff --git a/tools/h5dump/h5dump_xml.h b/tools/h5dump/h5dump_xml.h
index 04d02c9..d4c8365 100644
--- a/tools/h5dump/h5dump_xml.h
+++ b/tools/h5dump/h5dump_xml.h
@@ -103,14 +103,6 @@ static h5tool_format_t xml_dataformat = {
extern "C" {
#endif
-/* internal functions used by XML option */
-static void xml_print_datatype(hid_t, unsigned);
-static void xml_print_enum(hid_t);
-static int xml_print_refs(hid_t, int);
-static int xml_print_strs(hid_t, int);
-static char *xml_escape_the_string(const char *, int);
-static char *xml_escape_the_name(const char *);
-
/* The dump functions of the dump_function_table */
/* XML format: same interface, alternative output */
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 28fb4a4..d56fed5 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -105,6 +105,7 @@
#define FILE72 "tnestedcmpddt.h5"
#define FILE73 "tscalarintsize.h5"
#define FILE74 "tscalarattrintsize.h5"
+#define FILE75 "tscalarstring.h5"
/*-------------------------------------------------------------------------
* prototypes
@@ -8210,7 +8211,7 @@ static void gent_nested_compound_dt(void) { /* test nested data type */
/*-------------------------------------------------------------------------
* Function: gent_intscalars
*
- * Purpose: Generate a file to be used in the h5dump tests.
+ * Purpose: Generate a file to be used in the h5dump scalar tests.
* Four datasets of 1, 2, 4 and 8 bytes of unsigned int types are created.
* Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created.
* Fill them with raw data such that no bit will be all zero in a dataset.
@@ -8390,7 +8391,7 @@ gent_intscalars(void)
/* Double Dummy set for failure tests */
dims[0] = F73_XDIM; dims[1] = F73_YDIM8;
space = H5Screate(H5S_SCALAR);
- tid = H5Tarray_create2(H5T_IEEE_F64BE, F73_ARRAY_RANK, dims);
+ tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims);
dataset = H5Dcreate2(fid, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; i < dims[0]; i++)
@@ -8405,9 +8406,9 @@ gent_intscalars(void)
}
/*-------------------------------------------------------------------------
- * Function: gent_attr_packedbits
+ * Function: gent_attr_intscalars
*
- * Purpose: Generate a file to be used in the h5dump packed bits tests.
+ * Purpose: Generate a file to be used in the h5dump attribute scalar tests.
* Four attributes of 1, 2, 4 and 8 bytes of unsigned int types are created.
* Four more datasets of 1, 2, 4 and 8 bytes of signed int types are created.
* Fill them with raw data such that no bit will be all zero in a dataset.
@@ -8589,7 +8590,7 @@ gent_attr_intscalars(void)
/* Double Dummy set for failure tests */
dims[0] = F73_XDIM; dims[1] = F73_YDIM8;
space = H5Screate(H5S_SCALAR);
- tid = H5Tarray_create2(H5T_IEEE_F64BE, F73_ARRAY_RANK, dims);
+ tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, F73_ARRAY_RANK, dims);
attr = H5Acreate2(root, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT);
for(i = 0; i < dims[0]; i++)
@@ -8606,6 +8607,58 @@ gent_attr_intscalars(void)
}
/*-------------------------------------------------------------------------
+ * Function: gent_string_scalars
+ *
+ * Purpose: Generate a file to be used in the h5dump string scalar tests.
+ * A dataset of string types are created.
+ * An attribute of string types are created.
+ * Fill them with raw data such that no bit will be all zero in a dataset.
+ *-------------------------------------------------------------------------
+ */
+static void
+gent_string_scalars(void)
+{
+ hid_t fid, attr, dataset, space, tid, root;
+ hsize_t dims[2];
+ char string[F73_XDIM][F73_YDIM8];
+ unsigned int i, j;
+
+ fid = H5Fcreate(FILE75, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ root = H5Gopen2(fid, "/", H5P_DEFAULT);
+
+ /* string scalar */
+ dims[0] = F73_XDIM; dims[1] = F73_YDIM8;
+ space = H5Screate(H5S_SCALAR);
+ tid = H5Tcopy(H5T_C_S1);
+ H5Tset_size(tid, F73_XDIM * F73_YDIM8);
+
+ memset(string, ' ', F73_XDIM * F73_YDIM8);
+ for(i = 0; i < dims[0]; i++) {
+ string[i][0] = 'A' + i;
+ for(j = 1; j < dims[1]; j++) {
+ string[i][j] = string[i][j-1] + 1;
+ }
+ }
+ string[dims[0]-1][dims[1]-1] = 0;
+
+ /* Dataset of string scalar */
+ dataset = H5Dcreate2(fid, "the_str", tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, string);
+ H5Dclose(dataset);
+
+ /* attribute of string scalar */
+ attr = H5Acreate2(root, "attr_str", tid, space, H5P_DEFAULT, H5P_DEFAULT);
+ H5Awrite(attr, tid, string);
+
+ H5Sclose(space);
+ H5Aclose(attr);
+
+ H5Gclose(root);
+ H5Fclose(fid);
+}
+
+/*-------------------------------------------------------------------------
* Function: main
*
*-------------------------------------------------------------------------
@@ -8690,6 +8743,7 @@ int main(void)
gent_nested_compound_dt();
gent_intscalars();
gent_attr_intscalars();
+ gent_string_scalars();
return 0;
}
diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in
index c90c364..8a2483b 100644
--- a/tools/h5dump/testh5dump.sh.in
+++ b/tools/h5dump/testh5dump.sh.in
@@ -145,6 +145,7 @@ $SRC_H5DUMP_TESTFILES/tordergr.h5
$SRC_H5DUMP_TESTFILES/tsaf.h5
$SRC_H5DUMP_TESTFILES/tscalarintsize.h5
$SRC_H5DUMP_TESTFILES/tscalarattrintsize.h5
+$SRC_H5DUMP_TESTFILES/tscalarstring.h5
$SRC_H5DUMP_TESTFILES/tslink.h5
$SRC_H5DUMP_TESTFILES/tsplit_file-m.h5
$SRC_H5DUMP_TESTFILES/tsplit_file-r.h5
@@ -281,6 +282,7 @@ $SRC_H5DUMP_TESTFILES/treference.ddl
$SRC_H5DUMP_TESTFILES/tsaf.ddl
$SRC_H5DUMP_TESTFILES/tscalarintsize.ddl
$SRC_H5DUMP_TESTFILES/tscalarattrintsize.ddl
+$SRC_H5DUMP_TESTFILES/tscalarstring.ddl
$SRC_H5DUMP_TESTFILES/tscaleoffset.ddl
$SRC_H5DUMP_TESTFILES/tshuffle.ddl
$SRC_H5DUMP_TESTFILES/tslink-1.ddl
@@ -690,6 +692,8 @@ TOOLTEST tattrintsize.ddl --enable-error-stack tattrintsize.h5
TOOLTEST tcmpdattrintsize.ddl --enable-error-stack tcmpdattrintsize.h5
# test for signed/unsigned scalar attributes
TOOLTEST tscalarattrintsize.ddl --enable-error-stack tscalarattrintsize.h5
+# test for string scalar dataset attribute
+TOOLTEST tscalarstring.ddl --enable-error-stack tscalarstring.h5
# test for displaying groups
TOOLTEST tgroup-1.ddl --enable-error-stack tgroup.h5
# test for displaying the selected groups