Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.10.8 Merge Add missing dataset reference text #1081 #1084

Merged
merged 2 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions java/src/jni/h5util.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,23 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_
case sizeof(float): {
float tmp_float = 0.0f;

sscanf(token, "%f", &tmp_float);
HDsscanf(token, "%f", &tmp_float);
HDmemcpy(cptr, &tmp_float, sizeof(float));
break;
}

case sizeof(double): {
double tmp_double = 0.0;

sscanf(token, "%lf", &tmp_double);
HDsscanf(token, "%lf", &tmp_double);
HDmemcpy(cptr, &tmp_double, sizeof(double));
break;
}
#if H5_SIZEOF_LONG_DOUBLE != 0 && H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE
case sizeof(long double): {
long double tmp_ldouble = 0.0;

sscanf(token, "%Lg", &tmp_ldouble);
HDsscanf(token, "%Lg", &tmp_ldouble);
HDmemcpy(cptr, &tmp_ldouble, sizeof(long double));
break;
}
Expand Down Expand Up @@ -288,11 +288,11 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_
signed char tmp_char = 0;

if (H5T_SGN_NONE == nsign) {
sscanf(token, "%hhu", &tmp_uchar);
HDsscanf(token, "%hhu", &tmp_uchar);
HDmemcpy(cptr, &tmp_uchar, sizeof(unsigned char));
}
else {
sscanf(token, "%hhd", &tmp_char);
HDsscanf(token, "%hhd", &tmp_char);
HDmemcpy(cptr, &tmp_char, sizeof(char));
}

Expand All @@ -304,11 +304,11 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_
short tmp_short = 0;

if (H5T_SGN_NONE == nsign) {
sscanf(token, "%hu", &tmp_ushort);
HDsscanf(token, "%hu", &tmp_ushort);
HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short));
}
else {
sscanf(token, "%hd", &tmp_short);
HDsscanf(token, "%hd", &tmp_short);
HDmemcpy(&tmp_short, cptr, sizeof(short));
}

Expand All @@ -320,11 +320,11 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_
int tmp_int = 0;

if (H5T_SGN_NONE == nsign) {
sscanf(token, "%u", &tmp_uint);
HDsscanf(token, "%u", &tmp_uint);
HDmemcpy(cptr, &tmp_uint, sizeof(unsigned int));
}
else {
sscanf(token, "%d", &tmp_int);
HDsscanf(token, "%d", &tmp_int);
HDmemcpy(cptr, &tmp_int, sizeof(int));
}

Expand All @@ -337,11 +337,11 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_
long tmp_long = 0;

if (H5T_SGN_NONE == nsign) {
sscanf(token, "%lu", &tmp_ulong);
HDsscanf(token, "%lu", &tmp_ulong);
HDmemcpy(cptr, &tmp_ulong, sizeof(unsigned long));
}
else {
sscanf(token, "%ld", &tmp_long);
HDsscanf(token, "%ld", &tmp_long);
HDmemcpy(cptr, &tmp_long, sizeof(long));
}

Expand All @@ -354,11 +354,11 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_
long long tmp_llong = 0;

if (H5T_SGN_NONE == nsign) {
sscanf(token, fmt_ullong, &tmp_ullong);
HDsscanf(token, fmt_ullong, &tmp_ullong);
HDmemcpy(cptr, &tmp_ullong, sizeof(unsigned long long));
}
else {
sscanf(token, fmt_llong, &tmp_llong);
HDsscanf(token, fmt_llong, &tmp_llong);
HDmemcpy(cptr, &tmp_llong, sizeof(long long));
}

Expand Down Expand Up @@ -640,6 +640,34 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_
return retVal;
} /* end h5str_convert */

/*-------------------------------------------------------------------------
* Function: h5str_sprint_reference
*
* Purpose: Object reference -- show the name of the referenced object.
*
* Return: SUCCEED or FAIL
*-------------------------------------------------------------------------
*/
int
h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, hid_t region_obj, void *ref_buf)
{
hid_t region = H5I_INVALID_HID;
char ref_name[1024];
const char *path;

int ret_value = FAIL;

if ((H5Rget_name(region_obj, H5R_DATASET_REGION, ref_buf, (char *)ref_name, 1024)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (!h5str_append(out_str, ref_name))
H5_ASSERTION_ERROR(ENVONLY, "Unable to append string.");

ret_value = SUCCEED;
done:

return ret_value;
} /* h5str_sprint_reference */

int
h5str_region_dataset(JNIEnv *env, h5str_t *out_str, hid_t container, void *ref_buf, int expand_data)
{
Expand All @@ -655,6 +683,10 @@ h5str_region_dataset(JNIEnv *env, h5str_t *out_str, hid_t container, void *ref_b
if ((region_sid = H5Rget_region(container, H5R_DATASET_REGION, ref_buf)) < 0)
H5_LIBRARY_ERROR(ENVONLY);

if (expand_data == 0)
if (h5str_sprint_reference(ENVONLY, out_str, region_obj, ref_buf) < 0)
CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE);

if ((region_type = H5Sget_select_type(region_sid)) > H5S_SEL_ERROR) {
if (H5S_SEL_POINTS == region_type) {
if (h5str_dump_region_points(ENVONLY, out_str, region_sid, region_obj, expand_data) < 0)
Expand Down
1 change: 1 addition & 0 deletions java/src/jni/h5util.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern void h5str_resize(h5str_t *str, size_t new_len);
extern char * h5str_append(h5str_t *str, const char *cstr);
extern size_t h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf,
size_t out_buf_offset);
extern int h5str_sprint_reference(JNIEnv *env, h5str_t *out_str, hid_t region_obj, void *ref_buf);
extern size_t h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf,
int expand_data);
extern void h5str_array_free(char **strs, size_t len);
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/h5tools_ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ ref_path_table_gen_fake(const char *path)
/*-------------------------------------------------------------------------
* Function: lookup_ref_path
*
* Purpose: Lookup the path to the object with refernce 'ref'.
* Purpose: Lookup the path to the object with reference 'ref'.
*
* Return: Return a path to the object, or NULL if not found.
*
Expand Down