summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-06-04 00:17:27 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-06-04 00:17:27 (GMT)
commitb75540244fb313f179fe11c587e5e008677e6762 (patch)
treeb47e892c9d3bf61ff544169df1c7a3489f8b3a14 /tools/lib
parent771bae88881f4ae8102c9553fd10e0938aa3094c (diff)
downloadhdf5-b75540244fb313f179fe11c587e5e008677e6762.zip
hdf5-b75540244fb313f179fe11c587e5e008677e6762.tar.gz
hdf5-b75540244fb313f179fe11c587e5e008677e6762.tar.bz2
[svn-r15133] Description:
Fixed bug in h5ls that prevented relative group listings (like "h5ls foo.h5/bar") from working correctly. Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.5.3 (amazon) in debug mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5trav.c45
1 files changed, 14 insertions, 31 deletions
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 14ced60..0ed6a30 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -39,6 +39,7 @@ typedef struct {
typedef struct {
trav_addr_t *seen; /* List of addresses seen already */
const trav_visitor_t *visitor; /* Information for visiting each link/object */
+ hbool_t is_absolute; /* Whether the traversal has absolute paths */
} trav_ud_traverse_t;
typedef struct {
@@ -139,13 +140,19 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
void *_udata)
{
trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */
- char *full_name;
+ char *new_name = NULL;
+ const char *full_name;
const char *already_visited = NULL; /* Whether the link/object was already visited */
/* Create the full path name for the link */
- full_name = HDmalloc(HDstrlen(path) + 2);
- *full_name = '/';
- HDstrcpy(full_name + 1, path);
+ if(udata->is_absolute) {
+ new_name = HDmalloc(HDstrlen(path) + 2);
+ *new_name = '/';
+ HDstrcpy(new_name + 1, path);
+ full_name = new_name;
+ } /* end if */
+ else
+ full_name = path;
/* Perform the correct action for different types of links */
if(linfo->type == H5L_TYPE_HARD) {
@@ -172,7 +179,8 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
(*udata->visitor->visit_lnk)(full_name, linfo, udata->visitor->udata);
} /* end else */
- HDfree(full_name);
+ if(new_name)
+ HDfree(new_name);
return(H5_ITER_CONT);
} /* end traverse_cb() */
@@ -222,6 +230,7 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
/* Set up user data structure */
udata.seen = &seen;
udata.visitor = visitor;
+ udata.is_absolute = (*grp_name == '/');
/* Check for iteration of links vs. visiting all links recursively */
if(recurse) {
@@ -582,32 +591,6 @@ h5trav_getindext(const char *name, const trav_table_t *table)
}
/*-------------------------------------------------------------------------
- * Function: trav_table_search
- *
- * Purpose: Search in the table for OBJNO
- *
- * Return: index of object in table
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: November 4, 2002
- *
- *-------------------------------------------------------------------------
- */
-
-static size_t
-trav_table_search(const trav_table_t *table, haddr_t objno)
-{
- size_t i;
-
- for(i = 0; i < table->nobjs; i++)
- if(table->objs[i].objno == objno)
- return(i);
- return(i);
-}
-
-
-/*-------------------------------------------------------------------------
* Function: trav_table_add
*
* Purpose: Add OBJNO, NAME and TYPE of object to table