diff options
author | nijtmans <nijtmans> | 2008-10-05 22:25:35 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2008-10-05 22:25:35 (GMT) |
commit | 06d77e88c1820d6b44d1450d66d93d5950779ea8 (patch) | |
tree | 578409d445995ed8603c1288507ce8ce7ae0bf0c /generic/tclFCmd.c | |
parent | c095ba4368ae987448c8141e73b12276031ed168 (diff) | |
download | tcl-06d77e88c1820d6b44d1450d66d93d5950779ea8.zip tcl-06d77e88c1820d6b44d1450d66d93d5950779ea8.tar.gz tcl-06d77e88c1820d6b44d1450d66d93d5950779ea8.tar.bz2 |
* doc/FileSystem.3: CONSTified Tcl_FSFileAttrStringsProc
* generic/tclFCmd.c: and tclpFileAttrStrings. This allows
* generic/tclIOUtil.c: FileSystems to report their attributes
* generic/tclTest.c: as const strings, without worrying that
* unix/tclUnixFCmd.c: Tcl modifies them (which Tcl should not
* win/tclWinFCmd.c: do anyway, but the API didn't indicate that)
* generic/tcl.decls
* generic/tclDecls.h: regenerated
* generic/tcl.h: make sure that if CONST84 is defined
as empty, CONST86 should be defined
as empty as well (unless overridden).
This change complies with TIP #27
*** POTENTIAL INCOMPATIBILITY ***
Diffstat (limited to 'generic/tclFCmd.c')
-rw-r--r-- | generic/tclFCmd.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index d385f8e..6f92304 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFCmd.c,v 1.47 2008/09/24 19:31:29 dgp Exp $ + * RCS: @(#) $Id: tclFCmd.c,v 1.48 2008/10/05 22:25:35 nijtmans Exp $ */ #include "tclInt.h" @@ -944,7 +944,8 @@ TclFileAttrsCmd( Tcl_Obj *const objv[]) /* The command line objects. */ { int result; - const char ** attributeStrings; + const char *const *attributeStrings; + const char **attributeStringsAllocated = NULL; Tcl_Obj *objStrings = NULL; int numObjStrings = -1; Tcl_Obj *filePtr; @@ -997,13 +998,14 @@ TclFileAttrsCmd( if (Tcl_ListObjLength(interp, objStrings, &numObjStrings) != TCL_OK) { goto end; } - attributeStrings = (const char **) + attributeStringsAllocated = (const char **) TclStackAlloc(interp, (1+numObjStrings) * sizeof(char *)); for (index = 0; index < numObjStrings; index++) { Tcl_ListObjIndex(interp, objStrings, index, &objPtr); - attributeStrings[index] = TclGetString(objPtr); + attributeStringsAllocated[index] = TclGetString(objPtr); } - attributeStrings[index] = NULL; + attributeStringsAllocated[index] = NULL; + attributeStrings = attributeStringsAllocated; } if (objc == 0) { /* @@ -1103,12 +1105,12 @@ TclFileAttrsCmd( result = TCL_OK; end: - if (numObjStrings != -1) { + if (attributeStringsAllocated != NULL) { /* * Free up the array we allocated. */ - TclStackFree(interp, (void *)attributeStrings); + TclStackFree(interp, attributeStringsAllocated); /* * We don't need this object that was passed to us any more. |