mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-11 16:01:00 +08:00
[svn-r7804] Purpose:
h5diff new feature Description: added diff for the class ENUM Solution: Platforms tested: linux solaris 2.7 IRIX Misc. update:
This commit is contained in:
parent
0b8b8df0e0
commit
61d964625e
@ -74,7 +74,7 @@ int write_dataset( hid_t loc_id, int rank, hsize_t *dims, const char *dset_name,
|
||||
|
||||
/* Write the buf */
|
||||
if ( buf )
|
||||
assert(H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)>=0);
|
||||
H5Dwrite(dataset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf);
|
||||
|
||||
/* Close */
|
||||
status = H5Dclose(dataset_id);
|
||||
|
@ -175,21 +175,20 @@ int diff_array_mem( void *_mem1,
|
||||
{
|
||||
char fmt_llong[255], fmt_ullong[255];
|
||||
char fmt_llongp[255], fmt_ullongp[255];
|
||||
size_t type_size;
|
||||
static int ph=1; /* print header */
|
||||
int nfound=0; /* differences found */
|
||||
hsize_t dims[H5S_MAX_RANK];
|
||||
unsigned char *mem1 = (unsigned char*)_mem1;
|
||||
unsigned char *mem2 = (unsigned char*)_mem2;
|
||||
unsigned u;
|
||||
hid_t memb_type;
|
||||
size_t type_size;
|
||||
size_t offset;
|
||||
int nmembs;
|
||||
int j;
|
||||
hsize_t dims[H5S_MAX_RANK];
|
||||
hsize_t nelmts;
|
||||
hsize_t ndims;
|
||||
size_t size;
|
||||
|
||||
static int ph=1; /* print header */
|
||||
int nfound=0; /* differences found */
|
||||
|
||||
/* Build default formats for long long types */
|
||||
sprintf(fmt_llong, "%%%sd %%%sd %%%sd\n",
|
||||
@ -271,13 +270,35 @@ int diff_array_mem( void *_mem1,
|
||||
break;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* H5T_BITFIELD, H5T_OPAQUE, H5T_ENUM
|
||||
* H5T_BITFIELD
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
case H5T_BITFIELD:
|
||||
case H5T_OPAQUE:
|
||||
case H5T_ENUM:
|
||||
{
|
||||
/* byte-by-byte comparison */
|
||||
for (u=0; u<type_size; u++)
|
||||
nfound+=diff_native_uchar(
|
||||
mem1 + u,
|
||||
mem2 + u, /* offset */
|
||||
type_size,
|
||||
u,
|
||||
rank,
|
||||
acc,
|
||||
pos,
|
||||
options,
|
||||
obj1,
|
||||
obj2,
|
||||
ph);
|
||||
|
||||
}
|
||||
break;
|
||||
/*-------------------------------------------------------------------------
|
||||
* H5T_OPAQUE
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
case H5T_OPAQUE:
|
||||
|
||||
/* byte-by-byte comparison */
|
||||
for (u=0; u<type_size; u++)
|
||||
nfound+=diff_native_uchar(
|
||||
mem1 + u,
|
||||
@ -292,6 +313,48 @@ int diff_array_mem( void *_mem1,
|
||||
obj2,
|
||||
ph);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* H5T_ENUM
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
case H5T_ENUM:
|
||||
|
||||
/* For enumeration types we compare the names instead of the
|
||||
integer values. For each pair of elements being
|
||||
compared, we convert both bit patterns to their corresponding
|
||||
enumeration constant and do a string comparison */
|
||||
|
||||
{
|
||||
char enum_name1[1024];
|
||||
char enum_name2[1024];
|
||||
|
||||
if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) &&
|
||||
(H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0))
|
||||
{
|
||||
if (HDstrcmp(enum_name1,enum_name2)!=0)
|
||||
nfound=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (u=0; u<type_size; u++)
|
||||
nfound+=diff_native_uchar(
|
||||
mem1 + u,
|
||||
mem2 + u, /* offset */
|
||||
type_size,
|
||||
u,
|
||||
rank,
|
||||
acc,
|
||||
pos,
|
||||
options,
|
||||
obj1,
|
||||
obj2,
|
||||
ph);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -1278,8 +1341,7 @@ int diff_array_mem( void *_mem1,
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: diff_native_uchar
|
||||
*
|
||||
* Purpose: compare H5T_NATIVE_UCHAR (used in H5T_NATIVE_UCHAR
|
||||
* and H5T_STRING class)
|
||||
* Purpose: do a byte-by-byte comparison
|
||||
*
|
||||
* Return: number of differences found
|
||||
*
|
||||
|
@ -65,7 +65,7 @@ int diff_dataset( hid_t file1_id,
|
||||
int can1, can2; /* supported diff */
|
||||
hsize_t storage_size1;
|
||||
hsize_t storage_size2;
|
||||
int i;
|
||||
int i, gout=0;
|
||||
|
||||
|
||||
/* disable error reporting */
|
||||
@ -80,15 +80,17 @@ int diff_dataset( hid_t file1_id,
|
||||
if ( (dset1_id = H5Dopen(file1_id,obj1_name)) < 0 )
|
||||
{
|
||||
printf("Cannot open dataset <%s>\n", obj1_name );
|
||||
goto out;
|
||||
gout=1;
|
||||
}
|
||||
if ( (dset2_id = H5Dopen(file2_id,obj2_name)) < 0 )
|
||||
{
|
||||
printf("Cannot open dataset <%s>\n", obj2_name );
|
||||
goto out;
|
||||
gout=1;
|
||||
}
|
||||
/* enable error reporting */
|
||||
} H5E_END_TRY;
|
||||
if (gout)
|
||||
goto out;
|
||||
|
||||
/* Get the dataspace handle */
|
||||
if ( (space1_id = H5Dget_space(dset1_id)) < 0 )
|
||||
@ -373,13 +375,13 @@ int diff_dataset( hid_t file1_id,
|
||||
{
|
||||
if ( m_size1 < m_size2 )
|
||||
{
|
||||
assert( (H5Tclose(m_type1)) >=0);
|
||||
H5Tclose(m_type1);
|
||||
m_type1 = H5Tget_native_type( f_type2 , H5T_DIR_DEFAULT);
|
||||
m_size1 = H5Tget_size( m_type1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( (H5Tclose(m_type2)) >=0);
|
||||
H5Tclose(m_type2);
|
||||
m_type2 = H5Tget_native_type( f_type1 , H5T_DIR_DEFAULT);
|
||||
m_size2 = H5Tget_size( m_type2 );
|
||||
}
|
||||
@ -434,15 +436,19 @@ out:
|
||||
if ( buf1) HDfree(buf1);
|
||||
if ( buf2) HDfree(buf2);
|
||||
|
||||
/* Close */
|
||||
if ( dset1_id!=-1 ) assert( (H5Dclose(dset1_id)) >=0);
|
||||
if ( dset2_id!=-1 ) assert( (H5Dclose(dset2_id)) >=0);
|
||||
if ( space1_id!=-1 ) assert( (H5Sclose(space1_id)) >=0);
|
||||
if ( space2_id!=-1 ) assert( (H5Sclose(space2_id)) >=0);
|
||||
if ( f_type1!=-1 ) assert( (H5Tclose(f_type1)) >=0);
|
||||
if ( f_type2!=-1 ) assert( (H5Tclose(f_type2)) >=0);
|
||||
if ( m_type1!=-1 ) assert( (H5Tclose(m_type1)) >=0);
|
||||
if ( m_type2!=-1 ) assert( (H5Tclose(m_type2)) >=0);
|
||||
/* close */
|
||||
/* disable error reporting */
|
||||
H5E_BEGIN_TRY {
|
||||
H5Dclose(dset1_id);
|
||||
H5Dclose(dset2_id);
|
||||
H5Sclose(space1_id);
|
||||
H5Sclose(space2_id);
|
||||
H5Tclose(f_type1);
|
||||
H5Tclose(f_type2);
|
||||
H5Tclose(m_type1);
|
||||
H5Tclose(m_type2);
|
||||
/* enable error reporting */
|
||||
} H5E_END_TRY;
|
||||
|
||||
return nfound;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user