summaryrefslogtreecommitdiffstats
path: root/src/H5Gname.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-02-10 19:48:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-02-10 19:48:08 (GMT)
commit5f94d17285913b2497d169cadfb639f300773407 (patch)
treef4a96b86d8ac5d13411ca897e1377fb2f1808cb3 /src/H5Gname.c
parentf16098f402139aa4e258542661c3003389803de9 (diff)
downloadhdf5-5f94d17285913b2497d169cadfb639f300773407.zip
hdf5-5f94d17285913b2497d169cadfb639f300773407.tar.gz
hdf5-5f94d17285913b2497d169cadfb639f300773407.tar.bz2
[svn-r21925] Description:
Bring r21919-21924 from trunk to 1.8 branch: cleanup FUNC_ENTER macros, etc. Also removed Subversion mergeinfo tags from a few directories and files. These are artifacts from non-root merges using pre-1.6 Subversion clients. (This should fix the problem of unchanged directories looking "changed" during checkins.) Tested on: Mac OSX/64 10.7.3 (amazon) w/debug & production (daily tested on trunk)
Diffstat (limited to 'src/H5Gname.c')
-rw-r--r--src/H5Gname.c144
1 files changed, 121 insertions, 23 deletions
diff --git a/src/H5Gname.c b/src/H5Gname.c
index 18723a9..25639f2d 100644
--- a/src/H5Gname.c
+++ b/src/H5Gname.c
@@ -113,6 +113,104 @@ H5FL_BLK_EXTERN(str_buf);
/*-------------------------------------------------------------------------
+ * Function: H5G__component
+ *
+ * Purpose: Returns the pointer to the first component of the
+ * specified name by skipping leading slashes. Returns
+ * the size in characters of the component through SIZE_P not
+ * counting leading slashes or the null terminator.
+ *
+ * Return: Success: Ptr into NAME.
+ *
+ * Failure: Ptr to the null terminator of NAME.
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 11 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+const char *
+H5G__component(const char *name, size_t *size_p)
+{
+ FUNC_ENTER_PACKAGE_NOERR
+
+ assert(name);
+
+ while ('/' == *name)
+ name++;
+ if (size_p)
+ *size_p = HDstrcspn(name, "/");
+
+ FUNC_LEAVE_NOAPI(name)
+} /* end H5G__component() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_normalize
+ *
+ * Purpose: Returns a pointer to a new string which has duplicate and
+ * trailing slashes removed from it.
+ *
+ * Return: Success: Ptr to normalized name.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, August 16, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+char *
+H5G_normalize(const char *name)
+{
+ char *norm; /* Pointer to the normalized string */
+ size_t s,d; /* Positions within the strings */
+ unsigned last_slash; /* Flag to indicate last character was a slash */
+ char *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Sanity check */
+ HDassert(name);
+
+ /* Duplicate the name, to return */
+ if(NULL == (norm = H5MM_strdup(name)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string")
+
+ /* Walk through the characters, omitting duplicated '/'s */
+ s = d = 0;
+ last_slash = 0;
+ while(name[s] != '\0') {
+ if(name[s] == '/')
+ if(last_slash)
+ ;
+ else {
+ norm[d++] = name[s];
+ last_slash = 1;
+ } /* end else */
+ else {
+ norm[d++] = name[s];
+ last_slash = 0;
+ } /* end else */
+ s++;
+ } /* end while */
+
+ /* Terminate normalized string */
+ norm[d] = '\0';
+
+ /* Check for final '/' on normalized name & eliminate it */
+ if(d > 1 && last_slash)
+ norm[d - 1] = '\0';
+
+ /* Set return value */
+ ret_value = norm;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_normalize() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5G_common_path
*
* Purpose: Determine if one path is a valid prefix of another path
@@ -134,16 +232,16 @@ H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r)
size_t nchars1,nchars2; /* Number of characters in components */
htri_t ret_value=FALSE; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_common_path)
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Get component of each name */
fullpath=H5RS_get_str(fullpath_r);
assert(fullpath);
- fullpath=H5G_component(fullpath,&nchars1);
+ fullpath=H5G__component(fullpath,&nchars1);
assert(fullpath);
prefix=H5RS_get_str(prefix_r);
assert(prefix);
- prefix=H5G_component(prefix,&nchars2);
+ prefix=H5G__component(prefix,&nchars2);
assert(prefix);
/* Check if we have a real string for each component */
@@ -157,9 +255,9 @@ H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r)
prefix+=nchars2;
/* Get next component of each name */
- fullpath=H5G_component(fullpath,&nchars1);
+ fullpath=H5G__component(fullpath,&nchars1);
assert(fullpath);
- prefix=H5G_component(prefix,&nchars2);
+ prefix=H5G__component(prefix,&nchars2);
assert(prefix);
} /* end if */
else
@@ -199,7 +297,7 @@ H5G_build_fullpath(const char *prefix, const char *name)
unsigned need_sep; /* Flag to indicate if separator is needed */
H5RS_str_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_build_fullpath)
+ FUNC_ENTER_NOAPI_NOINIT
/* Sanity check */
HDassert(prefix);
@@ -255,7 +353,7 @@ H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name)
const char *prefix; /* Pointer to raw string for path */
H5RS_str_t *ret_value;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_build_fullpath_refstr_str)
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(prefix_r);
HDassert(name);
@@ -293,7 +391,7 @@ H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *n
const char *name; /* Pointer to raw string of name */
H5RS_str_t *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_build_fullpath_refstr_refstr)
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Get the pointer to the prefix */
prefix = H5RS_get_str(prefix_r);
@@ -310,7 +408,7 @@ H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *n
/*-------------------------------------------------------------------------
- * Function: H5G_name_init
+ * Function: H5G__name_init
*
* Purpose: Set the initial path for a group hierarchy name
*
@@ -323,9 +421,9 @@ H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *n
*-------------------------------------------------------------------------
*/
herr_t
-H5G_name_init(H5G_name_t *name, const char *path)
+H5G__name_init(H5G_name_t *name, const char *path)
{
- FUNC_ENTER_NOAPI_NOFUNC(H5G_name_init)
+ FUNC_ENTER_PACKAGE
/* Check arguments */
HDassert(name);
@@ -338,7 +436,7 @@ H5G_name_init(H5G_name_t *name, const char *path)
name->obj_hidden = 0;
FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5G_name_init() */
+} /* end H5G__name_init() */
/*-------------------------------------------------------------------------
@@ -355,11 +453,11 @@ H5G_name_init(H5G_name_t *name, const char *path)
*-------------------------------------------------------------------------
*/
herr_t
-H5G_name_set(H5G_name_t *loc, H5G_name_t *obj, const char *name)
+H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name)
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5G_name_set, FAIL)
+ FUNC_ENTER_NOAPI(FAIL)
HDassert(loc);
HDassert(obj);
@@ -413,7 +511,7 @@ done:
herr_t
H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth)
{
- FUNC_ENTER_NOAPI_NOFUNC(H5G_name_copy)
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check arguments */
HDassert(src);
@@ -466,7 +564,7 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size,
ssize_t len = 0; /* Length of object's name */
ssize_t ret_value; /* Return value */
- FUNC_ENTER_NOAPI(H5G_get_name, FAIL)
+ FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(loc);
@@ -533,7 +631,7 @@ done:
herr_t
H5G_name_reset(H5G_name_t *name)
{
- FUNC_ENTER_NOAPI_NOFUNC(H5G_name_reset)
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check arguments */
HDassert(name);
@@ -561,7 +659,7 @@ H5G_name_reset(H5G_name_t *name)
herr_t
H5G_name_free(H5G_name_t *name)
{
- FUNC_ENTER_NOAPI_NOFUNC(H5G_name_free)
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Check args */
HDassert(name);
@@ -602,7 +700,7 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char
size_t full_suffix_len; /* Length of full suffix */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_name_move_path)
+ FUNC_ENTER_NOAPI_NOINIT
/* Check arguments */
HDassert(path_r_ptr && *path_r_ptr);
@@ -704,7 +802,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
hbool_t obj_in_child = FALSE; /* Flag to indicate that the object is in the child mount hier. */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_name_replace_cb)
+ FUNC_ENTER_NOAPI_NOINIT
HDassert(obj_ptr);
@@ -972,7 +1070,7 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file,
{
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI(H5G_name_replace, FAIL)
+ FUNC_ENTER_NOAPI(FAIL)
/* Check arguments */
HDassert(src_file);
@@ -1110,7 +1208,7 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo,
hbool_t obj_found = FALSE; /* Object at 'path' found */
herr_t ret_value = H5_ITER_CONT; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5G_get_name_by_addr_cb)
+ FUNC_ENTER_NOAPI_NOINIT
/* Sanity check */
HDassert(path);
@@ -1183,7 +1281,7 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t *
/* Portably clear udata struct (before FUNC_ENTER) */
HDmemset(&udata, 0, sizeof(udata));
- FUNC_ENTER_NOAPI(H5G_get_name_by_addr, FAIL)
+ FUNC_ENTER_NOAPI(FAIL)
/* Construct the link info for the file's root group */
if(H5G_loc(file, &root_loc) < 0)