diff options
author | Albert Cheng <acheng@hdfgroup.org> | 2004-11-18 19:44:42 (GMT) |
---|---|---|
committer | Albert Cheng <acheng@hdfgroup.org> | 2004-11-18 19:44:42 (GMT) |
commit | 5b6ab042c461428289fdff6bc0d10dca2e39720e (patch) | |
tree | e336de99a7c532aeceeef36f393c056a30ee850e /tools/h5dump | |
parent | 8d1ec28583c9b8f518e63fcf7876e0fed0fc5c52 (diff) | |
download | hdf5-5b6ab042c461428289fdff6bc0d10dca2e39720e.zip hdf5-5b6ab042c461428289fdff6bc0d10dca2e39720e.tar.gz hdf5-5b6ab042c461428289fdff6bc0d10dca2e39720e.tar.bz2 |
[svn-r9545] Purpose:
Bug fix (#264)
Description:
h5dump did not print attribute data in ASCII format when
-r is used.
Solution:
Added the ability to print in ASCII for Attributes Data also.
Added a test for printing Attributes with -r option.
tall-2B.ddl is the standard output for printing attributes with -r option.
Platforms tested:
tested in heping.
Misc. update:
Update MANIFEST.
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/h5dump.c | 35 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 3 |
2 files changed, 37 insertions, 1 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 4f88223..e9803b3 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1839,6 +1839,8 @@ dump_subsetting_header(struct subset_t *sset, int dims) * Programmer: Ruey-Hsia Li * * Modifications: pvn, print the matrix indices + * Albert Cheng, 2004/11/18 + * Add --string printing for attributes too. * *------------------------------------------------------------------------- */ @@ -1927,6 +1929,9 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) status = h5tools_dump_dset(stdout, outputformat, obj_id, -1, sset, depth); H5Tclose(f_type); } else { + char string_prefix[64]; + h5dump_t string_dataformat; + /* need to call h5tools_dump_mem for the attribute data */ type = H5Aget_type(obj_id); p_type = h5tools_get_native_type(type); @@ -1943,9 +1948,37 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int pindex) buf = malloc((size_t)alloc_size); assert(buf); - if (H5Aread(obj_id, p_type, buf) >= 0) + if (H5Aread(obj_id, p_type, buf) >= 0){ + if (display_char && H5Tget_size(type) == 1 && H5Tget_class(type) == H5T_INTEGER) { + /* + * Print 1-byte integer data as an ASCII character string + * instead of integers if the `-r' or `--string' command-line + * option was given. + * + * We don't want to modify the global dataformat, so make a + * copy of it instead. + */ + string_dataformat = *outputformat; + string_dataformat.idx_fmt = " "; + string_dataformat.line_multi_new = 1; + string_dataformat.line_1st = " %s\""; + string_dataformat.line_pre = " %s"; + string_dataformat.line_cont = " %s"; + string_dataformat.str_repeat = 8; + string_dataformat.ascii = TRUE; + string_dataformat.elmt_suf1 = ""; + string_dataformat.elmt_suf2 = ""; + string_dataformat.line_indent = ""; + strcpy(string_prefix, string_dataformat.line_pre); + strcat(string_prefix, "\""); + string_dataformat.line_pre = string_prefix; + string_dataformat.line_suf = "\""; + outputformat = &string_dataformat; + } + status = h5tools_dump_mem(stdout, outputformat, obj_id, p_type, space, buf, depth); + } free(buf); H5Tclose(p_type); diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index e21633b..2414e04 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -198,6 +198,9 @@ TOOLTEST tlarge_objname.ddl -w157 tlarge_objname.h5 # test '-A' to suppress data but print attr's TOOLTEST tall-2A.ddl -A tall.h5 +# test '-r' to print attributes in ASCII instead of decimal +TOOLTEST tall-2B.ddl -A -r tall.h5 + # test Subsetting TOOLTEST tall-4s.ddl --dataset=/g1/g1.1/dset1.1.1 --start=1,1 --stride=2,3 --count=3,2 --block=1,1 tall.h5 TOOLTEST tall-5s.ddl -d "/g1/g1.1/dset1.1.2[0;2;10;]" tall.h5 |