HDFFV-10128 Fixed string length with no null fixed
This commit is contained in:
@@ -623,6 +623,7 @@ static hsize_t diff_datum(void *_mem1,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
case H5T_COMPOUND:
|
case H5T_COMPOUND:
|
||||||
|
h5difftrace("diff_datum H5T_COMPOUND\n");
|
||||||
|
|
||||||
nmembs = members->n;
|
nmembs = members->n;
|
||||||
|
|
||||||
@@ -655,18 +656,21 @@ static hsize_t diff_datum(void *_mem1,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
case H5T_STRING:
|
case H5T_STRING:
|
||||||
|
h5difftrace("diff_datum H5T_STRING\n");
|
||||||
{
|
{
|
||||||
H5T_str_t pad;
|
char *s = NULL;
|
||||||
char *s;
|
char *sx = NULL;
|
||||||
char *s1;
|
char *s1 = NULL;
|
||||||
char *s2;
|
char *s2 = NULL;
|
||||||
size_t size1;
|
size_t size1;
|
||||||
size_t size2;
|
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 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 */
|
/* Get pointer to first string */
|
||||||
s1 = *(char**) mem1;
|
s1 = *(char**) mem1;
|
||||||
size1 = HDstrlen(s1);
|
size1 = HDstrlen(s1);
|
||||||
@@ -674,14 +678,26 @@ static hsize_t diff_datum(void *_mem1,
|
|||||||
s2 = *(char**) mem2;
|
s2 = *(char**) mem2;
|
||||||
size2 = HDstrlen(s2);
|
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 */
|
/* Get pointer to first string */
|
||||||
s1 = (char *)mem1;
|
s1 = (char *)mem1;
|
||||||
size1 = H5Tget_size(m_type);
|
size1 = size_mtype;
|
||||||
/* Get pointer to second string */
|
/* Get pointer to second string */
|
||||||
s2 = (char *)mem2;
|
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",size1);
|
||||||
h5diffdebug2("diff_datum string size:%d\n",size2);
|
h5diffdebug2("diff_datum string size:%d\n",size2);
|
||||||
if(size1 != size2)
|
if(size1 != size2) {
|
||||||
{
|
|
||||||
h5difftrace("diff_datum string sizes\n");
|
h5difftrace("diff_datum string sizes\n");
|
||||||
nfound++;
|
nfound++;
|
||||||
}
|
}
|
||||||
if(size1 < size2)
|
if(size1 < size2) {
|
||||||
{
|
|
||||||
size = size1;
|
size = size1;
|
||||||
s = s1;
|
s = s1;
|
||||||
|
sizex = size2;
|
||||||
|
sx = s2;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
size = size2;
|
size = size2;
|
||||||
s = s2;
|
s = s2;
|
||||||
|
sizex = size1;
|
||||||
|
sx = s1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for NULL pointer for string */
|
/* check for NULL pointer for string */
|
||||||
if(s!=NULL)
|
if(s!=NULL) {
|
||||||
{
|
|
||||||
/* try fast compare first */
|
/* try fast compare first */
|
||||||
if (HDmemcmp(s1, s2, size)==0)
|
if(HDmemcmp(s1, s2, size)==0) {
|
||||||
break;
|
if(size1 != size2)
|
||||||
|
if(print_data(options))
|
||||||
pad = H5Tget_strpad(m_type);
|
for (u=size; u<sizex; u++)
|
||||||
|
character_compare(
|
||||||
for (u=0; u<size; u++)
|
s1 + u,
|
||||||
nfound+=character_compare(
|
s2 + u, /* offset */
|
||||||
s1 + u,
|
i, /* index position */
|
||||||
s2 + u, /* offset */
|
u, /* string character position */
|
||||||
i, /* index position */
|
rank,
|
||||||
u, /* string character position */
|
dims,
|
||||||
rank,
|
acc,
|
||||||
dims,
|
pos,
|
||||||
acc,
|
options,
|
||||||
pos,
|
obj1,
|
||||||
options,
|
obj2,
|
||||||
obj1,
|
ph);
|
||||||
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:
|
case H5T_BITFIELD:
|
||||||
|
h5difftrace("diff_datum H5T_BITFIELD\n");
|
||||||
|
|
||||||
/* byte-by-byte comparison */
|
/* byte-by-byte comparison */
|
||||||
for (u=0; u<type_size; u++)
|
for (u=0; u<type_size; u++)
|
||||||
@@ -764,7 +795,7 @@ static hsize_t diff_datum(void *_mem1,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
case H5T_OPAQUE:
|
case H5T_OPAQUE:
|
||||||
|
h5difftrace("diff_datum H5T_OPAQUE\n");
|
||||||
/* byte-by-byte comparison */
|
/* byte-by-byte comparison */
|
||||||
for (u=0; u<type_size; u++)
|
for (u=0; u<type_size; u++)
|
||||||
nfound+=character_compare_opt(
|
nfound+=character_compare_opt(
|
||||||
@@ -788,6 +819,7 @@ static hsize_t diff_datum(void *_mem1,
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
case H5T_ENUM:
|
case H5T_ENUM:
|
||||||
|
h5difftrace("diff_datum H5T_ENUM\n");
|
||||||
|
|
||||||
/* For enumeration types we compare the names instead of the
|
/* For enumeration types we compare the names instead of the
|
||||||
integer values. For each pair of elements being
|
integer values. For each pair of elements being
|
||||||
|
|||||||
Reference in New Issue
Block a user