summaryrefslogtreecommitdiffstats
path: root/generic/tclFileName.c
diff options
context:
space:
mode:
authorkjnash <k.j.nash@usa.net>2022-08-31 14:28:57 (GMT)
committerkjnash <k.j.nash@usa.net>2022-08-31 14:28:57 (GMT)
commit19f8c3bb6b2aa8d571a7534b588ddacfb49952d3 (patch)
tree5051f34456c20c798d30e7741fae52575927fd7a /generic/tclFileName.c
parentd9b5be0959a8ee2b81ba519ff3d4c70b2da9a6ce (diff)
parentff1e919a1bae9ff88ab6dbc094b18cfadedfe8af (diff)
downloadtcl-19f8c3bb6b2aa8d571a7534b588ddacfb49952d3.zip
tcl-19f8c3bb6b2aa8d571a7534b588ddacfb49952d3.tar.gz
tcl-19f8c3bb6b2aa8d571a7534b588ddacfb49952d3.tar.bz2
Merge old 8.7 674a6ad0472c7
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r--generic/tclFileName.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index 187003d..c3f3bf0 100644
--- a/generic/tclFileName.c
+++ b/generic/tclFileName.c
@@ -587,7 +587,8 @@ Tcl_SplitPath(
* plus the argv pointers and the terminating NULL pointer.
*/
- *argvPtr = (const char **)ckalloc((((*argcPtr) + 1) * sizeof(char *)) + size);
+ *argvPtr = (const char **)ckalloc(
+ ((((*argcPtr) + 1) * sizeof(char *)) + size));
/*
* Position p after the last argv pointer and copy the contents of the
@@ -644,12 +645,13 @@ SplitUnixPath(
{
int length;
const char *origPath = path, *elementStart;
- Tcl_Obj *result = Tcl_NewObj();
+ Tcl_Obj *result;
/*
* Deal with the root directory as a special case.
*/
+ TclNewObj(result);
if (*path == '/') {
Tcl_Obj *rootElt;
++path;
@@ -735,9 +737,10 @@ SplitWinPath(
const char *p, *elementStart;
Tcl_PathType type = TCL_PATH_ABSOLUTE;
Tcl_DString buf;
- Tcl_Obj *result = Tcl_NewObj();
+ Tcl_Obj *result;
Tcl_DStringInit(&buf);
+ TclNewObj(result);
p = ExtractWinRoot(path, &buf, 0, &type);
/*
@@ -977,7 +980,7 @@ Tcl_JoinPath(
Tcl_DString *resultPtr) /* Pointer to previously initialized DString */
{
int i, len;
- Tcl_Obj *listObj = Tcl_NewObj();
+ Tcl_Obj *listObj;
Tcl_Obj *resultObj;
const char *resultStr;
@@ -985,6 +988,7 @@ Tcl_JoinPath(
* Build the list of paths.
*/
+ TclNewObj(listObj);
for (i = 0; i < argc; i++) {
Tcl_ListObjAppendElement(NULL, listObj,
Tcl_NewStringObj(argv[i], -1));
@@ -1234,7 +1238,7 @@ Tcl_GlobObjCmd(
"-directory", "-join", "-nocomplain", "-path", "-tails",
"-types", "--", NULL
};
- enum options {
+ enum globOptionsEnum {
GLOB_DIR, GLOB_JOIN, GLOB_NOCOMPLAIN, GLOB_PATH, GLOB_TAILS,
GLOB_TYPE, GLOB_LAST
};
@@ -1267,7 +1271,7 @@ Tcl_GlobObjCmd(
}
}
- switch (index) {
+ switch ((enum globOptionsEnum) index) {
case GLOB_NOCOMPLAIN: /* -nocomplain */
globFlags |= TCL_GLOBMODE_NO_COMPLAIN;
break;
@@ -1280,7 +1284,10 @@ Tcl_GlobObjCmd(
}
if (dir != PATH_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "\"-directory\" cannot be used with \"-path\"", -1));
+ dir == PATH_DIR
+ ? "\"-directory\" may only be used once"
+ : "\"-directory\" cannot be used with \"-path\"",
+ -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB",
"BADOPTIONCOMBINATION", NULL);
return TCL_ERROR;
@@ -1305,7 +1312,10 @@ Tcl_GlobObjCmd(
}
if (dir != PATH_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "\"-path\" cannot be used with \"-directory\"", -1));
+ dir == PATH_GENERAL
+ ? "\"-path\" may only be used once"
+ : "\"-path\" cannot be used with \"-dictionary\"",
+ -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB",
"BADOPTIONCOMBINATION", NULL);
return TCL_ERROR;