summaryrefslogtreecommitdiffstats
path: root/generic/tclFileName.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclFileName.c')
-rw-r--r--generic/tclFileName.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index be1fdfa..b3879f7 100644
--- a/generic/tclFileName.c
+++ b/generic/tclFileName.c
@@ -578,7 +578,7 @@ Tcl_SplitPath(
* plus the argv pointers and the terminating NULL pointer.
*/
- *argvPtr = (const char **) ckalloc((unsigned)
+ *argvPtr = (const char **) ckalloc(
((((*argcPtr) + 1) * sizeof(char *)) + size));
/*
@@ -590,7 +590,7 @@ Tcl_SplitPath(
for (i = 0; i < *argcPtr; i++) {
Tcl_ListObjIndex(NULL, resultPtr, i, &eltPtr);
str = Tcl_GetStringFromObj(eltPtr, &len);
- memcpy(p, str, (size_t) len+1);
+ memcpy(p, str, len + 1);
p += len+1;
}
@@ -636,12 +636,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;
@@ -727,9 +728,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);
/*
@@ -974,7 +976,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;
@@ -982,6 +984,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));
@@ -1069,7 +1072,7 @@ Tcl_TranslateFileName(
*/
if (tclPlatform == TCL_PLATFORM_WINDOWS) {
- register char *p;
+ char *p;
for (p = Tcl_DStringValue(bufferPtr); *p != '\0'; p++) {
if (*p == '/') {
*p = '\\';
@@ -1212,7 +1215,6 @@ DoTildeSubst(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
Tcl_GlobObjCmd(
ClientData dummy, /* Not used. */
@@ -1230,12 +1232,13 @@ 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
};
enum pathDirOptions {PATH_NONE = -1 , PATH_GENERAL = 0, PATH_DIR = 1};
Tcl_GlobTypeData *globTypes = NULL;
+ (void)dummy;
globFlags = 0;
join = 0;
@@ -1263,7 +1266,7 @@ Tcl_GlobObjCmd(
}
}
- switch (index) {
+ switch ((enum globOptionsEnum) index) {
case GLOB_NOCOMPLAIN: /* -nocomplain */
globFlags |= TCL_GLOBMODE_NO_COMPLAIN;
break;
@@ -1275,7 +1278,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));
return TCL_ERROR;
}
dir = PATH_DIR;
@@ -1297,7 +1303,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));
return TCL_ERROR;
}
dir = PATH_GENERAL;
@@ -1334,7 +1343,7 @@ Tcl_GlobObjCmd(
return TCL_ERROR;
}
- separators = NULL; /* lint. */
+ separators = NULL;
switch (tclPlatform) {
case TCL_PLATFORM_UNIX:
separators = "/";
@@ -1439,7 +1448,7 @@ Tcl_GlobObjCmd(
if (length <= 0) {
goto skipTypes;
}
- globTypes = (Tcl_GlobTypeData*)
+ globTypes = (Tcl_GlobTypeData *)
TclStackAlloc(interp,sizeof(Tcl_GlobTypeData));
globTypes->type = 0;
globTypes->perm = 0;
@@ -1666,9 +1675,8 @@ Tcl_GlobObjCmd(
*
* TclGlob --
*
- * This procedure prepares arguments for the DoGlob call. It sets the
- * separator string based on the platform, performs * tilde substitution,
- * and calls DoGlob.
+ * Sets the separator string based on the platform, performs tilde
+ * substitution, and calls DoGlob.
*
* The interpreter's result, on entry to this function, must be a valid
* Tcl list (e.g. it could be empty), since we will lappend any new
@@ -1691,7 +1699,6 @@ Tcl_GlobObjCmd(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
int
TclGlob(
Tcl_Interp *interp, /* Interpreter for returning error message or
@@ -1710,7 +1717,7 @@ TclGlob(
int result;
Tcl_Obj *filenamesObj, *savedResultObj;
- separators = NULL; /* lint. */
+ separators = NULL;
switch (tclPlatform) {
case TCL_PLATFORM_UNIX:
separators = "/";
@@ -1891,7 +1898,7 @@ TclGlob(
}
/*
- * To process a [glob] invokation, this function may be called multiple
+ * To process a [glob] invocation, this function may be called multiple
* times. Each time, the previously discovered filenames are in the
* interpreter result. We stash that away here so the result is free for
* error messsages.
@@ -2045,7 +2052,7 @@ TclGlob(
* SkipToChar --
*
* This function traverses a glob pattern looking for the next unquoted
- * occurance of the specified character at the same braces nesting level.
+ * occurrence of the specified character at the same braces nesting level.
*
* Results:
* Updates stringPtr to point to the matching character, or to the end of
@@ -2064,7 +2071,7 @@ SkipToChar(
int match) /* Character to find. */
{
int quoted, level;
- register char *p;
+ char *p;
quoted = 0;
level = 0;
@@ -2507,7 +2514,7 @@ DoGlob(
Tcl_StatBuf *
Tcl_AllocStatBuf(void)
{
- return (Tcl_StatBuf *) ckalloc(sizeof(Tcl_StatBuf));
+ return (Tcl_StatBuf *)ckalloc(sizeof(Tcl_StatBuf));
}
/*