summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5tools.c138
-rw-r--r--tools/lib/h5tools_str.c162
2 files changed, 175 insertions, 125 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index fc2d034..ca3c8a6 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -18,6 +18,9 @@
#include "hdf5.h"
#include "H5private.h"
+
+
+
/*
* The output functions need a temporary buffer to hold a piece of the
* dataset while it's being printed. This constant sets the limit on the
@@ -90,8 +93,8 @@ h5tools_close(void)
{
if (h5tools_init_g) {
if (rawdatastream && rawdatastream != stdout) {
- if (HDfclose(rawdatastream))
- HDperror("closing rawdatastream");
+ if (fclose(rawdatastream))
+ perror("closing rawdatastream");
else
rawdatastream = NULL;
}
@@ -204,7 +207,7 @@ h5tools_fopen(const char *fname, char *drivername, size_t drivername_size)
/* Save the driver name */
if (drivername && drivername_size) {
if (fid >= 0) {
- HDstrncpy(drivername, driver[drivernum].name, drivername_size);
+ strncpy(drivername, driver[drivernum].name, drivername_size);
drivername[drivername_size - 1] = '\0';
} else {
/*no file opened*/
@@ -271,13 +274,13 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info,
if (!ctx->need_prefix)
return;
- HDmemset(&prefix, 0, sizeof(h5tools_str_t));
+ memset(&prefix, 0, sizeof(h5tools_str_t));
/* Terminate previous line, if any */
if (ctx->cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
- HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ fputs(OPT(info->line_suf, ""), stream);
+ putc('\n', stream);
+ fputs(OPT(info->line_sep, ""), stream);
}
/* Calculate new prefix */
@@ -298,16 +301,16 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info,
}
if (elmtno == 0 && secnum == 0 && info->line_1st)
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream);
+ fputs(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);
+ fputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream);
else
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
+ fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream);
templength = h5tools_str_len(&prefix);
for (i = 0; i < indentlevel; i++){
- HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
+ fputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream);
templength += h5tools_str_len(&prefix);
}
@@ -366,7 +369,7 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*to the ctx->size_last_dim. */
/* Setup */
- HDmemset(&buffer, 0, sizeof(h5tools_str_t));
+ memset(&buffer, 0, sizeof(h5tools_str_t));
size = H5Tget_size(type);
if (info->line_ncols > 0)
@@ -390,8 +393,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*/
if (info->line_multi_new == 1 &&
(ctx->cur_column + h5tools_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols) {
+ strlen(OPT(info->elmt_suf2, " ")) +
+ strlen(OPT(info->line_suf, ""))) > ncols) {
if (ctx->prev_multiline) {
/*
* ... and the previous element also occupied more than one
@@ -399,8 +402,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*/
ctx->need_prefix = TRUE;
} else if ((ctx->prev_prefix_len + h5tools_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
+ strlen(OPT(info->elmt_suf2, " ")) +
+ strlen(OPT(info->line_suf, ""))) <= ncols) {
/*
* ...but *could* fit on one line otherwise, then we
* should end the current line and start this element on its
@@ -432,8 +435,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*/
if (info->line_multi_new == 1 && ctx->prev_multiline &&
(ctx->cur_column + h5tools_ncols(s) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols)
+ strlen(OPT(info->elmt_suf2, " ")) +
+ strlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = TRUE;
/*
@@ -463,8 +466,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
*/
if ((!info->skip_first || i) &&
(ctx->cur_column + strlen(section) +
- HDstrlen(OPT(info->elmt_suf2, " ")) +
- HDstrlen(OPT(info->line_suf, ""))) > ncols)
+ strlen(OPT(info->elmt_suf2, " ")) +
+ strlen(OPT(info->line_suf, ""))) > ncols)
ctx->need_prefix = 1;
/*
@@ -477,13 +480,13 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container,
h5tools_simple_prefix(stream, info, ctx, i, secnum);
} else if ((i || ctx->continuation) && secnum == 0) {
- HDfputs(OPT(info->elmt_suf2, " "), stream);
- ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
+ fputs(OPT(info->elmt_suf2, " "), stream);
+ ctx->cur_column += strlen(OPT(info->elmt_suf2, " "));
}
/* Print the section */
- HDfputs(section, stream);
- ctx->cur_column += HDstrlen(section);
+ fputs(section, stream);
+ ctx->cur_column += strlen(section);
}
ctx->prev_multiline = multiline;
@@ -513,7 +516,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
{
herr_t ret; /*the value to return */
hid_t f_space; /*file data space */
- hsize_t i; /*counters */
+ hsize_t elmtno, i; /*counters */
hssize_t zero = 0; /*vector of zeros */
unsigned int flags; /*buffer extent flags */
hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/
@@ -542,7 +545,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
* great and the dimensionality of the items selected for printing must
* match the dimensionality of the dataset.
*/
- HDmemset(&ctx, 0, sizeof(ctx));
+ memset(&ctx, 0, sizeof(ctx));
ctx.indent_level = indentlevel;
ctx.need_prefix = 1;
ctx.ndims = H5Sget_simple_extent_ndims(f_space);
@@ -564,8 +567,11 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
for (; count > 0; sset->start[ctx.ndims - 1] += sset->stride[ctx.ndims - 1],
count--) {
/* calculate the potential number of elements we're going to print */
- H5Sselect_hyperslab(f_space, H5S_SELECT_SET, sset->start, sset->stride,
- sset->count, sset->block);
+ H5Sselect_hyperslab(f_space, H5S_SELECT_SET,
+ (hssize_t*)sset->start,
+ (hsize_t*)sset->stride,
+ (hsize_t*)sset->count,
+ (hsize_t*)sset->block);
sm_nelmts = H5Sget_select_npoints(f_space);
/*
@@ -604,7 +610,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
}
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
- sm_buf = HDmalloc((size_t)sm_nelmts * p_type_nbytes);
+ sm_buf = malloc((size_t)sm_nelmts * p_type_nbytes);
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, &zero, NULL, &sm_nelmts, NULL);
@@ -613,7 +619,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
H5Sclose(f_space);
H5Sclose(sm_space);
- HDfree(sm_buf);
+ free(sm_buf);
return FAIL;
}
@@ -629,15 +635,15 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset,
h5tools_dump_simple_data(stream, info, dset, &ctx, flags, sm_nelmts,
p_type, sm_buf);
- HDfree(sm_buf);
+ free(sm_buf);
ctx.continuation++;
}
/* Terminate the output */
if (ctx.cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
- HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ fputs(OPT(info->line_suf, ""), stream);
+ putc('\n', stream);
+ fputs(OPT(info->line_sep, ""), stream);
}
ret = SUCCEED;
@@ -707,7 +713,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
* great and the dimensionality of the items selected for printing must
* match the dimensionality of the dataset.
*/
- HDmemset(&ctx, 0, sizeof(ctx));
+ memset(&ctx, 0, sizeof(ctx));
ctx.indent_level = indentlevel;
ctx.need_prefix = 1;
ctx.ndims = H5Sget_simple_extent_ndims(f_space);
@@ -757,13 +763,13 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
}
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
- sm_buf = HDmalloc((size_t)sm_nbytes);
+ sm_buf = malloc((size_t)sm_nbytes);
sm_nelmts = sm_nbytes / p_type_nbytes;
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
/* The stripmine loop */
- HDmemset(hs_offset, 0, sizeof hs_offset);
- HDmemset(zero, 0, sizeof zero);
+ memset(hs_offset, 0, sizeof hs_offset);
+ memset(zero, 0, sizeof zero);
for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) {
/* Calculate the hyperslab size */
@@ -788,7 +794,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) {
H5Sclose(f_space);
H5Sclose(sm_space);
- HDfree(sm_buf);
+ free(sm_buf);
return FAIL;
}
@@ -818,14 +824,14 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset,
/* Terminate the output */
if (ctx.cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
- HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ fputs(OPT(info->line_suf, ""), stream);
+ putc('\n', stream);
+ fputs(OPT(info->line_sep, ""), stream);
}
H5Sclose(sm_space);
H5Sclose(f_space);
- HDfree(sm_buf);
+ free(sm_buf);
return SUCCEED;
}
@@ -859,7 +865,7 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id,
* great and the dimensionality of the items selected for printing must
* match the dimensionality of the dataset.
*/
- HDmemset(&ctx, 0, sizeof(ctx));
+ memset(&ctx, 0, sizeof(ctx));
ctx.ndims = H5Sget_simple_extent_ndims(space);
if ((size_t)ctx.ndims > NELMTS(ctx.p_min_idx))
@@ -888,9 +894,9 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id,
/* Terminate the output */
if (ctx.cur_column) {
- HDfputs(OPT(info->line_suf, ""), stream);
- HDputc('\n', stream);
- HDfputs(OPT(info->line_sep, ""), stream);
+ fputs(OPT(info->line_suf, ""), stream);
+ putc('\n', stream);
+ fputs(OPT(info->line_sep, ""), stream);
}
return SUCCEED;
@@ -989,12 +995,34 @@ h5tools_fixtype(hid_t f_type)
*/
nmembs = H5Tget_nmembers(f_type);
assert(nmembs > 0);
- memb = HDcalloc((size_t)nmembs, sizeof(hid_t));
- name = HDcalloc((size_t)nmembs, sizeof(char *));
+ memb = calloc((size_t)nmembs, sizeof(hid_t));
+ name = calloc((size_t)nmembs, sizeof(char *));
for (i = 0, size = 0; i < nmembs; i++) {
/* Get the member type and fix it */
f_memb = H5Tget_member_type(f_type, i);
+#ifdef WANT_H5_V1_2_COMPAT
+ /* v1.2 returns the base type of an array field, work around this */
+ {
+ hid_t new_f_memb; /* datatype for array, if necessary */
+ int arrndims; /* Array rank for reading */
+ size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */
+ hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */
+ int j; /* Local index variable */
+
+ /* Get the array dimensions */
+ arrndims=H5Tget_member_dims(f_type,i,dims,NULL);
+
+ /* Patch up array information */
+ if(arrndims>0) {
+ for(j=0; j<arrndims; j++)
+ arrdims[j]=dims[j];
+ new_f_memb=H5Tarray_create(f_memb,arrndims,arrdims,NULL);
+ H5Tclose(f_memb);
+ f_memb=new_f_memb;
+ } /* end if */
+ }
+#endif /* WANT_H5_V1_2_COMPAT */
memb[i] = h5tools_fixtype(f_memb);
H5Tclose(f_memb);
@@ -1087,18 +1115,18 @@ h5tools_fixtype(hid_t f_type)
done:
/* Clean up temp buffers */
if (memb && name) {
- int j;
+ register int j;
for (j = 0; j < nmembs; j++) {
if (memb[j] >= 0)
H5Tclose(memb[j]);
if (name[j])
- HDfree(name[j]);
+ free(name[j]);
}
- HDfree(memb);
- HDfree(name);
+ free(memb);
+ free(name);
}
return m_type;
@@ -1151,7 +1179,7 @@ h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type,
stream = stdout;
if (!info) {
- HDmemset(&info_dflt, 0, sizeof info_dflt);
+ memset(&info_dflt, 0, sizeof info_dflt);
info = &info_dflt;
}
@@ -1221,7 +1249,7 @@ h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, hid_t type,
stream = stdout;
if (!info) {
- HDmemset(&info_dflt, 0, sizeof(info_dflt));
+ memset(&info_dflt, 0, sizeof(info_dflt));
info = &info_dflt;
}
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 3922640..0836537 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -54,8 +54,8 @@ void
h5tools_str_close(h5tools_str_t *str)
{
if (str && str->nalloc) {
- HDfree(str->s);
- HDmemset(str, 0, sizeof(h5tools_str_t));
+ free(str->s);
+ memset(str, 0, sizeof(h5tools_str_t));
}
}
@@ -109,7 +109,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
/* Make sure we have some memory into which to print */
if (!str->s || str->nalloc <= 0) {
str->nalloc = STR_INIT_LEN;
- str->s = HDmalloc(str->nalloc);
+ str->s = malloc(str->nalloc);
assert(str->s);
str->s[0] = '\0';
str->len = 0;
@@ -127,7 +127,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
/* Try again with twice as much space */
str->nalloc *= 2;
- str->s = HDrealloc(str->s, str->nalloc);
+ str->s = realloc(str->s, str->nalloc);
assert(str->s);
}
@@ -158,7 +158,7 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/)
{
if (!str->s || str->nalloc <= 0) {
str->nalloc = STR_INIT_LEN;
- str->s = HDmalloc(str->nalloc);
+ str->s = malloc(str->nalloc);
assert(str->s);
}
@@ -220,20 +220,20 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
char _temp[1024], *temp = _temp;
/* If the format string is simply "%s" then don't bother doing anything */
- if (!HDstrcmp(fmt, "%s"))
+ if (!strcmp(fmt, "%s"))
return str->s;
/*
* Save the input value if there is a `%' anywhere in FMT. Otherwise
* don't bother because we don't need a temporary copy.
*/
- if (HDstrchr(fmt, '%')) {
+ if (strchr(fmt, '%')) {
if (str->len - start + 1 > sizeof(_temp)) {
- temp = HDmalloc(str->len-start + 1);
+ temp = malloc(str->len-start + 1);
assert(temp);
}
- HDstrcpy(temp, str->s + start);
+ strcpy(temp, str->s + start);
}
/* Reset the output string and append a formatted version */
@@ -242,7 +242,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
/* Free the temp buffer if we allocated one */
if (temp != _temp)
- HDfree(temp);
+ free(temp);
return str->s;
}
@@ -347,7 +347,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info)
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- ptdata = HDmalloc((size_t)alloc_size);
+ ptdata = malloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata);
@@ -370,7 +370,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info)
h5tools_str_append(str, ")");
}
- HDfree(ptdata);
+ free(ptdata);
}
/* Print point information */
@@ -379,7 +379,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info)
alloc_size = npoints * ndims * sizeof(ptdata[0]);
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
- ptdata = HDmalloc((size_t)alloc_size);
+ ptdata = malloc((size_t)alloc_size);
H5_CHECK_OVERFLOW(npoints,hssize_t,hsize_t);
H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata);
@@ -397,7 +397,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info)
h5tools_str_append(str, ")");
}
- HDfree(ptdata);
+ free(ptdata);
}
h5tools_str_append(str, "}");
@@ -450,7 +450,7 @@ h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch)
h5tools_str_append(str, "\\t");
break;
default:
- if (HDisprint(ch))
+ if (isprint(ch))
h5tools_str_append(str, "%c", (char)ch);
else
h5tools_str_append(str, "\\%03o", ch);
@@ -533,14 +533,14 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
for (i = 0; i < n; i++)
h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]);
} else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
- HDmemcpy(&tempfloat, vp, sizeof(float));
+ memcpy(&tempfloat, vp, sizeof(float));
h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat);
} else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
- HDmemcpy(&tempdouble, vp, sizeof(double));
+ memcpy(&tempdouble, vp, sizeof(double));
h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble);
} else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) ||
H5Tequal(type, H5T_NATIVE_UCHAR))) {
- h5tools_print_char(str, info, (unsigned char)*ucp_vp);
+ h5tools_print_char(str, info, *ucp_vp);
} else if (H5T_STRING == H5Tget_class(type)) {
unsigned int i;
@@ -578,7 +578,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
}
/* Print the character */
- h5tools_print_char(str, info, (unsigned char)ucp_vp[i]);
+ h5tools_print_char(str, info, ucp_vp[i]);
/* Print the repeat count */
if (info->str_repeat && j > info->str_repeat) {
@@ -600,53 +600,53 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
/*empty string*/
h5tools_str_append(str, "\"\"");
} else if (H5Tequal(type, H5T_NATIVE_INT)) {
- HDmemcpy(&tempint, vp, sizeof(int));
+ memcpy(&tempint, vp, sizeof(int));
h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
} else if (H5Tequal(type, H5T_NATIVE_UINT)) {
- HDmemcpy(&tempuint, vp, sizeof(unsigned int));
+ memcpy(&tempuint, vp, sizeof(unsigned int));
h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
} else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp);
} else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp);
} else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
- HDmemcpy(&tempshort, vp, sizeof(short));
+ memcpy(&tempshort, vp, sizeof(short));
h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
} else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
- HDmemcpy(&tempushort, vp, sizeof(unsigned short));
+ memcpy(&tempushort, vp, sizeof(unsigned short));
h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
} else if (H5Tequal(type, H5T_NATIVE_LONG)) {
- HDmemcpy(&templong, vp, sizeof(long));
+ memcpy(&templong, vp, sizeof(long));
h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
} else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
- HDmemcpy(&tempulong, vp, sizeof(unsigned long));
+ memcpy(&tempulong, vp, sizeof(unsigned long));
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
} else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
- HDmemcpy(&templlong, vp, sizeof(long_long));
+ memcpy(&templlong, vp, sizeof(long_long));
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));
+ memcpy(&tempullong, vp, sizeof(unsigned long_long));
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
} else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) {
if (sizeof(hssize_t) == sizeof(int)) {
- HDmemcpy(&tempint, vp, sizeof(int));
+ memcpy(&tempint, vp, sizeof(int));
h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
} else if (sizeof(hssize_t) == sizeof(long)) {
- HDmemcpy(&templong, vp, sizeof(long));
+ memcpy(&templong, vp, sizeof(long));
h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
} else {
- HDmemcpy(&templlong, vp, sizeof(long_long));
+ memcpy(&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));
+ memcpy(&tempuint, vp, sizeof(unsigned int));
h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
} else if (sizeof(hsize_t) == sizeof(long)) {
- HDmemcpy(&tempulong, vp, sizeof(long));
+ memcpy(&tempulong, vp, sizeof(long));
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
} else {
- HDmemcpy(&tempullong, vp, sizeof(unsigned long_long));
+ memcpy(&tempullong, vp, sizeof(unsigned long_long));
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
}
} else if (H5Tget_class(type) == H5T_COMPOUND) {
@@ -677,11 +677,33 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container,
/* The name */
name = H5Tget_member_name(type, j);
h5tools_str_append(str, OPT(info->cmpd_name, ""), name);
- HDfree(name);
+ free(name);
/* The value */
offset = H5Tget_member_offset(type, j);
memb = H5Tget_member_type(type, j);
+#ifdef WANT_H5_V1_2_COMPAT
+ /* v1.2 returns the base type of an array field, work around this */
+ {
+ hid_t new_memb; /* datatype for array, if necessary */
+ int arrndims; /* Array rank for reading */
+ size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */
+ hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */
+ int k; /* Local index variable */
+
+ /* Get the array dimensions */
+ arrndims=H5Tget_member_dims(type,j,dims,NULL);
+
+ /* Patch up array information */
+ if(arrndims>0) {
+ for(k=0; k<arrndims; k++)
+ arrdims[k]=dims[k];
+ new_memb=H5Tarray_create(memb,arrndims,arrdims,NULL);
+ H5Tclose(memb);
+ memb=new_memb;
+ } /* end if */
+ }
+#endif /* WANT_H5_V1_2_COMPAT */
ctx->indent_level++;
h5tools_str_sprint(str, info, container, memb, cp_vp + offset , ctx);
@@ -920,50 +942,50 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces)
for (i = 0; i < n; i++) {
switch (s[i]) {
- case '"':
- escape = "\\\"";
- break;
- case '\\':
- escape = "\\\\";
- break;
- case '\b':
- escape = "\\b";
- break;
- case '\f':
- escape = "\\f";
- break;
- case '\n':
- escape = "\\n";
- break;
- case '\r':
- escape = "\\r";
- break;
- case '\t':
- escape = "\\t";
- break;
- case ' ':
- escape = escape_spaces ? "\\ " : NULL;
- break;
- default:
- if (!isprint((int)*s)) {
- sprintf(octal, "\\%03o", (unsigned char)s[i]);
- escape = octal;
- } else {
- escape = NULL;
- }
-
- break;
+ case '"':
+ escape = "\\\"";
+ break;
+ case '\\':
+ escape = "\\\\";
+ break;
+ case '\b':
+ escape = "\\b";
+ break;
+ case '\f':
+ escape = "\\f";
+ break;
+ case '\n':
+ escape = "\\n";
+ break;
+ case '\r':
+ escape = "\\r";
+ break;
+ case '\t':
+ escape = "\\t";
+ break;
+ case ' ':
+ escape = escape_spaces ? "\\ " : NULL;
+ break;
+ default:
+ if (!isprint((int)*s)) {
+ sprintf(octal, "\\%03o", (unsigned char)s[i]);
+ escape = octal;
+ } else {
+ escape = NULL;
+ }
+
+ break;
}
if (escape) {
- size_t esc_size = HDstrlen(escape);
+ size_t esc_size = strlen(escape);
if (n + esc_size + 1 > size)
/*would overflow*/
return NULL;
- HDmemmove(s + i + esc_size, s + i, (n - i) + 1); /*make room*/
- HDmemcpy(s + i, escape, esc_size); /*insert*/
+ memmove(s + i + esc_size, s + i, (n - i) + 1); /*make room*/
+ memcpy(s + i, escape, esc_size); /*insert*/
n += esc_size;
i += esc_size - 1;
}