diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2008-02-28 14:49:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2008-02-28 14:49:48 (GMT) |
commit | 66fa79b4234287d1b51ef62b394aa92fcafe7dd2 (patch) | |
tree | f9df07d9e98ee2a7dcaee08691b757e43550169a /tools/lib | |
parent | a884d556b7401444be47828145786adf56edf311 (diff) | |
download | hdf5-66fa79b4234287d1b51ef62b394aa92fcafe7dd2.zip hdf5-66fa79b4234287d1b51ef62b394aa92fcafe7dd2.tar.gz hdf5-66fa79b4234287d1b51ef62b394aa92fcafe7dd2.tar.bz2 |
[svn-r14690] 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); } } |