summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2005-06-30 16:53:11 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2005-06-30 16:53:11 (GMT)
commita8d9f5cfbc57ee86a79e36bc1b9913f0bddd1a12 (patch)
treeb26b433d246f11db108a58ad3f0547546e8bb1be /tools/lib
parent2c1d787f3e230895d20389d0c385ef7b06a2aefb (diff)
downloadhdf5-a8d9f5cfbc57ee86a79e36bc1b9913f0bddd1a12.zip
hdf5-a8d9f5cfbc57ee86a79e36bc1b9913f0bddd1a12.tar.gz
hdf5-a8d9f5cfbc57ee86a79e36bc1b9913f0bddd1a12.tar.bz2
[svn-r11003] Purpose:
bug fix Description: when diffing a string type string , a cycle is made using the hdf5 get_size function, which returns the type size some strings might have a NULL terminator character before the type size position this was noticed on a HDF-EOS file on the HDFEOSVersion attribute which was defined as a type with a 32 size, but contained a string with 12 characters, making h5diff to compare the extra garbage characters Solution: detect the NULL terminator character and end the diff at that position Platforms tested: linux Misc. update:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff_array.c59
1 files changed, 38 insertions, 21 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index 1ed4ab2..3632cdb 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -321,27 +321,44 @@ hsize_t diff_datum(void *_mem1,
*-------------------------------------------------------------------------
*/
case H5T_STRING:
-
- if(H5Tis_variable_str(m_type))
- type_size = HDstrlen((char*)mem1);
- else
- type_size = H5Tget_size(m_type);
-
- for (u=0; u<type_size; u++)
- nfound+=diff_char(
- mem1 + u,
- mem2 + u, /* offset */
- i, /* index position */
- rank,
- acc,
- pos,
- options,
- obj1,
- obj2,
- ph);
-
-
- break;
+ {
+
+ H5T_str_t pad;
+ char *s;
+
+ if(H5Tis_variable_str(m_type))
+ {
+ /* mem1 is the pointer into the struct where a `char*' is stored. So we have
+ * to dereference the pointer to get the `char*' to pass to HDstrlen(). */
+ s = *(char**)mem1;
+ if(s!=NULL)
+ size = HDstrlen(s);
+ }
+ else
+ {
+ s = mem1;
+ size = H5Tget_size(m_type);
+ }
+
+ pad = H5Tget_strpad(m_type);
+
+ /* check for NULL pointer for string */
+ if(s!=NULL)
+ for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++)
+ nfound+=diff_char(
+ mem1 + u,
+ mem2 + u, /* offset */
+ i, /* index position */
+ rank,
+ acc,
+ pos,
+ options,
+ obj1,
+ obj2,
+ ph);
+
+ }
+ break;
/*-------------------------------------------------------------------------
* H5T_BITFIELD