summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools.c
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2011-05-02 20:41:03 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2011-05-02 20:41:03 (GMT)
commit3e755a079bb0bce16f80723ef8b4daf57d2ed979 (patch)
tree21b33798b4ef25dbe932e84cb6a2b56b01de2da1 /tools/lib/h5tools.c
parent216625cb8151eccb47bca4f9c6e19d7b85eb3c89 (diff)
downloadhdf5-3e755a079bb0bce16f80723ef8b4daf57d2ed979.zip
hdf5-3e755a079bb0bce16f80723ef8b4daf57d2ed979.tar.gz
hdf5-3e755a079bb0bce16f80723ef8b4daf57d2ed979.tar.bz2
[svn-r20706] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects Description: Merged from HDF5 trunk r20676. 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 3d29d39..a712794 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -631,11 +631,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
*-------------------------------------------------------------------------
*/
@@ -663,7 +663,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
@@ -853,7 +853,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 */
@@ -2424,7 +2424,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);
}
@@ -2532,7 +2532,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.
@@ -2550,7 +2550,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*/
@@ -4328,3 +4328,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;
+}
+