summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-07-03 12:45:44 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-07-03 12:45:44 (GMT)
commitc539c9c1cd9d62fc00b344cf920877725f32dd5c (patch)
treec990c3cca870e0185a086a42ef83e27ac60e51b8 /generic
parentff3de97d45c59dedd83ed8d0fe35c5928b34f85d (diff)
parentf7a562e6ef980a33224b0f7f578e9b4b0c0280c0 (diff)
downloadtcl-c539c9c1cd9d62fc00b344cf920877725f32dd5c.zip
tcl-c539c9c1cd9d62fc00b344cf920877725f32dd5c.tar.gz
tcl-c539c9c1cd9d62fc00b344cf920877725f32dd5c.tar.bz2
merge core-8-6-branch
Diffstat (limited to 'generic')
-rw-r--r--generic/tclPathObj.c58
1 files changed, 26 insertions, 32 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 5984c16..211976e 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -849,18 +849,18 @@ TclJoinPath(
int elements,
Tcl_Obj * const objv[])
{
- Tcl_Obj *res;
+ Tcl_Obj *res = NULL; /* Resulting path object (container of join) */
+ Tcl_Obj *elt; /* Path part (result if returns part of path) */
int i;
const Tcl_Filesystem *fsPtr = NULL;
- res = NULL;
-
for (i = 0; i < elements; i++) {
int driveNameLength, strEltLen, length;
Tcl_PathType type;
char *strElt, *ptr;
Tcl_Obj *driveName = NULL;
- Tcl_Obj *elt = objv[i];
+
+ elt = objv[i];
/*
* This is a special case where we can be much more efficient, where
@@ -893,10 +893,7 @@ TclJoinPath(
* the base itself is just fine!
*/
- if (res != NULL) {
- TclDecrRefCount(res);
- }
- return elt;
+ goto partReturn; /* return elt; */
}
/*
@@ -917,20 +914,20 @@ TclJoinPath(
*/
if ((tclPlatform != TCL_PLATFORM_WINDOWS)
- || (strchr(Tcl_GetString(elt), '\\') == NULL)) {
- if (res != NULL) {
- TclDecrRefCount(res);
- }
-
+ || (strchr(Tcl_GetString(elt), '\\') == NULL)
+ ) {
if (PATHFLAGS(elt)) {
- return TclNewFSPathObj(elt, str, len);
+ elt = TclNewFSPathObj(elt, str, len);
+ goto partReturn; /* return elt; */
}
if (TCL_PATH_ABSOLUTE != Tcl_FSGetPathType(elt)) {
- return TclNewFSPathObj(elt, str, len);
+ elt = TclNewFSPathObj(elt, str, len);
+ goto partReturn; /* return elt; */
}
(void) Tcl_FSGetNormalizedPath(NULL, elt);
if (elt == PATHOBJ(elt)->normPathPtr) {
- return TclNewFSPathObj(elt, str, len);
+ elt = TclNewFSPathObj(elt, str, len);
+ goto partReturn; /* return elt; */
}
}
}
@@ -940,19 +937,15 @@ TclJoinPath(
* more general code below handle things.
*/
} else if (tclPlatform == TCL_PLATFORM_UNIX) {
- if (res != NULL) {
- TclDecrRefCount(res);
- }
- return tailObj;
+ elt = tailObj;
+ goto partReturn; /* return elt; */
} else {
const char *str = TclGetString(tailObj);
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
if (strchr(str, '\\') == NULL) {
- if (res != NULL) {
- TclDecrRefCount(res);
- }
- return tailObj;
+ elt = tailObj;
+ goto partReturn; /* return elt; */
}
}
}
@@ -1031,16 +1024,12 @@ TclJoinPath(
}
ptr++;
}
- if (res != NULL) {
- TclDecrRefCount(res);
- }
-
/*
* This element is just what we want to return already; no further
* manipulation is requred.
*/
- return elt;
+ goto partReturn; /* return elt; */
}
/*
@@ -1051,10 +1040,8 @@ TclJoinPath(
noQuickReturn:
if (res == NULL) {
res = Tcl_NewObj();
- ptr = TclGetStringFromObj(res, &length);
- } else {
- ptr = TclGetStringFromObj(res, &length);
}
+ ptr = TclGetStringFromObj(res, &length);
/*
* Strip off any './' before a tilde, unless this is the beginning of
@@ -1087,6 +1074,7 @@ TclJoinPath(
if (sep != NULL) {
separator = TclGetString(sep)[0];
+ TclDecrRefCount(sep);
}
/* Safety check in case the VFS driver caused sharing */
if (Tcl_IsShared(res)) {
@@ -1126,6 +1114,12 @@ TclJoinPath(
res = Tcl_NewObj();
}
return res;
+
+partReturn:
+ if (res != NULL) {
+ TclDecrRefCount(res);
+ }
+ return elt;
}
/*