From 7078993d63aab4e239e4ae9c970b4b19d38352fa Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 12 May 2017 14:40:39 -0500 Subject: HDFFV-10128 Fix null term strings --- tools/lib/h5diff_array.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 49f41dc..bb2cd8a 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,19 @@ 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; - + H5T_str_t pad = H5Tget_strpad(m_type); + /* if variable length string */ 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,6 +676,15 @@ static hsize_t diff_datum(void *_mem1, s2 = *(char**) mem2; size2 = HDstrlen(s2); } + 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); + /* Get pointer to second string */ + s2 = (char*) mem2; + size2 = HDstrlen(s2); + } else { /* Get pointer to first string */ @@ -714,9 +725,6 @@ static hsize_t diff_datum(void *_mem1, /* try fast compare first */ if (HDmemcmp(s1, s2, size)==0) break; - - pad = H5Tget_strpad(m_type); - for (u=0; u Date: Mon, 15 May 2017 12:33:58 -0500 Subject: HDFFV-10128 add test to check null term Test is another dataset --- tools/lib/h5diff_array.c | 87 ++++++++++++++++----------- tools/test/h5diff/CMakeTests.cmake | 2 +- tools/test/h5diff/h5diffgentest.c | 28 +++++++++ tools/test/h5diff/testfiles/diff_strings1.h5 | Bin 4464 -> 4640 bytes tools/test/h5diff/testfiles/diff_strings2.h5 | Bin 4464 -> 4640 bytes tools/test/h5diff/testfiles/h5diff_tmp1.txt | 14 ++++- 6 files changed, 94 insertions(+), 37 deletions(-) diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index bb2cd8a..0a9d18a 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -658,16 +658,17 @@ static hsize_t diff_datum(void *_mem1, case H5T_STRING: h5difftrace("diff_datum H5T_STRING\n"); { - char *s; - char *s1; - char *s2; - size_t size1; - size_t size2; - H5T_str_t pad = H5Tget_strpad(m_type); - + char *s = NULL; + char *sx = NULL; + char *s1 = NULL; + char *s2 = NULL; + size_t size1; + size_t size2; + size_t sizex; + 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; @@ -685,8 +686,7 @@ static hsize_t diff_datum(void *_mem1, s2 = (char*) mem2; size2 = HDstrlen(s2); } - else - { + else { /* Get pointer to first string */ s1 = (char *)mem1; size1 = H5Tget_size(m_type); @@ -703,42 +703,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; - for (u=0; u> and > +3 differences found +attribute: > and > +1 differences found +attribute: > and > +1 differences found +attribute: > and > +1 differences found +attribute: > and > +1 differences found +attribute: > and > +1 differences found -------------------------------- Some objects are not comparable -------------------------------- Use -c for a list of objects. -EXIT CODE: 0 +EXIT CODE: 1 -- cgit v0.12