Merge pull request #1115 in HDFFV/hdf5 from ~BYRN/hdf5_adb:develop to develop

* commit '27047165aaa6838c4653daa56a41d7b64b6bf3cd':
  Remove debug statements
  Split/fix utility for vl types
  fix whitespace
  HDFVIEW compound vlen needed vlen_t size
This commit is contained in:
Allen Byrne
2018-06-25 08:12:36 -05:00
5 changed files with 178 additions and 55 deletions

View File

@@ -623,6 +623,7 @@ public class HDF5Constants {
public static final long H5T_UNIX_D64LE = H5T_UNIX_D64LE(); public static final long H5T_UNIX_D64LE = H5T_UNIX_D64LE();
public static final long H5T_VARIABLE = H5T_VARIABLE(); public static final long H5T_VARIABLE = H5T_VARIABLE();
public static final int H5T_VLEN = H5T_VLEN(); public static final int H5T_VLEN = H5T_VLEN();
public static final int H5T_VL_T = H5T_VL_T();
public static final int H5Z_CB_CONT = H5Z_CB_CONT(); public static final int H5Z_CB_CONT = H5Z_CB_CONT();
public static final int H5Z_CB_ERROR = H5Z_CB_ERROR(); public static final int H5Z_CB_ERROR = H5Z_CB_ERROR();
public static final int H5Z_CB_FAIL = H5Z_CB_FAIL(); public static final int H5Z_CB_FAIL = H5Z_CB_FAIL();
@@ -1825,6 +1826,8 @@ public class HDF5Constants {
private static native final int H5T_VLEN(); private static native final int H5T_VLEN();
private static native final int H5T_VL_T();
private static native final int H5Z_CB_CONT(); private static native final int H5Z_CB_CONT();
private static native final int H5Z_CB_ERROR(); private static native final int H5Z_CB_ERROR();

View File

@@ -1231,6 +1231,8 @@ JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1VARIABLE(JNIEnv *env, jclass cls) { return (int)H5T_VARIABLE; } Java_hdf_hdf5lib_HDF5Constants_H5T_1VARIABLE(JNIEnv *env, jclass cls) { return (int)H5T_VARIABLE; }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1VLEN(JNIEnv *env, jclass cls) { return H5T_VLEN; } Java_hdf_hdf5lib_HDF5Constants_H5T_1VLEN(JNIEnv *env, jclass cls) { return H5T_VLEN; }
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5T_1VL_1T(JNIEnv *env, jclass cls) { return sizeof(hvl_t); }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; } Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; }

View File

