summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-10-15 21:27:47 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-10-15 21:27:47 (GMT)
commit7222d685f8f460bfd8edb01515a8d6ad5e5c60a3 (patch)
tree660da6ea51654bcc0e6047863d9213d28f2694a4 /unix
parent03bf8aafa026b3996c8907876f76f3b43d77da04 (diff)
downloadtcl-7222d685f8f460bfd8edb01515a8d6ad5e5c60a3.zip
tcl-7222d685f8f460bfd8edb01515a8d6ad5e5c60a3.tar.gz
tcl-7222d685f8f460bfd8edb01515a8d6ad5e5c60a3.tar.bz2
* generic/tclIOCmd.c: Revise [open] so that it interprets leading
zero strings passed as the "permissions" argument as octal numbers, even if Tcl itself no longer parses integers in that way. * unix/tclUnixFCmd.c: Revise the "-permissions" [file attribute] so that it interprets leading zero strings as octal numbers, even if Tcl itself no longer parses integers in that way. * generic/tclCompExpr.c: Corrections to code that produces * generic/tclUtil.c: extended "bad octal" error messages. * tests/cmdAH.test: Test revisions so that tests pass whether or * tests/cmdIL.test: not Tcl parses leading zero strings as octal. * tests/compExpr-old.test: * tests/compExpr.test: * tests/compile.test: * tests/expr-old.test: * tests/expr.test: * tests/incr.test: * tests/io.test: * tests/lindex.test: * tests/link.test: * tests/mathop.test: * tests/parseExpr.test: * tests/set.test: * tests/string.test: * tests/stringComp.test:
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixFCmd.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index 076a957..07bdff9 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixFCmd.c,v 1.62 2007/07/31 13:57:15 dkf Exp $
+ * RCS: @(#) $Id: tclUnixFCmd.c,v 1.63 2007/10/15 21:27:50 dgp Exp $
*
* Portions of this code were derived from NetBSD source code which has the
* following copyright notice:
@@ -1595,18 +1595,31 @@ SetPermissionsAttribute(
{
long mode;
mode_t newMode;
- int result;
+ int result = TCL_ERROR;
CONST char *native;
+ char *modeStringPtr = TclGetString(attributePtr);
+ int scanned = TclParseAllWhiteSpace(modeStringPtr, -1);
/*
- * First try if the string is a number
+ * First supply support for octal number format
*/
- if (Tcl_GetLongFromObj(NULL, attributePtr, &mode) == TCL_OK) {
+ if ((modeStringPtr[scanned] == '0')
+ && (modeStringPtr[scanned+1] >= '0')
+ && (modeStringPtr[scanned+1] <= '7')) {
+ /* Leading zero - attempt octal interpretation */
+ Tcl_Obj *modeObj;
+
+ TclNewLiteralStringObj(modeObj, "0o");
+ Tcl_AppendToObj(modeObj, modeStringPtr+scanned+1, -1);
+ result = Tcl_GetLongFromObj(NULL, modeObj, &mode);
+ Tcl_DecrRefCount(modeObj);
+ }
+ if (result == TCL_OK
+ || Tcl_GetLongFromObj(NULL, attributePtr, &mode) == TCL_OK) {
newMode = (mode_t) (mode & 0x00007FFF);
} else {
Tcl_StatBuf buf;
- char *modeStringPtr = TclGetString(attributePtr);
/*
* Try the forms "rwxrwxrwx" and "ugo=rwx"