From d3f2e1bdff0eb5276214270a4ead9a06d22febe7 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Wed, 4 Sep 2002 10:50:12 -0500 Subject: [svn-r5911] Purpose: bug fix in 'ID to name' function Description: the function replace_name was only checking for immutable datatypes Solution: added a new function H5T_is_named, that checks for named datatypes Platforms tested: windows 2000, linux, solaris with Fortran --- src/H5G.c | 13 +++++++------ src/H5T.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- src/H5Tprivate.h | 1 + 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/H5G.c b/src/H5G.c index 482a551..317c1e3 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -2594,6 +2594,8 @@ done: *------------------------------------------------------------------------- */ + + herr_t H5G_replace_name( int type, H5G_entry_t *loc, const char *src_name, const char *dst_name, int op ) { @@ -2774,15 +2776,15 @@ done: FUNC_ENTER_NOAPI(H5G_replace_ent, FAIL); assert(obj_ptr); - + /* avoid no named datatypes */ - if( names->obj_type==H5I_DATATYPE && H5T_is_immutable((H5T_t*)obj_ptr)) + if( names->obj_type==H5I_DATATYPE && !H5T_is_named((H5T_t*)obj_ptr)) { /* Do not exit loop */ ret_value = SUCCEED; goto done; } - + /* Get the symbol table entry */ switch(names->obj_type) { case H5I_GROUP: @@ -2800,9 +2802,8 @@ done: "unknown data object"); } - if( !ent) - goto done; - + assert( ent ); + /* Check if is a mounted file */ if(ent->file->mtab.parent) { diff --git a/src/H5T.c b/src/H5T.c index 08f10f0..5206e5a 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -7512,7 +7512,7 @@ done: /*------------------------------------------------------------------------- * Function: H5T_is_immutable * - * Purpose: Check is a datatype is immutable. + * Purpose: Check if a datatype is immutable. * * Return: TRUE * @@ -7522,6 +7522,9 @@ done: * Friday, Dec 7, 2001 * * Modifications: + * Pedro Vicente + * Tuesday, Sep 3, 2002 + * Added 'else' * *------------------------------------------------------------------------- */ @@ -7535,12 +7538,51 @@ H5T_is_immutable(H5T_t *dt) assert(dt); if(dt->state == H5T_STATE_IMMUTABLE) - ret_value = TRUE; + ret_value = TRUE; + else + ret_value = FALSE; + +done: + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5T_is_named + * + * Purpose: Check if a datatype is named. + * + * Return: TRUE + * + * FALSE + * + * Programmer: Pedro Vicente + * Tuesday, Sep 3, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +htri_t +H5T_is_named(H5T_t *dt) +{ + htri_t ret_value = FALSE; + + FUNC_ENTER_NOAPI(H5T_is_named, FAIL); + + assert(dt); + + if( dt->state == H5T_STATE_OPEN || dt->state == H5T_STATE_NAMED ) + ret_value = TRUE; + else + ret_value = FALSE; done: FUNC_LEAVE(ret_value); } + + /*-------------------------------------------------------------------------- NAME diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index ba09e93..60747ca 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -117,6 +117,7 @@ __DLL__ herr_t H5T_pack(H5T_t *dt); __DLL__ herr_t H5T_debug(const H5T_t *dt, FILE * stream); __DLL__ H5G_entry_t *H5T_entof(H5T_t *dt); __DLL__ htri_t H5T_is_immutable(H5T_t *dt); +__DLL__ htri_t H5T_is_named(H5T_t *dt); __DLL__ H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, H5T_conv_t func); __DLL__ herr_t H5T_sort_value(H5T_t *dt, int *map); -- cgit v0.12