summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2011-04-29 17:02:31 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2011-04-29 17:02:31 (GMT)
commit170e7e53a515be431a33c4e191b0be7c74e14ae5 (patch)
tree63b1f338145e779f7112d8da2812b4c3429c5f79 /tools/lib/h5tools.c
parentad35b2bdb2d50d8f73703742c66d5baab6481d18 (diff)
downloadhdf5-170e7e53a515be431a33c4e191b0be7c74e14ae5.zip
hdf5-170e7e53a515be431a33c4e191b0be7c74e14ae5.tar.gz
hdf5-170e7e53a515be431a33c4e191b0be7c74e14ae5.tar.bz2
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects Description: Fixed: 1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications. 2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file. Test update: Updat prvious test cases (171, 172, 530) affected by this fix, so they still perfrom originally intended testing without bypassing. Tested: jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
Diffstat (limited to 'tools/lib/h5tools.c')
-rw-r--r--tools/lib/h5tools.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index bf85bc2..3e72bdd 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -626,11 +626,11 @@ h5tools_ncols(const char *s)
*
* Purpose: Recursive check for any variable length data in given type.
*
- * Return:
+ * Return:
* TRUE : type conatains any variable length data
* FALSE : type doesn't contain any variable length data
* Negative value: error occur
- *
+ *
* Programmer: Jonathan Kim March 18, 2011
*-------------------------------------------------------------------------
*/
@@ -658,7 +658,7 @@ done:
*
* Purpose: Recursive check for variable length string of a datatype.
*
- * Return:
+ * Return:
* TRUE : type conatains any variable length string
* FALSE : type doesn't contain any variable length string
* Negative value: error occur
@@ -848,7 +848,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
}
/* Calculate new prefix */
- h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims,
+ h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims,
ctx->p_max_idx, ctx);
/* Write new prefix to output */
@@ -2419,7 +2419,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset
/* Terminate the output */
if (ctx.cur_column) {
fputs(OPT(info->line_suf, ""), stdout);
- putc('\n', stdout);
+ putc('\n', stdout);
fputs(OPT(info->line_sep, ""), stdout);
}
@@ -2527,7 +2527,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info,
vl_data = TRUE;
if (H5Tdetect_class(p_type, H5T_VLEN) == TRUE)
vl_data = TRUE;
-
+
/*
* Determine the strip mine size and allocate a buffer. The strip mine is
* a hyperslab whose size is manageable.
@@ -2545,7 +2545,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info,
}
}
- if(!sm_nbytes)
+ if(!sm_nbytes)
goto done;
assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/
@@ -4323,3 +4323,45 @@ hbool_t h5tools_is_zero(const void *_mem, size_t size)
return TRUE;
}
+/*-------------------------------------------------------------------------
+ * Function: h5tools_is_obj_same
+ *
+ * Purpose: Check if two given object IDs or link names point to the same object.
+ *
+ * Parameters:
+ * hid_t loc_id1: location of the first object
+ * char *name1: link name of the first object.
+ * Use "." or NULL if loc_id1 is the object to be compared.
+ * hid_t loc_id2: location of the second object
+ * char *name1: link name of the first object.
+ * Use "." or NULL if loc_id2 is the object to be compared.
+ *
+ * Return: TRUE if it is the same object; FALSE otherwise.
+ *
+ * Programmer: Peter Cao
+ * 4/27/2011
+ *
+ *-------------------------------------------------------------------------
+ */
+hbool_t h5tools_is_obj_same(hid_t loc_id1, const char *name1,
+ hid_t loc_id2, const char *name2)
+{
+ H5O_info_t oinfo1, oinfo2;
+ hbool_t ret_val = 0;
+
+ if ( name1 && strcmp(name1, "."))
+ H5Oget_info_by_name(loc_id1, name1, &oinfo1, H5P_DEFAULT);
+ else
+ H5Oget_info(loc_id1, &oinfo1);
+
+ if ( name2 && strcmp(name2, "."))
+ H5Oget_info_by_name(loc_id2, name2, &oinfo2, H5P_DEFAULT);
+ else
+ H5Oget_info(loc_id2, &oinfo2);
+
+ if (oinfo1.fileno == oinfo2.fileno && oinfo1.addr==oinfo2.addr)
+ ret_val = 1;
+
+ return ret_val;
+}
+