summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2011-04-16 11:51:35 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2011-04-16 11:51:35 (GMT)
commitf1724b7ab36f74c7fc8f9f4c58e79be1864f14d5 (patch)
treebc4481b91b1bec8be4f57db173c7050374b47165
parent55499487fed3613d024c1ac04e226a6ab7e62a5d (diff)
downloadtcl-f1724b7ab36f74c7fc8f9f4c58e79be1864f14d5.zip
tcl-f1724b7ab36f74c7fc8f9f4c58e79be1864f14d5.tar.gz
tcl-f1724b7ab36f74c7fc8f9f4c58e79be1864f14d5.tar.bz2
Added comments to try to tame the file attributes guts, while trying to simplify
things enough that I can puzzle out AK's TclVFS problems. I suspect this is not a real fix though; just an attempt to make the problem tractable.
-rw-r--r--ChangeLog18
-rw-r--r--generic/tclFCmd.c36
2 files changed, 34 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index d04c05e..13aa14a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,15 @@
+2011-04-16 Donal K. Fellows <dkf@users.sf.net>
+
+ * generic/tclFCmd.c (TclFileAttrsCmd): Add comments to make this code
+ easier to understand. Added a panic to handle the case where the VFS
+ layer does something odd.
+
2011-04-13 Don Porter <dgp@users.sourceforge.net>
- * generic/tclUtil.c: Rewrite of Tcl_Concat*() routines to
- prevent segfaults on buffer overflow. Build them out of existing
- primitives already coded to handle overflow properly. Uses the
- new TclTrim*() routines. [Bug 3285375]
+ * generic/tclUtil.c: [Bug 3285375]: Rewrite of Tcl_Concat*()
+ routines to prevent segfaults on buffer overflow. Build them out of
+ existing primitives already coded to handle overflow properly. Uses
+ the new TclTrim*() routines.
* generic/tclCmdMZ.c: New internal utility routines TclTrimLeft()
* generic/tclInt.h: and TclTrimRight(). Refactor the
@@ -11,8 +17,8 @@
2011-04-13 Miguel Sofer <msofer@users.sf.net>
- * generic/tclVar.c: fix for [Bug 2662380], crash caused by
- appending to a variable with a write trace that unsets it.
+ * generic/tclVar.c: [Bug 2662380]: Fix crash caused by appending to a
+ variable with a write trace that unsets it.
2011-04-13 Donal K. Fellows <dkf@users.sf.net>
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index e9176ca..048fa57 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -966,6 +966,10 @@ TclFileAttrsCmd(
result = TCL_ERROR;
Tcl_SetErrno(0);
+ /*
+ * Get the set of attribute names from the filesystem.
+ */
+
attributeStrings = Tcl_FSFileAttrStrings(filePtr, &objStrings);
if (attributeStrings == NULL) {
int index;
@@ -980,9 +984,8 @@ TclFileAttrsCmd(
Tcl_AppendResult(interp, "could not read \"",
TclGetString(filePtr), "\": ", Tcl_PosixError(interp),
NULL);
- return TCL_ERROR;
}
- goto end;
+ return TCL_ERROR;
}
/*
@@ -1006,7 +1009,16 @@ TclFileAttrsCmd(
}
attributeStringsAllocated[index] = NULL;
attributeStrings = attributeStringsAllocated;
+ } else if (objStrings != NULL) {
+ Tcl_Panic("must not update objPtrRef's variable and return non-NULL");
}
+
+ /*
+ * Process the attributes to produce a list of all of them, the value of a
+ * particular attribute, or to set one or more attributes (depending on
+ * the number of arguments).
+ */
+
if (objc == 0) {
/*
* Get all attributes.
@@ -1114,21 +1126,17 @@ TclFileAttrsCmd(
}
result = TCL_OK;
+ /*
+ * Free up the array we allocated and drop our reference to any list of
+ * attribute names issued by the filesystem.
+ */
+
end:
if (attributeStringsAllocated != NULL) {
- /*
- * Free up the array we allocated.
- */
-
TclStackFree(interp, (void *) attributeStringsAllocated);
-
- /*
- * We don't need this object that was passed to us any more.
- */
-
- if (objStrings != NULL) {
- Tcl_DecrRefCount(objStrings);
- }
+ }
+ if (objStrings != NULL) {
+ Tcl_DecrRefCount(objStrings);
}
return result;
}