summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-07 17:06:42 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-07 17:06:42 (GMT)
commitde285fb90913bdc8a67f9a226de1b3d7ebd805db (patch)
treef484dd0c05c936beca33094365fbb956071e6a7c
parentc17b59ac25391c0f8ad5d5778c07c2185c3cea2c (diff)
downloadhdf5-de285fb90913bdc8a67f9a226de1b3d7ebd805db.zip
hdf5-de285fb90913bdc8a67f9a226de1b3d7ebd805db.tar.gz
hdf5-de285fb90913bdc8a67f9a226de1b3d7ebd805db.tar.bz2
[svn-r12875] Description:
Fix retrieving name for references to root group. Also, move 'ref' test earlier in testing, right after 'getname' test Tested on: Linux/64 2.6 (chicago2)
-rw-r--r--src/H5Gname.c17
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in8
-rw-r--r--test/getname.c6
-rw-r--r--test/links.c2
-rw-r--r--test/ref.c14
6 files changed, 35 insertions, 16 deletions
diff --git a/src/H5Gname.c b/src/H5Gname.c
index 944456a..b4c3db9 100644
--- a/src/H5Gname.c
+++ b/src/H5Gname.c
@@ -52,6 +52,7 @@ typedef struct H5G_ref_path_iter_t {
/* In */
hid_t file; /* File id where it came from */
hid_t dxpl_id; /* DXPL for operations */
+ hbool_t is_root_group; /* Flag to indicate that the root group is being looked at */
const H5O_loc_t *loc; /* The location of the object we're looking for */
/* In/Out */
@@ -1115,7 +1116,10 @@ H5G_refname_iterator(hid_t group, const char *name, void *_udata)
len = HDstrlen(udata->container);
if(NULL == (udata->container = H5MM_realloc(udata->container, HDstrlen(udata->container) + HDstrlen(name) + 2)))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate path string")
- HDstrcat(udata->container, name);
+ if(!udata->is_root_group)
+ HDstrcat(udata->container, name);
+ else
+ udata->is_root_group = FALSE;
HDstrcat(udata->container, "/");
ret_value = H5G_obj_iterate(udata->file, udata->container, H5_ITER_INC, 0, &last_obj, H5G_refname_iterator, udata, udata->dxpl_id);
@@ -1183,7 +1187,7 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc,
char *name, size_t size)
{
H5G_ref_path_iter_t udata; /* User data for iteration */
- int last_obj = 0; /* Start object for iteration */
+ herr_t status; /* Status from iteration */
ssize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_get_refobj_name)
@@ -1191,7 +1195,8 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc,
/* Set up user data for iterator */
udata.file = file;
udata.dxpl_id = dxpl_id;
- if(NULL == (udata.container = H5MM_strdup("/")))
+ udata.is_root_group = TRUE;
+ if(NULL == (udata.container = H5MM_strdup("")))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate root group name")
udata.loc = loc;
@@ -1200,9 +1205,9 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc,
HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create skip list for path nodes")
/* Iterate over all the objects in the file */
- if((ret_value = H5G_obj_iterate(file, "/", H5_ITER_INC, 0, &last_obj, H5G_refname_iterator, &udata, dxpl_id)) < 0)
+ if((status = H5G_refname_iterator(file, "/", &udata)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed while looking for object name")
- else if(ret_value > 0) {
+ else if(status > 0) {
/* Set the length of the full path */
ret_value = HDstrlen(udata.container) + 1;
@@ -1213,6 +1218,8 @@ H5G_get_refobj_name(hid_t file, hid_t dxpl_id, const H5O_loc_t *loc,
name[size - 1] = '\0';
} /* end if */
} /* end if */
+ else
+ ret_value = 0;
done:
H5MM_xfree(udata.container);
diff --git a/test/Makefile.am b/test/Makefile.am
index b311e40..450d28e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -40,8 +40,8 @@ TEST_PROG=testhdf5 lheap ohdr stab gheap cache cache_api \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 enum \
set_extent ttsafe stream_test \
- getname vfd ntypes dangle dtransform reserved cross_read \
- btree2 fheap ref
+ getname ref vfd ntypes dangle dtransform reserved cross_read \
+ btree2 fheap
# List programs to be built when testing here. error_test and err_compat are
# built at the same time as the other tests, but executed by testerror.sh.
diff --git a/test/Makefile.in b/test/Makefile.in
index ee2a028..082bf2f 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -82,9 +82,9 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
unlink$(EXEEXT) big$(EXEEXT) mtime$(EXEEXT) fillval$(EXEEXT) \
mount$(EXEEXT) flush1$(EXEEXT) flush2$(EXEEXT) enum$(EXEEXT) \
set_extent$(EXEEXT) ttsafe$(EXEEXT) stream_test$(EXEEXT) \
- getname$(EXEEXT) vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
+ getname$(EXEEXT) ref$(EXEEXT) vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \
- btree2$(EXEEXT) fheap$(EXEEXT) ref$(EXEEXT)
+ btree2$(EXEEXT) fheap$(EXEEXT)
am__EXEEXT_2 = gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \
gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \
gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \
@@ -632,8 +632,8 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 enum \
set_extent ttsafe stream_test \
- getname vfd ntypes dangle dtransform reserved cross_read \
- btree2 fheap ref
+ getname ref vfd ntypes dangle dtransform reserved cross_read \
+ btree2 fheap
# These programs generate test files for the tests. They don't need to be
diff --git a/test/getname.c b/test/getname.c
index 07e7bcf..5a6c176 100644
--- a/test/getname.c
+++ b/test/getname.c
@@ -818,7 +818,7 @@ int main( void )
/* Verify */
if(check_name(group_id, "/g14/g3/g4", "") < 0) TEST_ERROR;
- if(check_name(group2_id, "", "") < 0) TEST_ERROR;
+ if(check_name(group2_id, "/", "") < 0) TEST_ERROR;
/* Close */
H5Gclose( group_id );
@@ -860,7 +860,7 @@ int main( void )
if (H5Funmount(group2_id, ".")<0) TEST_ERROR;
/* Verify */
- if(check_name(group2_id, "", "") < 0) TEST_ERROR;
+ if(check_name(group2_id, "/", "") < 0) TEST_ERROR;
/* Close */
H5Gclose( group2_id );
@@ -902,7 +902,7 @@ int main( void )
if (H5Funmount(group2_id, ".")<0) TEST_ERROR;
/* Verify */
- if(check_name(group2_id, "", "") < 0) TEST_ERROR;
+ if(check_name(group2_id, "/", "") < 0) TEST_ERROR;
if(check_name(group3_id, "/g13/g1", "/g13/g1") < 0) TEST_ERROR;
/* Close */
diff --git a/test/links.c b/test/links.c
index 64ef6c0..9fa4221 100644
--- a/test/links.c
+++ b/test/links.c
@@ -1626,7 +1626,7 @@ external_link_root(hid_t fapl, hbool_t new_format)
/* Check name */
if((name_len = H5Iget_name( gid, objname, (size_t)NAME_BUF_SIZE )) < 0) TEST_ERROR
- if(name_len != 0) TEST_ERROR
+ if(HDstrcmp(objname, "/")) TEST_ERROR
/* Create object in external file */
if((gid2 = H5Gcreate(gid, "new_group", (size_t)0)) < 0) TEST_ERROR
diff --git a/test/ref.c b/test/ref.c
index c31f987..3ed7654 100644
--- a/test/ref.c
+++ b/test/ref.c
@@ -34,7 +34,7 @@
/* 1-D dataset with fixed dimensions */
#define SPACE1_RANK 1
-#define SPACE1_DIM1 7
+#define SPACE1_DIM1 8
int
main(void)
@@ -184,6 +184,10 @@ main(void)
if(H5Rcreate(&wbuf[6], fid1, "/Group1/Group2/Link/Dataset5", H5R_OBJECT, -1) < 0)
TEST_ERROR
+ /* Create reference to root group */
+ if(H5Rcreate(&wbuf[7], fid1, "/", H5R_OBJECT, -1) < 0)
+ TEST_ERROR
+
/* Write selection to disk */
if(H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf) < 0)
TEST_ERROR
@@ -243,6 +247,14 @@ main(void)
else
TEST_ERROR
+ HDmemset(buf, 0, 100);
+ TESTING("getting path to root group");
+ i = H5Iget_name(H5Rdereference(dataset, H5R_OBJECT , &wbuf[7]), (char*)buf, 100);
+ if((HDstrcmp(buf, "/") == 0) && (i == 2))
+ PASSED()
+ else
+ TEST_ERROR
+
/* Now we mount fid2 at /Group2 and look for dataset4. It shouldn't be found */
if(H5Fmount(fid1, "/Group1/Group2", fid2, H5P_DEFAULT) < 0)
TEST_ERROR