diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2008-02-28 14:53:38 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2008-02-28 14:53:38 (GMT) |
commit | a233b8a08d16b09a3da0365fb7fab8f8b6c5a3d6 (patch) | |
tree | 9bac97485276023025ec37b8af85a41625657234 /tools/lib | |
parent | c1c885892fc6e22277d8f4529e5cd6b7b3f5bb47 (diff) | |
download | hdf5-a233b8a08d16b09a3da0365fb7fab8f8b6c5a3d6.zip hdf5-a233b8a08d16b09a3da0365fb7fab8f8b6c5a3d6.tar.gz hdf5-a233b8a08d16b09a3da0365fb7fab8f8b6c5a3d6.tar.bz2 |
[svn-r14691] Description:
Handle comparing datasets & attributes w/variable-length strings properly.
Tested on:
Linux/64 2.6.9 (chicago)
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5diff_array.c | 88 |
1 files changed, 41 insertions, 47 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 008b6b9..a348ca0 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -266,8 +266,6 @@ hsize_t diff_array( void *_mem1, size_t size; /* size of datum */ unsigned char *mem1 = (unsigned char*)_mem1; unsigned char *mem2 = (unsigned char*)_mem2; - unsigned char *tmp1; - unsigned char *tmp2; hsize_t acc[32]; /* accumulator position */ hsize_t pos[32]; /* matrix position */ int ph=1; /* print header */ @@ -288,23 +286,26 @@ hsize_t diff_array( void *_mem1, if(H5Tis_variable_str(m_type)) { - tmp1 = ((unsigned char**)mem1)[0]; - tmp2 = ((unsigned char**)mem2)[0]; - nfound+=diff_datum( - tmp1, - tmp2, - m_type, - (hsize_t)0, - rank, - dims, - acc, - pos, - options, - name1, - name2, - container1_id, - container2_id, - &ph); + for ( i = 0; i < nelmts; i++) + { + nfound+=diff_datum( + ((unsigned char**)mem1)[(size_t)i], + ((unsigned char**)mem2)[(size_t)i], + m_type, + i, + rank, + dims, + acc, + pos, + options, + name1, + name2, + container1_id, + container2_id, + &ph); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } else @@ -515,42 +516,35 @@ hsize_t diff_datum(void *_mem1, case H5T_STRING: { - 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 = (char *)mem1; - size = H5Tget_size(m_type); - } - - pad = H5Tget_strpad(m_type); - + /* Get pointer to first string to compare */ + s = (char *)mem1; + /* check for NULL pointer for string */ if(s!=NULL) { + if(H5Tis_variable_str(m_type)) + size = HDstrlen(s); + else + size = H5Tget_size(m_type); + + pad = H5Tget_strpad(m_type); + for (u=0; u<size && (s[u] || pad!=H5T_STR_NULLTERM); u++) nfound+=character_compare( - mem1 + u, - mem2 + u, /* offset */ - i, /* index position */ - rank, - dims, - acc, - pos, - options, - obj1, - obj2, - ph); + mem1 + u, + mem2 + u, /* offset */ + i, /* index position */ + rank, + dims, + acc, + pos, + options, + obj1, + obj2, + ph); } } |