@@ -1002,20 +1002,38 @@ Java_hdf_hdf5lib_H5_H5DreadVL
jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) jlong file_space_id, jlong xfer_plist_id, jobjectArray buf)
{ {
herr_t status = -1; herr_t status = -1;
htri_t isVlenStr=0; htri_t isStr = 0;
htri_t isVlenStr = 0;
htri_t isComplex = 0;
if (buf == NULL) { if (buf == NULL) {
h5nullArgument(env, "H5DreadVL: buf is NULL"); h5nullArgument(env, "H5DreadVL: buf is NULL");
} /* end if */ } /* end if */
else { else {
isVlenStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING);
if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) {
if (isVlenStr) unsigned i;
h5badArgument(env, "H5DreadVL: type is not variable length non-string"); int nm = H5Tget_nmembers(mem_type_id);
else for(i = 0; i <nm; i++) {
hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i);
isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) ||
H5Tdetect_class((hid_t)nested_tid, H5T_VLEN);
H5Tclose(nested_tid);
}
}
else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) {
isVlenStr = 1; /* strings created by H5Tvlen_create( H5T_C_S1) */
}
if (isStr == 0 || isComplex>0 || isVlenStr) {
status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf); (hid_t)xfer_plist_id, buf);
}
else if (isStr > 0) {
status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id,
(hid_t)mem_space_id, (hid_t)file_space_id,
(hid_t)xfer_plist_id, buf);
}
} /* end else */ } /* end else */
return (jint)status; return (jint)status;
@@ -1034,7 +1052,9 @@ H5DreadVL_asstr
size_t max_len = 0; size_t max_len = 0;
herr_t status = -1; herr_t status = -1;
/* Get size of string array */
n = ENVPTR->GetArrayLength(ENVPAR buf); n = ENVPTR->GetArrayLength(ENVPAR buf);
/* we will need to read n number of hvl_t structures */
rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t));
if (rdata == NULL) { if (rdata == NULL) {
h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buff for read"); h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buff for read");
@@ -1048,12 +1068,14 @@ H5DreadVL_asstr
h5JNIFatalError(env, "H5DreadVL_notstr: failed to read data"); h5JNIFatalError(env, "H5DreadVL_notstr: failed to read data");
} /* end if */ } /* end if */
else { else {
/* calculate the largest size of all the hvl_t structures read */
max_len = 1; max_len = 1;
for (i=0; i < n; i++) { for (i=0; i < n; i++) {
if ((rdata + i)->len > max_len) if ((rdata + i)->len > max_len)
max_len = (rdata + i)->len; max_len = (rdata + i)->len;
} }
/* create one malloc to hold largest element */
size = H5Tget_size(tid) * max_len; size = H5Tget_size(tid) * max_len;
HDmemset(&h5str, 0, sizeof(h5str_t)); HDmemset(&h5str, 0, sizeof(h5str_t));
h5str_new(&h5str, 4 * size); h5str_new(&h5str, 4 * size);
@@ -1064,9 +1086,11 @@ H5DreadVL_asstr
h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buf"); h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buf");
} /* end if */ } /* end if */
else { else {
H5T_class_t tclass = H5Tget_class(tid);
/* convert each element to char string */
for (i=0; i < n; i++) { for (i=0; i < n; i++) {
h5str.s[0] = '\0'; h5str.s[0] = '\0';
h5str_sprintf(&h5str, did, tid, rdata+i, 0); h5str_vlsprintf(&h5str, did, tid, rdata+i, 0);
jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
} /* end for */ } /* end for */
@@ -1433,7 +1457,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref
h5str_new(&h5str, 1024); h5str_new(&h5str, 1024);
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
h5str.s[0] = '\0'; h5str.s[0] = '\0';
h5str_sprintf(&h5str, did, tid, ref_data[i], 0); h5str_sprintf(&h5str, did, tid, ref_data[i], 0, 0);
jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);

View File

@@ -21,6 +21,7 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#include <jni.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@@ -152,14 +153,14 @@ h5str_append
return HDstrcat(str->s, cstr); return HDstrcat(str->s, cstr);
} /* end h5str_append */ } /* end h5str_append */
/** print value of a data point into string. /** print value of a vlen data point into string.
Return Value: Return Value:
On success, the total number of characters printed is returned. On success, the total number of characters printed is returned.
On error, a negative number is returned. On error, a negative number is returned.
*/ */
size_t size_t
h5str_sprintf h5str_vlsprintf
(h5str_t *str, hid_t container, hid_t tid, void *ptr, int expand_data) (h5str_t *str, hid_t container, hid_t tid, hvl_t *ptr, int expand_data)
{ {
unsigned char tmp_uchar = 0; unsigned char tmp_uchar = 0;
char tmp_char = 0; char tmp_char = 0;
@@ -182,9 +183,102 @@ h5str_sprintf
char *this_str; char *this_str;
size_t this_strlen; size_t this_strlen;
int n; int n;
hvl_t *vlptr; H5T_class_t tclass = H5Tget_class(tid);
char *cptr = (char*) ptr; size_t size = H5Tget_size(tid);
unsigned char *ucptr = (unsigned char*) ptr; H5T_sign_t nsign = H5Tget_sign(tid);
int bdata_print = 0;
if (!str || !ptr)
return 0;
/* Build default formats for long long types */
if (!fmt_llong[0]) {
sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH);
sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH);
} /* end if */
this_str = NULL;
this_strlen = 0;
switch (tclass) {
case H5T_COMPOUND:
{
unsigned i;
n = H5Tget_nmembers(tid);
h5str_append(str, " {");
for (i = 0; i < n; i++) {
offset = H5Tget_member_offset(tid, i);
mtid = H5Tget_member_type(tid, i);
h5str_sprintf(str, container, mtid, ((char *) (ptr->p)) + offset, ptr->len, expand_data);
if (i < n - 1)
h5str_append(str, ", ");
H5Tclose(mtid);
}
h5str_append(str, "} ");
}
break;
case H5T_ARRAY:
{
int rank = 0;
hsize_t i, dims[H5S_MAX_RANK], total_elmts;
h5str_append(str, "[ ");
mtid = H5Tget_super(tid);
size = H5Tget_size(mtid);
rank = H5Tget_array_ndims(tid);
H5Tget_array_dims2(tid, dims);
total_elmts = 1;
for (i = 0; i < rank; i++)
total_elmts *= dims[i];
h5str_sprintf(str, container, mtid, ((char *) (ptr->p)), ptr->len, expand_data);
H5Tclose(mtid);
h5str_append(str, " ] ");
}
break;
default:
this_strlen = h5str_sprintf(str, container, tid, ((char *) (ptr->p)), ptr->len, expand_data);
break;
} /* end switch */
return this_strlen;
} /* end h5str_vlsprintf */
/** print value of a data point into string.
Return Value:
On success, the total number of characters printed is returned.
On error, a negative number is returned.
*/
size_t
h5str_sprintf
(h5str_t *str, hid_t container, hid_t tid, void *ptr, int ptr_len, int expand_data)
{
unsigned char tmp_uchar = 0;
char tmp_char = 0;
unsigned short tmp_ushort = 0;
short tmp_short = 0;
unsigned int tmp_uint = 0;
int tmp_int = 0;
unsigned long tmp_ulong = 0;
long tmp_long = 0;
unsigned long long tmp_ullong = 0;
long long tmp_llong = 0;
float tmp_float = 0.0;
double tmp_double = 0.0;
long double tmp_ldouble = 0.0;
static char fmt_llong[8], fmt_ullong[8];
hid_t mtid = -1;
size_t offset;
size_t nll;
char *this_str;
size_t this_strlen;
int n;
char *cptr = (char*) (ptr);
unsigned char *ucptr = (unsigned char*) (ptr);
H5T_class_t tclass = H5Tget_class(tid); H5T_class_t tclass = H5Tget_class(tid);
size_t size = H5Tget_size(tid); size_t size = H5Tget_size(tid);
H5T_sign_t nsign = H5Tget_sign(tid); H5T_sign_t nsign = H5Tget_sign(tid);
@@ -206,20 +300,20 @@ h5str_sprintf
case H5T_FLOAT: case H5T_FLOAT:
if (sizeof(float) == size) { if (sizeof(float) == size) {
/* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */ /* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */
HDmemcpy(&tmp_float, ptr, sizeof(float)); HDmemcpy(&tmp_float, cptr, sizeof(float));
this_str = (char*)HDmalloc(25); this_str = (char*)HDmalloc(25);
sprintf(this_str, "%g", tmp_float); sprintf(this_str, "%g", tmp_float);
} }
else if (sizeof(double) == size) { else if (sizeof(double) == size) {
/* if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) */ /* if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) */
HDmemcpy(&tmp_double, ptr, sizeof(double)); HDmemcpy(&tmp_double, cptr, sizeof(double));
this_str = (char*)HDmalloc(25); this_str = (char*)HDmalloc(25);
sprintf(this_str, "%g", tmp_double); sprintf(this_str, "%g", tmp_double);
} }
#if H5_SIZEOF_LONG_DOUBLE !=0 #if H5_SIZEOF_LONG_DOUBLE !=0
else if (sizeof(long double) == size) { else if (sizeof(long double) == size) {
/* if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) */ /* if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) */
HDmemcpy(&tmp_ldouble, ptr, sizeof(long double)); HDmemcpy(&tmp_ldouble, cptr, sizeof(long double));
this_str = (char*)HDmalloc(27); this_str = (char*)HDmalloc(27);
sprintf(this_str, "%Lf", tmp_ldouble); sprintf(this_str, "%Lf", tmp_ldouble);
} }
@@ -256,13 +350,13 @@ h5str_sprintf
if (sizeof(char) == size) { if (sizeof(char) == size) {
if(H5T_SGN_NONE == nsign) { if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */ /* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */
HDmemcpy(&tmp_uchar, ptr, sizeof(unsigned char)); HDmemcpy(&tmp_uchar, cptr, sizeof(unsigned char));
this_str = (char*)HDmalloc(7); this_str = (char*)HDmalloc(7);
sprintf(this_str, "%u", tmp_uchar); sprintf(this_str, "%u", tmp_uchar);
} }
else { else {
/* if (H5Tequal(tid, H5T_NATIVE_SCHAR)) */ /* if (H5Tequal(tid, H5T_NATIVE_SCHAR)) */
HDmemcpy(&tmp_char, ptr, sizeof(char)); HDmemcpy(&tmp_char, cptr, sizeof(char));
this_str = (char*)HDmalloc(7); this_str = (char*)HDmalloc(7);
sprintf(this_str, "%hhd", tmp_char); sprintf(this_str, "%hhd", tmp_char);
} }
@@ -270,13 +364,13 @@ h5str_sprintf
else if (sizeof(int) == size) { else if (sizeof(int) == size) {
if(H5T_SGN_NONE == nsign) { if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_UINT)) */ /* if (H5Tequal(tid, H5T_NATIVE_UINT)) */
HDmemcpy(&tmp_uint, ptr, sizeof(unsigned int)); HDmemcpy(&tmp_uint, cptr, sizeof(unsigned int));
this_str = (char*)HDmalloc(14); this_str = (char*)HDmalloc(14);
sprintf(this_str, "%u", tmp_uint); sprintf(this_str, "%u", tmp_uint);
} }
else { else {
/* if (H5Tequal(tid, H5T_NATIVE_INT)) */ /* if (H5Tequal(tid, H5T_NATIVE_INT)) */
HDmemcpy(&tmp_int, ptr, sizeof(int)); HDmemcpy(&tmp_int, cptr, sizeof(int));
this_str = (char*)HDmalloc(14); this_str = (char*)HDmalloc(14);
sprintf(this_str, "%d", tmp_int); sprintf(this_str, "%d", tmp_int);
} }
@@ -284,13 +378,13 @@ h5str_sprintf
else if (sizeof(short) == size) { else if (sizeof(short) == size) {
if(H5T_SGN_NONE == nsign) { if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */ /* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */
HDmemcpy(&tmp_ushort, ptr, sizeof(unsigned short)); HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short));
this_str = (char*)HDmalloc(9); this_str = (char*)HDmalloc(9);
sprintf(this_str, "%u", tmp_ushort); sprintf(this_str, "%u", tmp_ushort);
} }
else { else {
/* if (H5Tequal(tid, H5T_NATIVE_SHORT)) */ /* if (H5Tequal(tid, H5T_NATIVE_SHORT)) */
HDmemcpy(&tmp_short, ptr, sizeof(short)); HDmemcpy(&tmp_short, cptr, sizeof(short));
this_str = (char*)HDmalloc(9); this_str = (char*)HDmalloc(9);
sprintf(this_str, "%d", tmp_short); sprintf(this_str, "%d", tmp_short);
} }
@@ -298,13 +392,13 @@ h5str_sprintf
else if (sizeof(long) == size) { else if (sizeof(long) == size) {
if(H5T_SGN_NONE == nsign) { if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */ /* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */
HDmemcpy(&tmp_ulong, ptr, sizeof(unsigned long)); HDmemcpy(&tmp_ulong, cptr, sizeof(unsigned long));
this_str = (char*)HDmalloc(23); this_str = (char*)HDmalloc(23);
sprintf(this_str, "%lu", tmp_ulong); sprintf(this_str, "%lu", tmp_ulong);
} }
else { else {
/* if (H5Tequal(tid, H5T_NATIVE_LONG)) */ /* if (H5Tequal(tid, H5T_NATIVE_LONG)) */
HDmemcpy(&tmp_long, ptr, sizeof(long)); HDmemcpy(&tmp_long, cptr, sizeof(long));
this_str = (char*)HDmalloc(23); this_str = (char*)HDmalloc(23);
sprintf(this_str, "%ld", tmp_long); sprintf(this_str, "%ld", tmp_long);
} }
@@ -312,13 +406,13 @@ h5str_sprintf
else if (sizeof(long long) == size) { else if (sizeof(long long) == size) {
if(H5T_SGN_NONE == nsign) { if(H5T_SGN_NONE == nsign) {
/* if (H5Tequal(tid, H5T_NATIVE_ULLONG)) */ /* if (H5Tequal(tid, H5T_NATIVE_ULLONG)) */
HDmemcpy(&tmp_ullong, ptr, sizeof(unsigned long long)); HDmemcpy(&tmp_ullong, cptr, sizeof(unsigned long long));
this_str = (char*)HDmalloc(25); this_str = (char*)HDmalloc(25);
sprintf(this_str, fmt_ullong, tmp_ullong); sprintf(this_str, fmt_ullong, tmp_ullong);
} }
else { else {
/* if (H5Tequal(tid, H5T_NATIVE_LLONG)) */ /* if (H5Tequal(tid, H5T_NATIVE_LLONG)) */
HDmemcpy(&tmp_llong, ptr, sizeof(long long)); HDmemcpy(&tmp_llong, cptr, sizeof(long long));
this_str = (char*)HDmalloc(25); this_str = (char*)HDmalloc(25);
sprintf(this_str, fmt_llong, tmp_llong); sprintf(this_str, fmt_llong, tmp_llong);
} }
@@ -333,7 +427,7 @@ h5str_sprintf
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
offset = H5Tget_member_offset(tid, i); offset = H5Tget_member_offset(tid, i);
mtid = H5Tget_member_type(tid, i); mtid = H5Tget_member_type(tid, i);
h5str_sprintf(str, container, mtid, cptr + offset, expand_data); h5str_sprintf(str, container, mtid, cptr + offset, ptr_len, expand_data);
if (i < n - 1) if (i < n - 1)
h5str_append(str, ", "); h5str_append(str, ", ");
H5Tclose(mtid); H5Tclose(mtid);
@@ -344,7 +438,7 @@ h5str_sprintf
case H5T_ENUM: case H5T_ENUM:
{ {
char enum_name[1024]; char enum_name[1024];
if (H5Tenum_nameof(tid, ptr, enum_name, sizeof enum_name) >= 0) { if (H5Tenum_nameof(tid, cptr, enum_name, sizeof enum_name) >= 0) {
h5str_append(str, enum_name); h5str_append(str, enum_name);
} }
else { else {
@@ -363,7 +457,7 @@ h5str_sprintf
} }
break; break;
case H5T_REFERENCE: case H5T_REFERENCE:
if (h5str_is_zero(ptr, size)) { if (h5str_is_zero(cptr, size)) {
h5str_append(str, "NULL"); h5str_append(str, "NULL");
} }
else { else {
@@ -379,9 +473,9 @@ h5str_sprintf
H5S_sel_type region_type; H5S_sel_type region_type;
/* get name of the dataset the region reference points to using H5Rget_name */ /* get name of the dataset the region reference points to using H5Rget_name */
region_obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, ptr); region_obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, cptr);
if (region_obj >= 0) { if (region_obj >= 0) {
region = H5Rget_region(container, H5R_DATASET_REGION, ptr); region = H5Rget_region(container, H5R_DATASET_REGION, cptr);
if (region >= 0) { if (region >= 0) {
if(expand_data) { if(expand_data) {
region_type = H5Sget_select_type(region); region_type = H5Sget_select_type(region);
@@ -393,7 +487,7 @@ h5str_sprintf
} }
} }
else { else {
if(H5Rget_name(region_obj, H5R_DATASET_REGION, ptr, (char*)ref_name, 1024) >= 0) { if(H5Rget_name(region_obj, H5R_DATASET_REGION, cptr, (char*)ref_name, 1024) >= 0) {
h5str_append(str, ref_name); h5str_append(str, ref_name);
} }
@@ -424,7 +518,7 @@ h5str_sprintf
hid_t obj; hid_t obj;
this_str = (char*)HDmalloc(64); this_str = (char*)HDmalloc(64);
obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, ptr); obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, cptr);
H5Oget_info2(obj, &oi, H5O_INFO_ALL); H5Oget_info2(obj, &oi, H5O_INFO_ALL);
/* Print object data and close object */ /* Print object data and close object */
@@ -450,31 +544,30 @@ h5str_sprintf
total_elmts *= dims[i]; total_elmts *= dims[i];
for (i = 0; i < total_elmts; i++) { for (i = 0; i < total_elmts; i++) {
h5str_sprintf(str, container, mtid, cptr + i * size, expand_data); h5str_sprintf(str, container, mtid, cptr + i * size, ptr_len, expand_data);
if (i < total_elmts - 1) if (i < total_elmts - 1)
h5str_append(str, ", "); h5str_append(str, ", ");
} }
H5Tclose(mtid); H5Tclose(mtid);
h5str_append(str, "] "); h5str_append(str, " ] ");
} }
break; break;
case H5T_VLEN: case H5T_VLEN:
{ {
unsigned int i; unsigned int i;
mtid = H5Tget_super(tid); mtid = H5Tget_super(tid);
size = H5Tget_size(mtid); size = H5Tget_size(mtid);
vlptr = (hvl_t *) cptr; h5str_append(str, "{");
for (i = 0; i < (int)ptr_len; i++) {
nll = vlptr->len; h5str_sprintf(str, container, mtid, cptr + i * size, ptr_len, expand_data);
for (i = 0; i < (int)nll; i++) { if (i < (int)ptr_len - 1)
h5str_sprintf(str, container, mtid, ((char *) (vlptr->p)) + i * size, expand_data); h5str_append(str, ", ");
if (i < (int)nll - 1) }
h5str_append(str, ", "); H5Tclose(mtid);
h5str_append(str, "}");
} }
H5Tclose(mtid); break;
}
break;
default: default:
{ {
@@ -563,7 +656,7 @@ h5str_print_region_data_blocks
if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) { if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) {
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
for (numindex = 0; numindex < numelem; numindex++) { for (numindex = 0; numindex < numelem; numindex++) {
h5str_sprintf(str, region_id, type_id, ((char*)region_buf + numindex * type_size), 1); h5str_sprintf(str, region_id, type_id, ((char*)region_buf + numindex * type_size), 0, 1);
if (numindex + 1 < numelem) if (numindex + 1 < numelem)
h5str_append(str, ", "); h5str_append(str, ", ");
@@ -763,7 +856,7 @@ h5str_print_region_data_points
for (jndx = 0; jndx < npoints; jndx++) { for (jndx = 0; jndx < npoints; jndx++) {
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) {
h5str_sprintf(str, region_id, type_id, ((char*)region_buf + jndx * type_size), 1); h5str_sprintf(str, region_id, type_id, ((char*)region_buf + jndx * type_size), 0, 1);
if (jndx + 1 < npoints) if (jndx + 1 < npoints)
h5str_append(str, ", "); h5str_append(str, ", ");
@@ -1883,7 +1976,7 @@ h5tools_dump_simple_data
/* Render the data element*/ /* Render the data element*/
h5str_new(&buffer, 32 * size); h5str_new(&buffer, 32 * size);
bytes_in = h5str_sprintf(&buffer, container, type, memref, 1); bytes_in = h5str_sprintf(&buffer, container, type, memref, 0, 1);
if(i > 0) { if(i > 0) {
HDfprintf(stream, ", "); HDfprintf(stream, ", ");
if (line_count >= H5TOOLS_TEXT_BLOCK) { if (line_count >= H5TOOLS_TEXT_BLOCK) {
@@ -2059,7 +2152,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex
else { else {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
h5str.s[0] = '\0'; h5str.s[0] = '\0';
h5str_sprintf(&h5str, attr_id, mem_type_id, rdata + ((size_t)i * size), 0); h5str_sprintf(&h5str, attr_id, mem_type_id, rdata + ((size_t)i * size), 0, 0);
jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s);
ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);
} /* end for */ } /* end for */

View File

@@ -39,7 +39,8 @@ extern void h5str_new (h5str_t *str, size_t len);
extern void h5str_free (h5str_t *str); extern void h5str_free (h5str_t *str);
extern void h5str_resize (h5str_t *str, size_t new_len); extern void h5str_resize (h5str_t *str, size_t new_len);
extern char* h5str_append (h5str_t *str, const char* cstr); extern char* h5str_append (h5str_t *str, const char* cstr);
extern size_t h5str_sprintf(h5str_t *str, hid_t container, hid_t tid, void *buf, int expand_data); extern size_t h5str_vlsprintf(h5str_t *str, hid_t container, hid_t tid, hvl_t *buf, int expand_data);
extern size_t h5str_sprintf(h5str_t *str, hid_t container, hid_t tid, void *buf, int ptrlen, int expand_data);
extern void h5str_array_free(char **strs, size_t len); extern void h5str_array_free(char **strs, size_t len);
extern int h5str_dump_simple_dset(FILE *stream, hid_t dset, int binary_order); extern int h5str_dump_simple_dset(FILE *stream, hid_t dset, int binary_order);
extern int h5str_dump_region_blocks_data(h5str_t *str, hid_t region, hid_t region_obj); extern int h5str_dump_region_blocks_data(h5str_t *str, hid_t region, hid_t region_obj);