summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2013-04-19 15:23:01 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2013-04-19 15:23:01 (GMT)
commit14d8e1c2b5ecaf2e298984f269094dd5f2bd735f (patch)
treecc250461294a2c9118b10a95d0459d7314fa5e50 /tools/lib
parent6ee0e05fb94445551840fcb80b9b1c254c736799 (diff)
downloadhdf5-14d8e1c2b5ecaf2e298984f269094dd5f2bd735f.zip
hdf5-14d8e1c2b5ecaf2e298984f269094dd5f2bd735f.tar.gz
hdf5-14d8e1c2b5ecaf2e298984f269094dd5f2bd735f.tar.bz2
[svn-r23600] Bring revisions #23085 - #23341 from trunk to revise_chunks.
h5committested.
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/CMakeLists.txt2
-rw-r--r--tools/lib/Makefile.in2
-rw-r--r--tools/lib/h5diff_attr.c7
-rw-r--r--tools/lib/h5tools.c136
-rw-r--r--tools/lib/h5tools.h7
-rw-r--r--tools/lib/h5tools_dump.c8
-rw-r--r--tools/lib/h5tools_str.c379
-rw-r--r--tools/lib/h5tools_utils.c20
8 files changed, 294 insertions, 267 deletions
diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt
index 7f7b451..f0d0d01 100644
--- a/tools/lib/CMakeLists.txt
+++ b/tools/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.8.6)
+cmake_minimum_required (VERSION 2.8.10)
PROJECT (HDF5_TOOLS_LIB)
#-----------------------------------------------------------------------------
diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in
index 6a76e1d..743e158 100644
--- a/tools/lib/Makefile.in
+++ b/tools/lib/Makefile.in
@@ -226,6 +226,7 @@ H5_VERSION = @H5_VERSION@
HADDR_T = @HADDR_T@
HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
+HAVE_PTHREAD = @HAVE_PTHREAD@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
HDF_CXX = @HDF_CXX@
@@ -277,7 +278,6 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PARALLEL = @PARALLEL@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
-PTHREAD = @PTHREAD@
RANLIB = @RANLIB@
ROOT = @ROOT@
RUNPARALLEL = @RUNPARALLEL@
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 130a0d8..4899200 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -350,6 +350,13 @@ hsize_t diff_attr(hid_t loc1_id,
if( build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, options) < 0)
goto error;
+ /* if detect any unique extra attr */
+ if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2)
+ {
+ /* exit will be 1 */
+ options->contents = 0;
+ }
+
for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++)
{
if( (match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1]) )
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 7b6098d..5f4227c 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -30,16 +30,13 @@
#include "h5tools_utils.h"
#include "H5private.h"
-#define SANITY_CHECK
-
-#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z))
-
/* global variables */
hid_t H5tools_ERR_STACK_g = 0;
hid_t H5tools_ERR_CLS_g = -1;
hid_t H5E_tools_g = -1;
hid_t H5E_tools_min_id_g = -1;
int compound_data;
+FILE *rawattrstream; /* should initialize to stdout but gcc moans about it */
FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */
FILE *rawoutstream; /* should initialize to stdout but gcc moans about it */
FILE *rawerrorstream; /* should initialize to stderr but gcc moans about it */
@@ -119,6 +116,8 @@ h5tools_init(void)
H5tools_ERR_STACK_g = H5Ecreate_stack();
H5TOOLS_INIT_ERROR()
+ if (!rawattrstream)
+ rawattrstream = stdout;
if (!rawdatastream)
rawdatastream = stdout;
if (!rawoutstream)
@@ -154,9 +153,19 @@ h5tools_close(void)
H5E_auto2_t tools_func;
void *tools_edata;
if (h5tools_init_g) {
+ /* special case where only data is output to stdout */
+ if((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout))
+ HDfprintf(rawdatastream, "\n");
+
H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
if(tools_func!=NULL)
H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream);
+ if (rawattrstream && rawattrstream != stdout) {
+ if (fclose(rawattrstream))
+ perror("closing rawattrstream");
+ else
+ rawattrstream = NULL;
+ }
if (rawdatastream && rawdatastream != stdout) {
if (fclose(rawdatastream))
perror("closing rawdatastream");
@@ -573,6 +582,9 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
size_t templength = 0;
int i, indentlevel = 0;
+ if (stream == NULL)
+ return;
+
if (!ctx->need_prefix)
return;
@@ -581,9 +593,9 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
/* Terminate previous line, if any */
if (ctx->cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
+ PUTSTREAM(OPT(info->line_suf, ""), stream);
HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ PUTSTREAM(OPT(info->line_sep, ""), stream);
}
/* Calculate new prefix */
@@ -607,23 +619,26 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
the prefix is printed one indentation level before */
if (info->pindex) {
for (i = 0; i < indentlevel - 1; i++) {
- HDfputs(h5tools_str_fmt(&str, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&str, 0, info->line_indent), stream);
}
}
- if (elmtno == 0 && secnum == 0 && info->line_1st)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
- else if (secnum && info->line_cont)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
- else
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ if (elmtno == 0 && secnum == 0 && info->line_1st) {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
+ }
+ else if (secnum && info->line_cont) {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
+ }
+ else {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ }
templength = h5tools_str_len(&prefix);
for (i = 0; i < indentlevel; i++) {
/*we already made the indent for the array indices case */
if (!info->pindex) {
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
templength += h5tools_str_len(&prefix);
}
else {
@@ -662,6 +677,9 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
size_t templength = 0;
int i, indentlevel = 0;
+ if (stream == NULL)
+ return;
+
if (!ctx->need_prefix)
return;
@@ -670,9 +688,9 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
/* Terminate previous line, if any */
if (ctx->cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
+ PUTSTREAM(OPT(info->line_suf, ""), stream);
HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ PUTSTREAM(OPT(info->line_sep, ""), stream);
}
/* Calculate new prefix */
@@ -696,23 +714,26 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
the prefix is printed one indentation level before */
if (info->pindex) {
for (i = 0; i < indentlevel - 1; i++) {
- HDfputs(h5tools_str_fmt(&str, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&str, 0, info->line_indent), stream);
}
}
- if (elmtno == 0 && secnum == 0 && info->line_1st)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
- else if (secnum && info->line_cont)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
- else
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ if (elmtno == 0 && secnum == 0 && info->line_1st) {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
+ }
+ else if (secnum && info->line_cont) {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
+ }
+ else {
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ }
templength = h5tools_str_len(&prefix);
for (i = 0; i < indentlevel; i++) {
/*we already made the indent for the array indices case */
if (!info->pindex) {
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
+ PUTSTREAM(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
templength += h5tools_str_len(&prefix);
}
else {
@@ -766,6 +787,9 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
int secnum; /*section sequence number */
int multiline; /*datum was multiline */
+ if (stream == NULL)
+ return dimension_break;
+
s = h5tools_str_fmt(buffer, 0, "%s");
/*
@@ -870,12 +894,12 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info,
h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum);
}
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
- HDfputs(OPT(info->elmt_suf2, " "), stream);
+ PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
}
/* Print the section */
- HDfputs(section, stream);
+ PUTSTREAM(section, stream);
ctx->cur_column += HDstrlen(section);
}
@@ -1026,12 +1050,12 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum);
}
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
- HDfputs(OPT(info->elmt_suf2, " "), stream);
+ PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
}
/* Print the section */
- HDfputs(section, stream);
+ PUTSTREAM(section, stream);
ctx->cur_column += HDstrlen(section);
}
@@ -1095,7 +1119,6 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
while(block_index > 0) {
size_t bytes_in = 0; /* # of bytes to write */
size_t bytes_wrote = 0; /* # of bytes written */
- size_t item_size = size; /* size of items in bytes */
if(block_index > sizeof(size_t))
bytes_in = sizeof(size_t);
@@ -1133,7 +1156,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
}
for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char));
- if (1 != HDfwrite(&tempuchar, size, 1, stream))
+ if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream))
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
} /* i */
} /* for (block_index = 0; block_index < block_nelmts; block_index++) */
@@ -1141,16 +1164,21 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
break;
case H5T_COMPOUND:
{
- unsigned j;
- hid_t memb;
+ int snmembs;
unsigned nmembs;
- size_t offset;
- nmembs = H5Tget_nmembers(tid);
+ if((snmembs = H5Tget_nmembers(tid)) < 0)
+ H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers of compound failed");
+ nmembs = (unsigned)snmembs;
for (block_index = 0; block_index < block_nelmts; block_index++) {
+ unsigned j;
+
mem = ((unsigned char*)_mem) + block_index * size;
for (j = 0; j < nmembs; j++) {
+ hid_t memb;
+ size_t offset;
+
offset = H5Tget_member_offset(tid, j);
memb = H5Tget_member_type(tid, j);
@@ -1165,7 +1193,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
case H5T_ARRAY:
{
int k, ndims;
- hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts;
+ hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts;
hid_t memb;
/* get the array's base datatype for each element */
@@ -1192,7 +1220,6 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
break;
case H5T_VLEN:
{
- unsigned int i;
hsize_t nelmts;
hid_t memb;
@@ -1213,7 +1240,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
break;
case H5T_REFERENCE:
{
- if (H5Tequal(tid, H5T_STD_REF_DSETREG)) {
+ if (size == H5R_DSET_REG_REF_BUF_SIZE) {
+ /* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */
if (region_output) {
/* region data */
hid_t region_id, region_space;
@@ -1237,7 +1265,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
}
} /* end if (region_output... */
}
- else if (H5Tequal(tid, H5T_STD_REF_OBJ)) {
+ else if (size == H5R_OBJ_REF_BUF_SIZE) {
+ /* if (H5Tequal(tid, H5T_STD_REF_OBJ)) */
;
}
}
@@ -1276,10 +1305,9 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
hsize_t *start = NULL;
hsize_t *count = NULL;
hsize_t numelem;
- hsize_t numindex;
hsize_t total_size[H5S_MAX_RANK];
int jndx;
- int type_size;
+ size_t type_size;
hid_t mem_space = -1;
void *region_buf = NULL;
int blkndx;
@@ -1370,15 +1398,17 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container)
{
HERR_INIT(hbool_t, TRUE)
- hssize_t nblocks;
+ hssize_t snblocks;
+ hsize_t nblocks;
hsize_t alloc_size;
- hsize_t *ptdata = NULL;
+ hsize_t *ptdata;
int ndims;
hid_t dtype;
hid_t type_id;
- if((nblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
+ if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
+ nblocks = (hsize_t)snblocks;
/* Print block information */
if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
@@ -1434,13 +1464,12 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
* hssize_t npoints is the number of points in the region
*-------------------------------------------------------------------------
*/
-int
+static int
render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
FILE *stream, hid_t container,
- int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata)
+ int ndims, hid_t type_id, hssize_t npoints)
{
hsize_t *dims1 = NULL;
- int jndx;
int type_size;
hid_t mem_space = -1;
void *region_buf = NULL;
@@ -1496,8 +1525,6 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id,
{
HERR_INIT(hbool_t, TRUE)
hssize_t npoints;
- hsize_t alloc_size;
- hsize_t *ptdata;
int ndims;
hid_t dtype;
hid_t type_id;
@@ -1509,15 +1536,6 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id,
if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
- alloc_size = npoints * ndims * sizeof(ptdata[0]);
- HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
- if(NULL == (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size)))
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
-
- H5_CHECK_OVERFLOW(npoints, hssize_t, hsize_t);
- if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0)
- HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_pointlist failed");
-
if((dtype = H5Dget_type(region_id)) < 0)
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
@@ -1525,11 +1543,9 @@ render_bin_output_region_points(hid_t region_space, hid_t region_id,
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
render_bin_output_region_data_points(region_space, region_id,
- stream, container, ndims, type_id, npoints, ptdata);
+ stream, container, ndims, type_id, npoints);
done:
- HDfree(ptdata);
-
if(H5Tclose(type_id) < 0)
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 1a2b81c..8e5b9c8 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -36,6 +36,12 @@
#define H5TOOLS_DUMP_MAX_RANK H5S_MAX_RANK
+/* Stream macros */
+#define FLUSHSTREAM(S) if(S != NULL) HDfflush(S)
+#define PRINTSTREAM(S, F, ...) if(S != NULL) HDfprintf(S, F, __VA_ARGS__)
+#define PRINTVALSTREAM(S, V) if(S != NULL) HDfprintf(S, V)
+#define PUTSTREAM(X,S) if(S != NULL) HDfputs(X, S);
+
/*
* Strings for output - these were duplicated from the h5dump.h
* file in order to support region reference data display
@@ -533,6 +539,7 @@ H5TOOLS_DLLVAR int packed_bits_num; /* number of packed bits to display
H5TOOLS_DLLVAR int packed_data_offset; /* offset of packed bits to display */
H5TOOLS_DLLVAR int packed_data_length; /* lengtht of packed bits to display */
H5TOOLS_DLLVAR unsigned long long packed_data_mask; /* mask in which packed bits to display */
+H5TOOLS_DLLVAR FILE *rawattrstream; /* output stream for raw attribute data */
H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */
H5TOOLS_DLLVAR FILE *rawoutstream; /* output stream for raw output */
H5TOOLS_DLLVAR FILE *rawerrorstream; /* output stream for raw error */
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 33fef3c..e1f71eb 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -284,9 +284,9 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
*to the ctx->size_last_dim. */
/* binary dump */
- if (bin_output) {
+ if (bin_output && (rawdatastream != NULL)) {
if (render_bin_output(rawdatastream, container, type, _mem, nelmts) < 0) {
- HDfprintf(rawoutstream,"\nError in writing binary stream\n");
+ PRINTVALSTREAM(rawoutstream, "\nError in writing binary stream\n");
}
} /* end if */
else {
@@ -303,7 +303,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai
*/
curr_pos = ctx->sm_pos;
- if (region_output && H5Tequal(type, H5T_STD_REF_DSETREG)) {
+ if (region_output && (size == H5R_DSET_REG_REF_BUF_SIZE)) {
for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) {
void* memref = mem + i * size;
char ref_name[1024];
@@ -1838,7 +1838,7 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c
if (H5Sis_simple(space) <= 0)
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sis_simple failed")
- H5_LEAVE(h5tools_dump_simple_mem(stream, info, ctx, obj_id, type, space, mem))
+ H5_LEAVE(h5tools_dump_simple_mem(rawattrstream, info, ctx, obj_id, type, space, mem))
CATCH
return ret_value;
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 11850f2..b46dc18 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -700,7 +700,8 @@ char *
h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
hid_t type, void *vp, h5tools_context_t *ctx)
{
- size_t n, offset, size=0, nelmts, start;
+ size_t nsize, offset, size=0, nelmts, start;
+ H5T_sign_t nsign;
char *name;
unsigned char *ucp_vp = (unsigned char *)vp;
char *cp_vp = (char *)vp;
@@ -730,15 +731,16 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
/* Append value depending on data type */
start = h5tools_str_len(str);
+ nsize = H5Tget_size(type);
+ nsign = H5Tget_sign(type);
if (info->raw) {
size_t i;
- n = H5Tget_size(type);
- if (1 == n) {
+ if (1 == nsize) {
h5tools_str_append(str, OPT(info->fmt_raw, "0x%02x"), ucp_vp[0]);
}
else {
- for (i = 0; i < n; i++) {
+ for (i = 0; i < nsize; i++) {
if (i)
h5tools_str_append(str, ":");
h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]);
@@ -750,20 +752,23 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
return NULL;
switch (type_class) {
case H5T_FLOAT:
- if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
+ if (sizeof(float) == nsize) {
+ /* if (H5Tequal(type, H5T_NATIVE_FLOAT)) */
float tempfloat;
HDmemcpy(&tempfloat, vp, sizeof(float));
h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat);
}
- else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
+ else if (sizeof(double) == nsize) {
+ /* if (H5Tequal(type, H5T_NATIVE_DOUBLE)) */
double tempdouble;
HDmemcpy(&tempdouble, vp, sizeof(double));
h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble);
#if H5_SIZEOF_LONG_DOUBLE !=0
}
- else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
+ else if (sizeof(long double) == nsize) {
+ /* if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) */
long double templdouble;
HDmemcpy(&templdouble, vp, sizeof(long double));
@@ -848,147 +853,140 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
}
break;
case H5T_INTEGER:
- if (H5Tequal(type, H5T_NATIVE_INT)) {
- HDmemcpy(&tempint, vp, sizeof(int));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(int))
- tempint = 0;
- else
- tempint = (tempint >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
- }
- else if (H5Tequal(type, H5T_NATIVE_UINT)) {
- HDmemcpy(&tempuint, vp, sizeof(unsigned int));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(unsigned int))
- tempuint = 0;
- else
- tempuint = (tempuint >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
- }
- else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) {
- h5tools_print_char(str, info, (char) (*ucp_vp));
- }
- else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
- signed char tempchar;
- HDmemcpy(&tempchar, cp_vp, sizeof(char));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(char))
- tempchar = 0;
- else
- tempchar = (tempchar >> packed_data_offset) & packed_data_mask;
- }
-#ifdef H5_VMS
- h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar);
-#else
- h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar);
-#endif
- }
- else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
- unsigned char tempuchar;
- HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(unsigned char))
- tempuchar = 0;
- else
- tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar);
- }
- else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
- short tempshort;
-
- HDmemcpy(&tempshort, vp, sizeof(short));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(short))
- tempshort = 0;
- else
- tempshort = (tempshort >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
- }
- else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
- unsigned short tempushort;
-
- HDmemcpy(&tempushort, vp, sizeof(unsigned short));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(unsigned short))
- tempushort = 0;
- else
- tempushort = (tempushort >> packed_data_offset) & packed_data_mask;
- }
- h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
- }
- else if (H5Tequal(type, H5T_NATIVE_LONG)) {
- HDmemcpy(&templong, vp, sizeof(long));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(long))
- templong = 0;
- else
- templong = (templong >> packed_data_offset) & packed_data_mask;
+ if (sizeof(char) == nsize) {
+ /* if ((H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) */
+ if (info->ascii) {
+ h5tools_print_char(str, info, (char) (*ucp_vp));
}
- h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
- }
- else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
- HDmemcpy(&tempulong, vp, sizeof(unsigned long));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(unsigned long))
- tempulong = 0;
- else
- tempulong = (tempulong >> packed_data_offset) & packed_data_mask;
+ else if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(type, H5T_NATIVE_UCHAR)) */
+ unsigned char tempuchar;
+ HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned char))
+ tempuchar = 0;
+ else
+ tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar);
}
- h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
- }
- else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
- HDmemcpy(&templlong, vp, sizeof(long long));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(long long))
- templlong = 0;
- else
- templlong = (templlong >> packed_data_offset) & packed_data_mask;
+ else {
+ /* if (H5Tequal(type, H5T_NATIVE_SCHAR)) */
+ signed char tempchar;
+ HDmemcpy(&tempchar, cp_vp, sizeof(char));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(char))
+ tempchar = 0;
+ else
+ tempchar = (tempchar >> packed_data_offset) & packed_data_mask;
+ }
+ #ifdef H5_VMS
+ h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar);
+ #else
+ h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar);
+ #endif
}
- h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
- }
- else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
- HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
- if (packed_bits_num) {
- if (packed_data_offset >= 8 * sizeof(unsigned long long))
- tempullong = 0;
- else
- tempullong = (tempullong >> packed_data_offset) & packed_data_mask;
+ } /* end if (sizeof(char) == nsize) */
+ else if (sizeof(int) == nsize) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(type, H5T_NATIVE_UINT)) */
+ HDmemcpy(&tempuint, vp, sizeof(unsigned int));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned int))
+ tempuint = 0;
+ else
+ tempuint = (tempuint >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
}
- h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
- }
- else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) {
- if (sizeof(hssize_t) == sizeof(int)) {
+ else {
+ /* if (H5Tequal(type, H5T_NATIVE_INT)) */
HDmemcpy(&tempint, vp, sizeof(int));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(int))
+ tempint = 0;
+ else
+ tempint = (tempint >> packed_data_offset) & packed_data_mask;
+ }
h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
}
- else if (sizeof(hssize_t) == sizeof(long)) {
- HDmemcpy(&templong, vp, sizeof(long));
- h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
+ } /* end if (sizeof(int) == nsize) */
+ else if (sizeof(short) == nsize) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(type, H5T_NATIVE_USHORT)) */
+ unsigned short tempushort;
+
+ HDmemcpy(&tempushort, vp, sizeof(unsigned short));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned short))
+ tempushort = 0;
+ else
+ tempushort = (tempushort >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
}
else {
- HDmemcpy(&templlong, vp, sizeof(long long));
- h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
- }
- }
- else if (H5Tequal(type, H5T_NATIVE_HSIZE)) {
- if (sizeof(hsize_t) == sizeof(int)) {
- HDmemcpy(&tempuint, vp, sizeof(unsigned int));
- h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
+ /* if (H5Tequal(type, H5T_NATIVE_SHORT)) */
+ short tempshort;
+
+ HDmemcpy(&tempshort, vp, sizeof(short));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(short))
+ tempshort = 0;
+ else
+ tempshort = (tempshort >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
}
- else if (sizeof(hsize_t) == sizeof(long)) {
- HDmemcpy(&tempulong, vp, sizeof(long));
+ } /* end if (sizeof(short) == nsize) */
+ else if (sizeof(long) == nsize) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(type, H5T_NATIVE_ULONG)) */
+ HDmemcpy(&tempulong, vp, sizeof(unsigned long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned long))
+ tempulong = 0;
+ else
+ tempulong = (tempulong >> packed_data_offset) & packed_data_mask;
+ }
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
}
else {
+ /* if (H5Tequal(type, H5T_NATIVE_LONG)) */
+ HDmemcpy(&templong, vp, sizeof(long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(long))
+ templong = 0;
+ else
+ templong = (templong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
+ }
+ } /* end if (sizeof(long) == nsize) */
+ else if (sizeof(long long) == nsize) {
+ if(H5T_SGN_NONE == nsign) {
+ /* if (H5Tequal(type, H5T_NATIVE_ULLONG)) */
HDmemcpy(&tempullong, vp, sizeof(unsigned long long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(unsigned long long))
+ tempullong = 0;
+ else
+ tempullong = (tempullong >> packed_data_offset) & packed_data_mask;
+ }
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
}
- }
+ else {
+ /* if (H5Tequal(type, H5T_NATIVE_LLONG)) */
+ HDmemcpy(&templlong, vp, sizeof(long long));
+ if (packed_bits_num) {
+ if (packed_data_offset >= 8 * sizeof(long long))
+ templlong = 0;
+ else
+ templlong = (templlong >> packed_data_offset) & packed_data_mask;
+ }
+ h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
+ }
+ } /* end if (sizeof(long long) == nsize) */
break;
case H5T_COMPOUND:
if(ctx->cmpd_listv) { /* there is <list_of_fields> */
@@ -1089,75 +1087,71 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
}
else {
size_t i;
- n = H5Tget_size(type);
- if (1 == n) {
+ if (1 == nsize) {
h5tools_str_append(str, "0x%02x", ucp_vp[0]);
}
else {
- for (i = 0; i < n; i++)
+ for (i = 0; i < nsize; i++)
h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
}
}
}
break;
case H5T_REFERENCE:
- if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
- if (h5tools_str_is_zero(vp, H5Tget_size(type))) {
- h5tools_str_append(str, "NULL");
- }
- else {
- h5tools_str_sprint_region(str, info, container, vp);
- }
+ if (h5tools_str_is_zero(vp, nsize)) {
+ h5tools_str_append(str, "NULL");
}
- else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
- /*
- * Object references -- show the type and OID of the referenced
- * object.
- */
- if (h5tools_str_is_zero(vp, H5Tget_size(type))) {
- h5tools_str_append(str, "NULL");
+ else {
+ if (nsize == H5R_DSET_REG_REF_BUF_SIZE) {
+ /* if (H5Tequal(type, H5T_STD_REF_DSETREG)) */
+ h5tools_str_sprint_region(str, info, container, vp);
}
- else {
- H5O_info_t oi;
- const char *path;
-
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp);
- H5Oget_info(obj, &oi);
-
- /* Print object type and close object */
- switch (oi.type) {
- case H5O_TYPE_GROUP:
- h5tools_str_append(str, H5_TOOLS_GROUP);
- break;
-
- case H5O_TYPE_DATASET:
- h5tools_str_append(str, H5_TOOLS_DATASET);
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- h5tools_str_append(str, H5_TOOLS_DATATYPE);
- break;
-
- default:
- h5tools_str_append(str, "%u-", (unsigned) oi.type);
- break;
- } /* end switch */
- H5Oclose(obj);
-
- /* Print OID */
- if (info->obj_hidefileno)
- h5tools_str_append(str, info->obj_format, oi.addr);
- else
- h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
-
- /* Print name */
- path = lookup_ref_path(*(haddr_t *) vp);
- if (path) {
- h5tools_str_append(str, " ");
- h5tools_str_append(str, path);
- h5tools_str_append(str, " ");
- } /* end if */
- } /* end else */
+ else if (nsize == H5R_OBJ_REF_BUF_SIZE) {
+ /* if (H5Tequal(type, H5T_STD_REF_OBJ)) */
+ /*
+ * Object references -- show the type and OID of the referenced
+ * object.
+ */
+ H5O_info_t oi;
+ const char *path;
+
+ obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp);
+ H5Oget_info(obj, &oi);
+
+ /* Print object type and close object */
+ switch (oi.type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, H5_TOOLS_DATATYPE);
+ break;
+
+ default:
+ h5tools_str_append(str, "%u-", (unsigned) oi.type);
+ break;
+ } /* end switch */
+ H5Oclose(obj);
+
+ /* Print OID */
+ if (info->obj_hidefileno)
+ h5tools_str_append(str, info->obj_format, oi.addr);
+ else
+ h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
+
+ /* Print name */
+ path = lookup_ref_path(*(haddr_t *) vp);
+ if (path) {
+ h5tools_str_append(str, " ");
+ h5tools_str_append(str, path);
+ h5tools_str_append(str, " ");
+ } /* end if */
+ } /* end else if (H5Tequal(type, H5T_STD_REF_OBJ)) */
}
break;
case H5T_ARRAY:
@@ -1271,12 +1265,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
{
/* All other types get printed as hexadecimal */
size_t i;
- n = H5Tget_size(type);
- if (1 == n) {
+ if (1 == nsize) {
h5tools_str_append(str, "0x%02x", ucp_vp[0]);
}
else {
- for (i = 0; i < n; i++)
+ for (i = 0; i < nsize; i++)
h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]);
}
}
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 79322bc..d7c5adb 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -152,8 +152,9 @@ error_msg(const char *fmt, ...)
va_list ap;
HDva_start(ap, fmt);
- HDfflush(rawdatastream);
- HDfflush(rawoutstream);
+ FLUSHSTREAM(rawattrstream);
+ FLUSHSTREAM(rawdatastream);
+ FLUSHSTREAM(rawoutstream);
HDfprintf(rawerrorstream, "%s error: ", h5tools_getprogname());
HDvfprintf(rawerrorstream, fmt, ap);
@@ -182,8 +183,9 @@ warn_msg(const char *fmt, ...)
va_list ap;
HDva_start(ap, fmt);
- HDfflush(rawdatastream);
- HDfflush(rawoutstream);
+ FLUSHSTREAM(rawattrstream);
+ FLUSHSTREAM(rawdatastream);
+ FLUSHSTREAM(rawoutstream);
HDfprintf(rawerrorstream, "%s warning: ", h5tools_getprogname());
HDvfprintf(rawerrorstream, fmt, ap);
HDva_end(ap);
@@ -275,6 +277,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti
opt_opt = '?';
}
+ else
+ opt_arg = NULL;
}
else {
if (arg[len] == '=') {
@@ -388,7 +392,7 @@ indentation(int x)
{
if (x < h5tools_nCols) {
while (x-- > 0)
- HDfprintf(rawoutstream, " ");
+ PRINTVALSTREAM(rawoutstream, " ");
}
else {
HDfprintf(rawerrorstream, "error: the indentation exceeds the number of cols.\n");
@@ -414,7 +418,7 @@ indentation(int x)
void
print_version(const char *progname)
{
- HDfprintf(rawoutstream, "%s: Version %u.%u.%u%s%s\n",
+ PRINTSTREAM(rawoutstream, "%s: Version %u.%u.%u%s%s\n",
progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE,
((char *)H5_VERS_SUBRELEASE)[0] ? "-" : "", H5_VERS_SUBRELEASE);
}
@@ -494,9 +498,9 @@ dump_table(char* tablename, table_t *table)
{
unsigned u;
- HDfprintf(rawoutstream,"%s: # of entries = %d\n", tablename,table->nobjs);
+ PRINTSTREAM(rawoutstream,"%s: # of entries = %d\n", tablename,table->nobjs);
for (u = 0; u < table->nobjs; u++)
- HDfprintf(rawoutstream,"%a %s %d %d\n", table->objs[u].objno,
+ PRINTSTREAM(rawoutstream,"%a %s %d %d\n", table->objs[u].objno,
table->objs[u].objname,
table->objs[u].displayed, table->objs[u].recorded);
}