diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2017-05-16 14:28:49 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2017-05-17 15:14:53 (GMT) |
commit | 2e1b6a2a4d8f1d3a8eb503a8d30c6d91452b6282 (patch) | |
tree | bdda72af40eb405963a911d159ae045de3c28380 /tools | |
parent | f3c235b0a57bc6a32951571e22b55333c5adc03d (diff) | |
download | hdf5-2e1b6a2a4d8f1d3a8eb503a8d30c6d91452b6282.zip hdf5-2e1b6a2a4d8f1d3a8eb503a8d30c6d91452b6282.tar.gz hdf5-2e1b6a2a4d8f1d3a8eb503a8d30c6d91452b6282.tar.bz2 |
HDFFV-10128 Fixed string length with no null fixed
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/h5diff_array.c | 114 |
1 files changed, 73 insertions, 41 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 49f41dc..499d5eb 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -623,6 +623,7 @@ static hsize_t diff_datum(void *_mem1, *------------------------------------------------------------------------- */ case H5T_COMPOUND: + h5difftrace("diff_datum H5T_COMPOUND\n"); nmembs = members->n; @@ -655,18 +656,21 @@ static hsize_t diff_datum(void *_mem1, *------------------------------------------------------------------------- */ case H5T_STRING: - + h5difftrace("diff_datum H5T_STRING\n"); { - H5T_str_t pad; - char *s; - char *s1; - char *s2; - size_t size1; - size_t size2; + char *s = NULL; + char *sx = NULL; + char *s1 = NULL; + char *s2 = NULL; + size_t size1; + size_t size2; + size_t sizex; + size_t size_mtype = H5Tget_size(m_type); + H5T_str_t pad = H5Tget_strpad(m_type); /* if variable length string */ - if(H5Tis_variable_str(m_type)) - { + if(H5Tis_variable_str(m_type)) { + h5difftrace("diff_datum H5T_STRING variable\n"); /* Get pointer to first string */ s1 = *(char**) mem1; size1 = HDstrlen(s1); @@ -674,14 +678,26 @@ static hsize_t diff_datum(void *_mem1, s2 = *(char**) mem2; size2 = HDstrlen(s2); } - else - { + else if (H5T_STR_NULLTERM == pad) { + h5difftrace("diff_datum H5T_STRING null term\n"); + /* Get pointer to first string */ + s1 = (char*) mem1; + size1 = HDstrlen(s1); + if (size1 > size_mtype) + size1 = size_mtype; + /* Get pointer to second string */ + s2 = (char*) mem2; + size2 = HDstrlen(s2); + if (size2 > size_mtype) + size2 = size_mtype; + } + else { /* Get pointer to first string */ s1 = (char *)mem1; - size1 = H5Tget_size(m_type); + size1 = size_mtype; /* Get pointer to second string */ s2 = (char *)mem2; - size2 = H5Tget_size(m_type); + size2 = size_mtype; } /* @@ -692,45 +708,59 @@ static hsize_t diff_datum(void *_mem1, */ h5diffdebug2("diff_datum string size:%d\n",size1); h5diffdebug2("diff_datum string size:%d\n",size2); - if(size1 != size2) - { + if(size1 != size2) { h5difftrace("diff_datum string sizes\n"); nfound++; } - if(size1 < size2) - { + if(size1 < size2) { size = size1; s = s1; + sizex = size2; + sx = s2; } - else - { + else { size = size2; s = s2; + sizex = size1; + sx = s1; } /* check for NULL pointer for string */ - if(s!=NULL) - { + if(s!=NULL) { /* try fast compare first */ - if (HDmemcmp(s1, s2, size)==0) - break; - - pad = H5Tget_strpad(m_type); - - for (u=0; u<size; u++) - nfound+=character_compare( - s1 + u, - s2 + u, /* offset */ - i, /* index position */ - u, /* string character position */ - rank, - dims, - acc, - pos, - options, - obj1, - obj2, - ph); + if(HDmemcmp(s1, s2, size)==0) { + if(size1 != size2) + if(print_data(options)) + for (u=size; u<sizex; u++) + character_compare( + s1 + u, + s2 + u, /* offset */ + i, /* index position */ + u, /* string character position */ + rank, + dims, + acc, + pos, + options, + obj1, + obj2, + ph); + } + else + for (u=0; u<size; u++) + nfound+=character_compare( + s1 + u, + s2 + u, /* offset */ + i, /* index position */ + u, /* string character position */ + rank, + dims, + acc, + pos, + options, + obj1, + obj2, + ph); } } @@ -741,6 +771,7 @@ static hsize_t diff_datum(void *_mem1, *------------------------------------------------------------------------- */ case H5T_BITFIELD: + h5difftrace("diff_datum H5T_BITFIELD\n"); /* byte-by-byte comparison */ for (u=0; u<type_size; u++) @@ -764,7 +795,7 @@ static hsize_t diff_datum(void *_mem1, *------------------------------------------------------------------------- */ case H5T_OPAQUE: - + h5difftrace("diff_datum H5T_OPAQUE\n"); /* byte-by-byte comparison */ for (u=0; u<type_size; u++) nfound+=character_compare_opt( @@ -788,6 +819,7 @@ static hsize_t diff_datum(void *_mem1, *------------------------------------------------------------------------- */ case H5T_ENUM: + h5difftrace("diff_datum H5T_ENUM\n"); /* For enumeration types we compare the names instead of the integer values. For each pair of elements being |