diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2017-05-31 22:07:49 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2017-05-31 22:07:49 (GMT) |
commit | 1e9354bcf551c16f3ad9d6a4ad42a2bce827c95e (patch) | |
tree | 20d28f7dd91b67f06880d6ca6566c1caa3dc06ae /tools/lib/h5diff_array.c | |
parent | 734aebc39538039c6e81db63edd68eb3a2029cd2 (diff) | |
parent | 5c5ea7e89fbac1d31880d61e6a35ff6034019078 (diff) | |
download | hdf5-1e9354bcf551c16f3ad9d6a4ad42a2bce827c95e.zip hdf5-1e9354bcf551c16f3ad9d6a4ad42a2bce827c95e.tar.gz hdf5-1e9354bcf551c16f3ad9d6a4ad42a2bce827c95e.tar.bz2 |
Merge branch 'develop' into windows_open
Diffstat (limited to 'tools/lib/h5diff_array.c')
-rw-r--r-- | tools/lib/h5diff_array.c | 126 |
1 files changed, 79 insertions, 47 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 49f41dc..0b1a96e 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -140,7 +140,7 @@ typedef struct mcomp_t static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id,hid_t region1_id, hid_t region2_id, diff_opt_t *options); static hbool_t all_zero(const void *_mem, size_t size); static int ull2float(unsigned long long ull_value, float *f_value); -static hsize_t character_compare(char *mem1,char *mem2,hsize_t i,unsigned u,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph); +static hsize_t character_compare(char *mem1,char *mem2,hsize_t i,size_t u,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph); static hsize_t character_compare_opt(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph); static hbool_t equal_float(float value, float expected, diff_opt_t *options); static hbool_t equal_double(double value, double expected, diff_opt_t *options); @@ -149,7 +149,7 @@ static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t #endif static int print_data(diff_opt_t *options); static void print_pos(int *ph,int pp,hsize_t curr_pos,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 ); -static void print_char_pos(int *ph,int pp,hsize_t curr_pos,unsigned u,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 ); +static void print_char_pos(int *ph,int pp,hsize_t curr_pos,size_t u,hsize_t *acc,hsize_t *pos,int rank,hsize_t *dims,const char *obj1,const char *obj2 ); static void h5diff_print_char(char ch); static hsize_t diff_datum(void *_mem1, void *_mem2, @@ -575,7 +575,7 @@ static hsize_t diff_datum(void *_mem1, { unsigned char *mem1 = (unsigned char*)_mem1; unsigned char *mem2 = (unsigned char*)_mem2; - unsigned u; + size_t u; hid_t memb_type; size_t type_size; H5T_sign_t type_sign; @@ -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 @@ -2781,7 +2813,7 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, - unsigned u, + size_t u, int rank, hsize_t *dims, hsize_t *acc, @@ -5874,7 +5906,7 @@ static void print_char_pos( int *ph, /* print header */ int pp, /* print percentage */ hsize_t curr_pos, - unsigned u, + size_t u, hsize_t *acc, hsize_t *pos, int rank, @@ -5912,7 +5944,7 @@ void print_char_pos( int *ph, /* print header */ } else { - parallel_print("%u", (unsigned)u); + parallel_print("%zu", u); } parallel_print("]" ); } |