summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/tarray.c55
-rw-r--r--tools/h5dump/h5dump.c66
-rw-r--r--tools/h5toh4/h5toh4.c46
-rw-r--r--tools/lib/h5tools.c138
-rw-r--r--tools/lib/h5tools_str.c162
5 files changed, 340 insertions, 127 deletions
diff --git a/test/tarray.c b/test/tarray.c
index bb59d72..4175d9f 100644
--- a/test/tarray.c
+++ b/test/tarray.c
@@ -21,6 +21,7 @@
*************************************************************/
#include "testhdf5.h"
+
#include "hdf5.h"
#define FILENAME "tarray1.h5"
@@ -709,11 +710,13 @@ test_array_compound_array(void)
hsize_t sdims1[] = {SPACE1_DIM1};
hsize_t tdims1[] = {ARRAY1_DIM1};
#ifdef WANT_H5_V1_2_COMPAT
+ size_t msize;
size_t otdims1[] = {ARRAY1_DIM1};
#endif /* WANT_H5_V1_2_COMPAT */
int ndims; /* Array rank for reading */
hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
#ifdef WANT_H5_V1_2_COMPAT
+ size_t rdims2[H5S_MAX_RANK]; /* Array dimensions for reading */
size_t ordims1[H5S_MAX_RANK]; /* Array dimensions for reading */
#endif /* WANT_H5_V1_2_COMPAT */
int nmemb; /* Number of compound members */
@@ -769,7 +772,7 @@ test_array_compound_array(void)
/* Compatibility code to verify that the old API functions are still working */
#ifdef WANT_H5_V1_2_COMPAT
- /* Insert float array field */
+ /* Insert double array field */
ret = H5Tinsert_array (tid2, "d", HOFFSET(s1_t,d), ARRAY1_RANK,otdims1,NULL,H5T_NATIVE_DOUBLE);
CHECK(ret, FAIL, "H5Tinsert_array");
#endif /* WANT_H5_V1_2_COMPAT */
@@ -887,6 +890,29 @@ test_array_compound_array(void)
mtid=H5Tget_member_type(tid2,1);
CHECK(mtid, FAIL, "H5Tget_member_type");
+#ifdef WANT_H5_V1_2_COMPAT
+ /* H5Tget_member_type() returns the base type in v1.2 */
+ /* Get the 2nd field's class */
+ mclass=H5Tget_class(mtid);
+ VERIFY(mclass, H5T_FLOAT, "H5Tget_class");
+
+ /* Get the 2nd field's size */
+ msize=H5Tget_size(mtid);
+ VERIFY(msize, sizeof(float), "H5Tget_size");
+
+ /* Get the array dimensions */
+ ndims=H5Tget_member_dims(tid2,1,rdims2,NULL);
+ VERIFY(ndims, ARRAY1_RANK, "H5Tget_member_dims");
+ VERIFY(rdims2[0], ARRAY1_DIM1, "H5Tget_member_dims");
+
+ /* Check the array dimensions */
+ for(i=0; i<ndims; i++)
+ if(rdims2[i]!=tdims1[i]) {
+ num_errs++;
+ printf("Nested array dimension information doesn't match!, rdims2[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims2[i],(int)i,(int)tdims1[i]);
+ continue;
+ } /* end if */
+#else /* WANT_H5_V1_2_COMPAT */
/* Get the 2nd field's class */
mclass=H5Tget_class(mtid);
VERIFY(mclass, H5T_ARRAY, "H5Tget_class");
@@ -919,6 +945,7 @@ test_array_compound_array(void)
/* Close the array's base type datatype */
ret=H5Tclose(tid3);
CHECK(mtid, FAIL, "H5Tclose");
+#endif /* WANT_H5_V1_2_COMPAT */
/* Close the member datatype */
ret=H5Tclose(mtid);
@@ -939,6 +966,19 @@ test_array_compound_array(void)
off=H5Tget_member_offset(tid2,2);
VERIFY(off, HOFFSET(s1_t,d), "H5Tget_member_offset");
+ /* Check the 2nd field's datatype */
+ mtid=H5Tget_member_type(tid2,2);
+ CHECK(mtid, FAIL, "H5Tget_member_type");
+
+ /* H5Tget_member_type() returns the base type in v1.2 */
+ /* Get the 3rd field's class */
+ mclass=H5Tget_class(mtid);
+ VERIFY(mclass, H5T_FLOAT, "H5Tget_class");
+
+ /* Get the 3rd field's size */
+ msize=H5Tget_size(mtid);
+ VERIFY(msize, sizeof(double), "H5Tget_size");
+
/* Check the array rank */
ndims=H5Tget_member_dims(tid2,2,ordims1,NULL);
VERIFY(ndims,ARRAY1_RANK,"H5Tget_member_dims");
@@ -950,6 +990,11 @@ test_array_compound_array(void)
printf("Nested array dimension information doesn't match!, ordims1[%d]=%d, otdims1[%d]=%d\n",(int)i,(int)ordims1[i],(int)i,(int)otdims1[i]);
continue;
} /* end if */
+
+ /* Close the member datatype */
+ ret=H5Tclose(mtid);
+ CHECK(mtid, FAIL, "H5Tclose");
+
#endif /* WANT_H5_V1_2_COMPAT */
/* Close Compound Datatype */
@@ -1830,16 +1875,20 @@ test_compat(void)
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
hid_t tid1; /* Array Datatype ID */
+#ifndef WANT_H5_V1_2_COMPAT
hid_t tid2; /* Datatype ID */
hsize_t tdims1[] = {ARRAY1_DIM1};
int ndims; /* Array rank for reading */
hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */
+#endif /* !WANT_H5_V1_2_COMPAT */
H5T_class_t mclass; /* Datatype class for VL */
int nmemb; /* Number of compound members */
char *mname; /* Name of compound field */
size_t off; /* Offset of compound field */
hid_t mtid; /* Datatype ID for field */
+#ifndef WANT_H5_V1_2_COMPAT
intn i; /* Index variables */
+#endif /* !WANT_H5_V1_2_COMPAT */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2013,6 +2062,7 @@ test_compat(void)
off=H5Tget_member_offset(tid1,1);
VERIFY(off, 4, "H5Tget_member_offset");
+#ifndef WANT_H5_V1_2_COMPAT
/* Check the 2nd field's datatype */
mtid=H5Tget_member_type(tid1,1);
CHECK(mtid, FAIL, "H5Tget_member_type");
@@ -2049,6 +2099,7 @@ test_compat(void)
CHECK(ret, FAIL, "H5Tclose");
ret=H5Tclose(mtid);
CHECK(ret, FAIL, "H5Tclose");
+#endif /* !WANT_H5_V1_2_COMPAT */
/* Check the 3rd field's name */
mname=H5Tget_member_name(tid1,2);
@@ -2063,6 +2114,7 @@ test_compat(void)
off=H5Tget_member_offset(tid1,2);
VERIFY(off, 20, "H5Tget_member_offset");
+#ifndef WANT_H5_V1_2_COMPAT
/* Check the 3rd field's datatype */
mtid=H5Tget_member_type(tid1,2);
CHECK(mtid, FAIL, "H5Tget_member_type");
@@ -2099,6 +2151,7 @@ test_compat(void)
CHECK(ret, FAIL, "H5Tclose");
ret=H5Tclose(mtid);
CHECK(ret, FAIL, "H5Tclose");
+#endif /* !WANT_H5_V1_2_COMPAT */
/* Check the 4th field's name */
mname=H5Tget_member_name(tid1,3);
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 85c554b..977d67c 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -861,6 +861,28 @@ print_datatype(hid_t type)
for (i = 0; i < nmembers; i++) {
fname = H5Tget_member_name(type, i);
mtype = H5Tget_member_type(type, i);
+#ifdef WANT_H5_V1_2_COMPAT
+ /* v1.2 returns the base type of an array field, work around this */
+ {
+ hid_t new_mtype; /* 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,i,dims,NULL);
+
+ /* Patch up array information */
+ if(arrndims>0) {
+ for(k=0; k<arrndims; k++)
+ arrdims[k]=dims[k];
+ new_mtype=H5Tarray_create(mtype,arrndims,arrdims,NULL);
+ H5Tclose(mtype);
+ mtype=new_mtype;
+ } /* end if */
+ }
+#endif /* WANT_H5_V1_2_COMPAT */
indentation(indent + COL);
@@ -3622,6 +3644,28 @@ xml_print_datatype(hid_t type)
fname = H5Tget_member_name(type, i);
mtype = H5Tget_member_type(type, i);
+#ifdef WANT_H5_V1_2_COMPAT
+ /* v1.2 returns the base type of an array field, work around this */
+ {
+ hid_t new_mtype; /* 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,i,dims,NULL);
+
+ /* Patch up array information */
+ if(arrndims>0) {
+ for(k=0; k<arrndims; k++)
+ arrdims[k]=dims[k];
+ new_mtype=H5Tarray_create(mtype,arrndims,arrdims,NULL);
+ H5Tclose(mtype);
+ mtype=new_mtype;
+ } /* end if */
+ }
+#endif /* WANT_H5_V1_2_COMPAT */
indentation(indent);
t_fname = xml_escape_the_name(fname);
printf("<Field FieldName=\"%s\">\n", t_fname);
@@ -4179,6 +4223,28 @@ xml_dump_named_datatype(hid_t type, const char *name)
fname = H5Tget_member_name(type, x);
mtype = H5Tget_member_type(type, x);
+#ifdef WANT_H5_V1_2_COMPAT
+ /* v1.2 returns the base type of an array field, work around this */
+ {
+ hid_t new_mtype; /* 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,x,dims,NULL);
+
+ /* Patch up array information */
+ if(arrndims>0) {
+ for(k=0; k<arrndims; k++)
+ arrdims[k]=dims[k];
+ new_mtype=H5Tarray_create(mtype,arrndims,arrdims,NULL);
+ H5Tclose(mtype);
+ mtype=new_mtype;
+ } /* end if */
+ }
+#endif /* WANT_H5_V1_2_COMPAT */
indentation(indent);
t_fname = xml_escape_the_name(fname);
printf("<Field FieldName=\"%s\">\n", t_fname);
diff --git a/tools/h5toh4/h5toh4.c b/tools/h5toh4/h5toh4.c
index f5b2e93..09138b0 100644
--- a/tools/h5toh4/h5toh4.c
+++ b/tools/h5toh4/h5toh4.c
@@ -315,7 +315,7 @@ int h5toh4(char *h5_filename, char *h4_filename)
hid_t (*func)(void*);
- find_objs_t *info = HDmalloc(sizeof(find_objs_t));
+ find_objs_t *info = malloc(sizeof(find_objs_t));
@@ -788,6 +788,28 @@ int32 order_array[512];
DEBUG_PRINT("Error detected in %s() [%s line %d]\n", "convert_dataset", __FILE__, __LINE__);
break;
}
+#ifdef H5_WANT_H5_V1_2_COMPAT
+ /* v1.2 returns the base type of an array field, work around this */
+ {
+ hid_t new_fieldtype; /* 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,idx,dims,NULL);
+
+ /* Patch up array information */
+ if(arrndims>0) {
+ for(k=0; k<arrndims; k++)
+ arrdims[k]=dims[k];
+ new_fieldtype=H5Tarray_create(fieldtype,arrndims,arrdims,NULL);
+ H5Tclose(fieldtype);
+ fieldtype=new_fieldtype;
+ } /* end if */
+ }
+#endif /* WANT_H5_V1_2_COMPAT */
/* Special case for array fields */
if(H5Tget_class(fieldtype)==H5T_ARRAY) {
hid_t arr_base_type;
@@ -910,6 +932,28 @@ int32 order_array[512];
DEBUG_PRINT("Error detected in %s() [%s line %d]\n", "convert_dataset", __FILE__, __LINE__);
break;
}
+#ifdef H5_WANT_H5_V1_2_COMPAT
+ /* v1.2 returns the base type of an array field, work around this */
+ {
+ hid_t new_arr_type; /* 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,idx,dims,NULL);
+
+ /* Patch up array information */
+ if(arrndims>0) {
+ for(k=0; k<arrndims; k++)
+ arrdims[k]=dims[k];
+ new_arr_type=H5Tarray_create(arr_type,arrndims,arrdims,NULL);
+ H5Tclose(arr_type);
+ arr_type=new_arr_type;
+ } /* end if */
+ }
+#endif /* WANT_H5_V1_2_COMPAT */
/* Get the number of dimensions */
if ((ndimf = H5Tget_array_ndims(arr_type)) < 0 || ndimf > H5S_MAX_RANK ) {
fprintf(stderr, "Error: rank of members of compound type should not be %d\n",ndimf);
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;
}