summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog30
-rw-r--r--generic/tclCompExpr.c25
-rw-r--r--generic/tclIOCmd.c22
-rw-r--r--generic/tclUtil.c9
-rw-r--r--tests/cmdAH.test4
-rw-r--r--tests/cmdIL.test10
-rw-r--r--tests/compExpr-old.test10
-rw-r--r--tests/compExpr.test6
-rw-r--r--tests/compile.test8
-rw-r--r--tests/expr-old.test12
-rw-r--r--tests/expr.test14
-rw-r--r--tests/incr.test6
-rw-r--r--tests/io.test10
-rw-r--r--tests/lindex.test52
-rw-r--r--tests/link.test6
-rw-r--r--tests/mathop.test66
-rw-r--r--tests/parseExpr.test16
-rw-r--r--tests/set.test10
-rw-r--r--tests/string.test22
-rw-r--r--tests/stringComp.test14
-rw-r--r--unix/tclUnixFCmd.c23
21 files changed, 229 insertions, 146 deletions
diff --git a/ChangeLog b/ChangeLog
index 5871cc2..32f6413 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2007-10-15 Don Porter <dgp@users.sourceforge.net>
+
+ * 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:
+
2007-10-15 David Gravereaux <davygrvy@pobox.com>
* tools/mkdepend.tcl: Produces usable output. Include path
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index 18ac99d..36be6eb 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.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: tclCompExpr.c,v 1.86 2007/08/28 17:43:07 dgp Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.87 2007/10/15 21:27:48 dgp Exp $
*/
#include "tclInt.h"
@@ -744,6 +744,29 @@ ParseExpr(
" or \"%.*s%s(...)\" or ...",
(scanned < limit) ? scanned : limit - 3,
start, (scanned < limit) ? "" : "...");
+ if (NotOperator(lastParsed)) {
+ if ((lastStart[0] == '0')
+ && ((lastStart[1] == 'o')
+ || (lastStart[1] == 'O'))
+ && (lastStart[2] >= '0')
+ && (lastStart[2] <= '9')) {
+ const char *end = lastStart + 2;
+ while (isdigit(*end)) {
+ end++;
+ }
+ Tcl_Obj *copy = Tcl_NewStringObj(lastStart,
+ end - lastStart);
+ if (TclCheckBadOctal(NULL,
+ Tcl_GetString(copy))) {
+ TclNewLiteralStringObj(post,
+ "(invalid octal number?)");
+ }
+ Tcl_DecrRefCount(copy);
+ }
+ scanned = 0;
+ insertMark = 1;
+ parsePtr->errorType = TCL_PARSE_BAD_NUMBER;
+ }
goto error;
}
}
diff --git a/generic/tclIOCmd.c b/generic/tclIOCmd.c
index 9156b6d..1c25295 100644
--- a/generic/tclIOCmd.c
+++ b/generic/tclIOCmd.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOCmd.c,v 1.43 2007/09/06 18:13:20 dgp Exp $
+ * RCS: @(#) $Id: tclIOCmd.c,v 1.44 2007/10/15 21:27:48 dgp Exp $
*/
#include "tclInt.h"
@@ -1025,7 +1025,25 @@ Tcl_OpenObjCmd(
} else {
modeString = Tcl_GetString(objv[2]);
if (objc == 4) {
- if (Tcl_GetIntFromObj(interp, objv[3], &prot) != TCL_OK) {
+ char *permString = TclGetString(objv[3]);
+ int code = TCL_ERROR;
+ int scanned = TclParseAllWhiteSpace(permString, -1);
+
+ /* Support legacy octal numbers */
+ if ((permString[scanned] == '0')
+ && (permString[scanned+1] >= '0')
+ && (permString[scanned+1] <= '7')) {
+
+ Tcl_Obj *permObj;
+
+ TclNewLiteralStringObj(permObj, "0o");
+ Tcl_AppendToObj(permObj, permString+scanned+1, -1);
+ code = Tcl_GetIntFromObj(NULL, permObj, &prot);
+ Tcl_DecrRefCount(permObj);
+ }
+
+ if ((code == TCL_ERROR)
+ && Tcl_GetIntFromObj(interp, objv[3], &prot) != TCL_OK) {
return TCL_ERROR;
}
}
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index fe7f18a..6a25141 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtil.c,v 1.82 2007/05/07 19:45:33 dgp Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.83 2007/10/15 21:27:48 dgp Exp $
*/
#include "tclInt.h"
@@ -2372,8 +2372,8 @@ TclGetIntForIndex(
Tcl_AppendResult(interp, "bad index \"", bytes,
"\": must be integer?[+-]integer? or end?[+-]integer?",
(char *) NULL);
- if (!strncmp(bytes, "end-", 3)) {
- bytes += 3;
+ if (!strncmp(bytes, "end-", 4)) {
+ bytes += 4;
}
TclCheckBadOctal(interp, bytes);
}
@@ -2556,6 +2556,9 @@ TclCheckBadOctal(
p++;
}
if (*p == '0') {
+ if ((p[1] == 'o') || p[1] == 'O') {
+ p+=2;
+ }
while (isdigit(UCHAR(*p))) { /* INTL: digit. */
p++;
}
diff --git a/tests/cmdAH.test b/tests/cmdAH.test
index 031d152..cc4916c 100644
--- a/tests/cmdAH.test
+++ b/tests/cmdAH.test
@@ -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: cmdAH.test,v 1.55 2007/01/18 22:09:44 dkf Exp $
+# RCS: @(#) $Id: cmdAH.test,v 1.56 2007/10/15 21:27:49 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -1332,7 +1332,7 @@ test cmdAH-28.4 {Tcl_FileObjCmd: stat} {
test cmdAH-28.5 {Tcl_FileObjCmd: stat} {unix} {
catch {unset stat}
file stat $gorpfile stat
- expr $stat(mode)&0777
+ expr $stat(mode)&0o777
} {501}
test cmdAH-28.6 {Tcl_FileObjCmd: stat} {
string tolower [list [catch {file stat _bogus_ stat} msg] \
diff --git a/tests/cmdIL.test b/tests/cmdIL.test
index c9796db..3ededd3 100644
--- a/tests/cmdIL.test
+++ b/tests/cmdIL.test
@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: cmdIL.test,v 1.33 2007/03/13 17:34:04 dgp Exp $
+# RCS: @(#) $Id: cmdIL.test,v 1.34 2007/10/15 21:27:49 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -195,8 +195,8 @@ test cmdIL-3.10 {SortCompare procedure, -integer option} {
list [catch {lsort -integer {3 q}} msg] $msg
} {1 {expected integer but got "q"}}
test cmdIL-3.11 {SortCompare procedure, -integer option} {
- lsort -integer {35 21 0x20 30 023 100 8}
-} {8 023 21 30 0x20 35 100}
+ lsort -integer {35 21 0x20 30 0o23 100 8}
+} {8 0o23 21 30 0x20 35 100}
test cmdIL-3.12 {SortCompare procedure, -real option} {
list [catch {lsort -real {6...4 3}} msg] $msg
} {1 {expected floating-point number but got "6...4"}}
@@ -247,8 +247,8 @@ test cmdIL-3.18 {SortCompare procedure, -command option} -body {
rename cmp ""
} -result {48 36 35 22 21 18 6}
test cmdIL-3.19 {SortCompare procedure, -decreasing option} {
- lsort -decreasing -integer {35 21 0x20 30 023 100 8}
-} {100 35 0x20 30 21 023 8}
+ lsort -decreasing -integer {35 21 0x20 30 0o23 100 8}
+} {100 35 0x20 30 21 0o23 8}
test cmdIL-4.1 {DictionaryCompare procedure, numerics, leading zeros} {
lsort -dictionary {a003b a03b}
diff --git a/tests/compExpr-old.test b/tests/compExpr-old.test
index 78e6090..7568268 100644
--- a/tests/compExpr-old.test
+++ b/tests/compExpr-old.test
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: compExpr-old.test,v 1.21 2006/10/09 19:15:44 msofer Exp $
+# RCS: @(#) $Id: compExpr-old.test,v 1.22 2007/10/15 21:27:49 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -362,7 +362,7 @@ test compExpr-old-9.10 {CompileRelationalExpr: error compiling relational arm} -
test compExpr-old-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
test compExpr-old-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
test compExpr-old-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
-test compExpr-old-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
+test compExpr-old-10.4 {CompileShiftExpr: just add expr} {expr 1-0o123} -82
test compExpr-old-10.5 {CompileShiftExpr: error in add expr} -body {
expr x+3
} -returnCodes error -match glob -result *
@@ -384,7 +384,7 @@ test compExpr-old-10.11 {CompileShiftExpr: runtime error} {
test compExpr-old-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
test compExpr-old-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
test compExpr-old-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
-test compExpr-old-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
+test compExpr-old-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0o123} 6
test compExpr-old-11.5 {CompileAddExpr: error in multiply expr} -body {
expr x*3
} -returnCodes error -match glob -result *
@@ -435,7 +435,7 @@ test compExpr-old-12.11 {CompileMultiplyExpr: runtime error} {
} {1 {can't use non-numeric string as operand of "/"}}
test compExpr-old-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255
-test compExpr-old-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83
+test compExpr-old-13.2 {CompileUnaryExpr: unary exprs} {expr +0o00123} 83
test compExpr-old-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36
test compExpr-old-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
test compExpr-old-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
@@ -470,7 +470,7 @@ test compExpr-old-13.16 {CompileUnaryExpr: error in primary expr} {
test compExpr-old-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1
test compExpr-old-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123
test compExpr-old-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255
-test compExpr-old-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8
+test compExpr-old-14.4 {CompilePrimaryExpr: literal primary} {expr 0o0010} 8
test compExpr-old-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0
test compExpr-old-14.6 {CompilePrimaryExpr: literal primary} {
expr 3.1400000
diff --git a/tests/compExpr.test b/tests/compExpr.test
index f2075df..65c7d1c 100644
--- a/tests/compExpr.test
+++ b/tests/compExpr.test
@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: compExpr.test,v 1.14 2007/08/24 21:34:20 dgp Exp $
+# RCS: @(#) $Id: compExpr.test,v 1.15 2007/10/15 21:27:49 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -37,7 +37,7 @@ test compExpr-1.3 {TclCompileExpr procedure, error compiling expr} -body {
} -match glob -result {1 {* "*foo"}}
test compExpr-1.4 {TclCompileExpr procedure, expr has no operators} {
- set a {000123}
+ set a {0o00123}
expr {$a}
} 83
@@ -283,7 +283,7 @@ test compExpr-4.7 {CompileCondExpr procedure, simple "false" clause} {
} nope
test compExpr-4.8 {CompileCondExpr procedure, convert "false" clause to numeric} {
catch {unset a}
- set a 00123
+ set a 0o0123
expr {0? 42 : $a}
} 83
test compExpr-4.9 {CompileCondExpr procedure, error in "false" clause} {
diff --git a/tests/compile.test b/tests/compile.test
index 18d3b16..5c21d43 100644
--- a/tests/compile.test
+++ b/tests/compile.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: compile.test,v 1.46 2007/03/07 19:16:05 dgp Exp $
+# RCS: @(#) $Id: compile.test,v 1.47 2007/10/15 21:27:49 dgp Exp $
package require tcltest 2
namespace import -force ::tcltest::*
@@ -241,10 +241,10 @@ test compile-11.2 {Tcl_Append*: ensure Tcl_ResetResult is used properly} {
proc p {} { set r [list foobar] ; string index a bogus }
list [catch {p} msg] $msg
} {1 {bad index "bogus": must be integer?[+-]integer? or end?[+-]integer?}}
-test compile-11.3 {Tcl_Append*: ensure Tcl_ResetResult is used properly} {
- proc p {} { set r [list foobar] ; string index a 09 }
+test compile-11.3 {Tcl_Append*: ensure Tcl_ResetResult is used properly} -body {
+ proc p {} { set r [list foobar] ; string index a 0o9 }
list [catch {p} msg] $msg
-} {1 {bad index "09": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
+} -match glob -result {1 {*invalid octal number*}}
test compile-11.4 {Tcl_Append*: ensure Tcl_ResetResult is used properly} {
proc p {} { set r [list foobar] ; array set var {one two many} }
list [catch {p} msg] $msg
diff --git a/tests/expr-old.test b/tests/expr-old.test
index 598697c..94021d8 100644
--- a/tests/expr-old.test
+++ b/tests/expr-old.test
@@ -13,7 +13,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: expr-old.test,v 1.38 2006/08/31 20:09:19 dgp Exp $
+# RCS: @(#) $Id: expr-old.test,v 1.39 2007/10/15 21:27:49 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -465,7 +465,7 @@ test expr-old-23.8 {double quotes} {
# Numbers in various bases.
test expr-old-24.1 {numbers in different bases} {expr 0x20} 32
-test expr-old-24.2 {numbers in different bases} {expr 015} 13
+test expr-old-24.2 {numbers in different bases} {expr 0o15} 13
# Conversions between various data types.
@@ -678,7 +678,7 @@ test expr-old-28.14 {Tcl_ExprBool usage} {
# Operands enclosed in braces
test expr-old-29.1 {braces} {expr {{abc}}} abc
-test expr-old-29.2 {braces} {expr {{00010}}} 8
+test expr-old-29.2 {braces} {expr {{0o0010}}} 8
test expr-old-29.3 {braces} {expr {{3.1200000}}} 3.12
test expr-old-29.4 {braces} {expr {{a{b}{1 {2 3}}c}}} "a{b}{1 {2 3}}c"
test expr-old-29.5 {braces} -body {
@@ -959,10 +959,10 @@ test expr-old-34.17 {errors in math functions} -constraints testmathfunctions \
} -match glob -result {1 {too many arguments for math function*}}
test expr-old-36.1 {ExprLooksLikeInt procedure} -body {
- expr 0289
+ expr 0o289
} -returnCodes error -match glob -result {*invalid octal number*}
test expr-old-36.2 {ExprLooksLikeInt procedure} {
- set x 0289
+ set x 0o289
list [catch {expr {$x+1}} msg] $msg
} {1 {can't use invalid octal number as operand of "+"}}
test expr-old-36.3 {ExprLooksLikeInt procedure} {
@@ -1014,7 +1014,7 @@ test expr-old-36.14 {ExprLooksLikeInt procedure} {
expr {$x+1}
} 123456789012345678901234567891
test expr-old-36.15 {ExprLooksLikeInt procedure} {
- set x "099 "
+ set x "0o99 "
list [catch {expr {$x+1}} msg] $msg
} {1 {can't use invalid octal number as operand of "+"}}
test expr-old-36.16 {ExprLooksLikeInt procedure} {
diff --git a/tests/expr.test b/tests/expr.test
index ed8f586..d733b4c 100644
--- a/tests/expr.test
+++ b/tests/expr.test
@@ -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: expr.test,v 1.69 2007/08/25 03:23:18 kennykb Exp $
+# RCS: @(#) $Id: expr.test,v 1.70 2007/10/15 21:27:49 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -441,7 +441,7 @@ test expr-9.10 {CompileRelationalExpr: error compiling relational arm} -body {
test expr-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
test expr-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
test expr-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
-test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
+test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0o123} -82
test expr-10.5 {CompileShiftExpr: error in add expr} -body {
expr x+3
} -returnCodes error -match glob -result *
@@ -463,7 +463,7 @@ test expr-10.11 {CompileShiftExpr: runtime error} {
test expr-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
test expr-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
test expr-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
-test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
+test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0o123} 6
test expr-11.5 {CompileAddExpr: error in multiply expr} -body {
expr x*3
} -returnCodes error -match glob -result *
@@ -514,7 +514,7 @@ test expr-12.11 {CompileMultiplyExpr: runtime error} {
} {1 {can't use non-numeric string as operand of "/"}}
test expr-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255
-test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83
+test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +0o00123} 83
test expr-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36
test expr-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
test expr-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
@@ -553,7 +553,7 @@ test expr-13.17 {CompileUnaryExpr: negating non-numeric boolean literals} {
test expr-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1
test expr-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123
test expr-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255
-test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8
+test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 0o0010} 8
test expr-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0
test expr-14.6 {CompilePrimaryExpr: literal primary} {
expr 3.1400000
@@ -6452,10 +6452,10 @@ test expr-39.25 {Tcl_ExprDoubleObj and NaN} \
} {1 {domain error: argument not in valid range}}
test expr-40.1 {large octal shift} {
- expr 0100000000000000000000000000000000
+ expr 0o100000000000000000000000000000000
} [expr 0x1000000000000000000000000]
test expr-40.2 {large octal shift} {
- expr 0100000000000000000000000000000001
+ expr 0o100000000000000000000000000000001
} [expr 0x1000000000000000000000001]
test expr-41.1 {exponent overflow} {
diff --git a/tests/incr.test b/tests/incr.test
index 9546db8..27d6fd1 100644
--- a/tests/incr.test
+++ b/tests/incr.test
@@ -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: incr.test,v 1.14 2006/10/09 19:15:44 msofer Exp $
+# RCS: @(#) $Id: incr.test,v 1.15 2007/10/15 21:27:50 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -194,7 +194,7 @@ test incr-1.22 {TclCompileIncrCmd: increment given, large int} {
} 200005
test incr-1.23 {TclCompileIncrCmd: increment given, formatted int != int} {
set i 25
- incr i 000012345 ;# an octal literal
+ incr i 0o00012345 ;# an octal literal
} 5374
test incr-1.24 {TclCompileIncrCmd: increment given, formatted int != int} {
set i 25
@@ -445,7 +445,7 @@ test incr-2.22 {incr command (not compiled): increment given, large int} {
test incr-2.23 {incr command (not compiled): increment given, formatted int != int} {
set z incr
set i 25
- $z i 000012345 ;# an octal literal
+ $z i 0o00012345 ;# an octal literal
} 5374
test incr-2.24 {incr command (not compiled): increment given, formatted int != int} {
set z incr
diff --git a/tests/io.test b/tests/io.test
index f74b078..588002e 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -13,7 +13,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: io.test,v 1.76 2007/05/04 14:59:06 kennykb Exp $
+# RCS: @(#) $Id: io.test,v 1.77 2007/10/15 21:27:50 dgp Exp $
if {[catch {package require tcltest 2}]} {
puts stderr "Skipping tests in [info script]. tcltest 2 required."
@@ -48,7 +48,7 @@ testConstraint largefileSupport 0
# some tests can only be run is umask is 2
# if "umask" cannot be run, the tests will be skipped.
set umaskValue 0
-testConstraint umask [expr {![catch {set umaskValue [exec /bin/sh -c umask]}]}]
+testConstraint umask [expr {![catch {set umaskValue [scan [exec /bin/sh -c umask] %o]}]}]
testConstraint makeFileInHome [expr {![file exists ~/_test_] && [file writable ~]}]
@@ -5209,7 +5209,7 @@ test io-40.2 {POSIX open access modes: CREAT} {unix} {
file delete $path(test3)
set f [open $path(test3) {WRONLY CREAT} 0600]
file stat $path(test3) stats
- set x [format "0%o" [expr $stats(mode)&0777]]
+ set x [format "0%o" [expr $stats(mode)&0o777]]
puts $f "line 1"
close $f
set f [open $path(test3) r]
@@ -5223,8 +5223,8 @@ test io-40.3 {POSIX open access modes: CREAT} {unix umask} {
set f [open $path(test3) {WRONLY CREAT}]
close $f
file stat $path(test3) stats
- format "0%o" [expr $stats(mode)&0777]
-} [format %04o [expr {0666 & ~ $umaskValue}]]
+ format "0%o" [expr $stats(mode)&0o777]
+} [format %04o [expr {0o666 & ~ $umaskValue}]]
test io-40.4 {POSIX open access modes: CREAT} {
file delete $path(test3)
set f [open $path(test3) w]
diff --git a/tests/lindex.test b/tests/lindex.test
index 37c840e..baaf73a 100644
--- a/tests/lindex.test
+++ b/tests/lindex.test
@@ -12,10 +12,10 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: lindex.test,v 1.15 2007/09/03 21:27:22 kennykb Exp $
+# RCS: @(#) $Id: lindex.test,v 1.16 2007/10/15 21:27:50 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
- package require tcltest
+ package require tcltest 2.2
namespace import -force ::tcltest::*
}
@@ -66,14 +66,14 @@ test lindex-3.4 {integer 3} testevalex {
set x [string range 33 0 0]
list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
} {{} {}}
-test lindex-3.5 {bad octal} testevalex {
- set x 08
+test lindex-3.5 {bad octal} -constraints testevalex -body {
+ set x 0o8
list [catch { testevalex {lindex {a b c} $x} } result] $result
-} {1 {bad index "08": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
-test lindex-3.6 {bad octal} testevalex {
- set x -09
+} -match glob -result {1 {*invalid octal number*}}
+test lindex-3.6 {bad octal} -constraints testevalex -body {
+ set x -0o9
list [catch { testevalex {lindex {a b c} $x} } result] $result
-} {1 {bad index "-09": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
+} -match glob -result {1 {*invalid octal number*}}
test lindex-3.7 {indexes don't shimmer wide ints} {
set x [expr {(wide(1)<<31) - 2}]
list $x [lindex {1 2 3} $x] [incr x] [incr x]
@@ -101,14 +101,14 @@ test lindex-4.5 {index = end-3} testevalex {
set x end-3
list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
} {{} {}}
-test lindex-4.6 {bad octal} testevalex {
- set x end-08
+test lindex-4.6 {bad octal} -constraints testevalex -body {
+ set x end-0o8
list [catch { testevalex {lindex {a b c} $x} } result] $result
-} {1 {bad index "end-08": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
-test lindex-4.7 {bad octal} testevalex {
- set x end--09
+} -match glob -result {1 {*invalid octal number*}}
+test lindex-4.7 {bad octal} -constraints testevalex -body {
+ set x end--0o9
list [catch { testevalex {lindex {a b c} $x} } result] $result
-} {1 {bad index "end--09": must be integer?[+-]integer? or end?[+-]integer?}}
+} -match glob -result {1 {*invalid octal number*}}
test lindex-4.8 {bad integer, not octal} testevalex {
set x end-0a2
list [catch { testevalex {lindex {a b c} $x} } result] $result
@@ -257,14 +257,14 @@ test lindex-11.4 {integer 3} {
} result
set result
} {{} {}}
-test lindex-11.5 {bad octal} {
- set x 08
+test lindex-11.5 {bad octal} -body {
+ set x 0o8
list [catch { lindex {a b c} $x } result] $result
-} {1 {bad index "08": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
-test lindex-11.6 {bad octal} {
- set x -09
+} -match glob -result {1 {*invalid octal number*}}
+test lindex-11.6 {bad octal} -body {
+ set x -0o9
list [catch { lindex {a b c} $x } result] $result
-} {1 {bad index "-09": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
+} -match glob -result {1 {*invalid octal number*}}
# Indices relative to end
@@ -303,14 +303,14 @@ test lindex-12.5 {index = end-3} {
} result
set result
} {{} {}}
-test lindex-12.6 {bad octal} {
- set x end-08
+test lindex-12.6 {bad octal} -body {
+ set x end-0o8
list [catch { lindex {a b c} $x } result] $result
-} {1 {bad index "end-08": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
-test lindex-12.7 {bad octal} {
- set x end--09
+} -match glob -result {1 {*invalid octal number*}}
+test lindex-12.7 {bad octal} -body {
+ set x end--0o9
list [catch { lindex {a b c} $x } result] $result
-} {1 {bad index "end--09": must be integer?[+-]integer? or end?[+-]integer?}}
+} -match glob -result {1 {*invalid octal number*}}
test lindex-12.8 {bad integer, not octal} {
set x end-0a2
list [catch { lindex {a b c} $x } result] $result
diff --git a/tests/link.test b/tests/link.test
index 08251b1..606fe68 100644
--- a/tests/link.test
+++ b/tests/link.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: link.test,v 1.15 2006/03/21 11:12:29 dkf Exp $
+# RCS: @(#) $Id: link.test,v 1.16 2007/10/15 21:27:50 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -40,7 +40,7 @@ test link-2.1 {writing C variables from Tcl} {testlink} {
testlink delete
testlink set 43 1.21 4 - 56785678 64 250 30000 60000 0xbaadbeef 12321 32123 3.25 1231231234
testlink create 1 1 1 1 1 1 1 1 1 1 1 1 1 1
- set int "00721"
+ set int "0o0721"
set real -10.5
set bool true
set string abcdef
@@ -55,7 +55,7 @@ test link-2.1 {writing C variables from Tcl} {testlink} {
set float 1.0987654321
set uwide 357357357357
concat [testlink get] | $int $real $bool $string $wide $char $uchar $short $ushort $uint $long $ulong $float $uwide
-} {465 -10.5 1 abcdef 135135 79 161 8000 40000 -1073628482 34543 567890 1.0987653732299805 357357357357 | 00721 -10.5 true abcdef 135135 79 161 8000 40000 0xc001babe 34543 567890 1.0987654321 357357357357}
+} {465 -10.5 1 abcdef 135135 79 161 8000 40000 -1073628482 34543 567890 1.0987653732299805 357357357357 | 0o0721 -10.5 true abcdef 135135 79 161 8000 40000 0xc001babe 34543 567890 1.0987654321 357357357357}
test link-2.2 {writing bad values into variables} {testlink} {
testlink delete
testlink set 43 1.23 4 - 56785678 64 250 30000 60000 0xbeefbabe 12321 32123 3.25 1231231234
diff --git a/tests/mathop.test b/tests/mathop.test
index 8bbebd9..7fe140b 100644
--- a/tests/mathop.test
+++ b/tests/mathop.test
@@ -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: mathop.test,v 1.9 2007/09/09 16:51:19 dgp Exp $
+# RCS: @(#) $Id: mathop.test,v 1.10 2007/10/15 21:27:50 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -127,10 +127,10 @@ namespace eval ::testmathop {
+ 0 nan
} -result {can't use non-numeric floating-point value as operand of "+"}
test mathop-1.15 {compiled +: errors} -returnCodes error -body {
- + 08 0
+ + 0o8 0
} -result {can't use invalid octal number as operand of "+"}
test mathop-1.16 {compiled +: errors} -returnCodes error -body {
- + 0 08
+ + 0 0o8
} -result {can't use invalid octal number as operand of "+"}
test mathop-1.17 {compiled +: errors} -returnCodes error -body {
+ 0 [error expectedError]
@@ -165,10 +165,10 @@ namespace eval ::testmathop {
$op 0 nan
} -result {can't use non-numeric floating-point value as operand of "+"}
test mathop-1.33 {interpreted +: errors} -returnCodes error -body {
- $op 08 0
+ $op 0o8 0
} -result {can't use invalid octal number as operand of "+"}
test mathop-1.34 {interpreted +: errors} -returnCodes error -body {
- $op 0 08
+ $op 0 0o8
} -result {can't use invalid octal number as operand of "+"}
test mathop-1.35 {interpreted +: errors} -returnCodes error -body {
$op 0 [error expectedError]
@@ -202,10 +202,10 @@ namespace eval ::testmathop {
* 0 nan
} -result {can't use non-numeric floating-point value as operand of "*"}
test mathop-2.15 {compiled *: errors} -returnCodes error -body {
- * 08 0
+ * 0o8 0
} -result {can't use invalid octal number as operand of "*"}
test mathop-2.16 {compiled *: errors} -returnCodes error -body {
- * 0 08
+ * 0 0o8
} -result {can't use invalid octal number as operand of "*"}
test mathop-2.17 {compiled *: errors} -returnCodes error -body {
* 0 [error expectedError]
@@ -240,10 +240,10 @@ namespace eval ::testmathop {
$op 0 nan
} -result {can't use non-numeric floating-point value as operand of "*"}
test mathop-2.33 {interpreted *: errors} -returnCodes error -body {
- $op 08 0
+ $op 0o8 0
} -result {can't use invalid octal number as operand of "*"}
test mathop-2.34 {interpreted *: errors} -returnCodes error -body {
- $op 0 08
+ $op 0 0o8
} -result {can't use invalid octal number as operand of "*"}
test mathop-2.35 {interpreted *: errors} -returnCodes error -body {
$op 0 [error expectedError]
@@ -384,9 +384,9 @@ namespace eval ::testmathop {
& 1 2 3.0
} -result {can't use floating-point value as operand of "&"}
test mathop-6.7 {compiled &} { & 100000000002 18 -126 } 2
- test mathop-6.8 {compiled &} { & 0xff 0377 333333333333 } 85
+ test mathop-6.8 {compiled &} { & 0xff 0o377 333333333333 } 85
test mathop-6.9 {compiled &} { & 1000000000000000000002 18 -126 } 2
- test mathop-6.10 {compiled &} { & 0xff 0377 3333333333333333333333 } 85
+ test mathop-6.10 {compiled &} { & 0xff 0o377 3333333333333333333333 } 85
test mathop-6.11 {compiled &: errors} -returnCodes error -body {
& x 0
} -result {can't use non-numeric string as operand of "&"}
@@ -400,10 +400,10 @@ namespace eval ::testmathop {
& 0 nan
} -result {can't use non-numeric floating-point value as operand of "&"}
test mathop-6.15 {compiled &: errors} -returnCodes error -body {
- & 08 0
+ & 0o8 0
} -result {can't use invalid octal number as operand of "&"}
test mathop-6.16 {compiled &: errors} -returnCodes error -body {
- & 0 08
+ & 0 0o8
} -result {can't use invalid octal number as operand of "&"}
test mathop-6.17 {compiled &: errors} -returnCodes error -body {
& 0 [error expectedError]
@@ -426,9 +426,9 @@ namespace eval ::testmathop {
$op 1 2 3.0
} -result {can't use floating-point value as operand of "&"}
test mathop-6.25 {interpreted &} { $op 100000000002 18 -126 } 2
- test mathop-6.26 {interpreted &} { $op 0xff 0377 333333333333 } 85
+ test mathop-6.26 {interpreted &} { $op 0xff 0o377 333333333333 } 85
test mathop-6.27 {interpreted &} { $op 1000000000000000000002 18 -126 } 2
- test mathop-6.28 {interpreted &} { $op 0xff 0377 3333333333333333333333 } 85
+ test mathop-6.28 {interpreted &} { $op 0xff 0o377 3333333333333333333333 } 85
test mathop-6.29 {interpreted &: errors} -returnCodes error -body {
$op x 0
} -result {can't use non-numeric string as operand of "&"}
@@ -442,10 +442,10 @@ namespace eval ::testmathop {
$op 0 nan
} -result {can't use non-numeric floating-point value as operand of "&"}
test mathop-6.33 {interpreted &: errors} -returnCodes error -body {
- $op 08 0
+ $op 0o8 0
} -result {can't use invalid octal number as operand of "&"}
test mathop-6.34 {interpreted &: errors} -returnCodes error -body {
- $op 0 08
+ $op 0 0o8
} -result {can't use invalid octal number as operand of "&"}
test mathop-6.35 {interpreted &: errors} -returnCodes error -body {
$op 0 [error expectedError]
@@ -494,9 +494,9 @@ namespace eval ::testmathop {
| 1 2 3.0
} -result {can't use floating-point value as operand of "|"}
test mathop-7.7 {compiled |} { | 100000000002 18 -126 } -110
- test mathop-7.8 {compiled |} { | 0xff 0377 333333333333 } 333333333503
+ test mathop-7.8 {compiled |} { | 0xff 0o377 333333333333 } 333333333503
test mathop-7.9 {compiled |} { | 1000000000000000000002 18 -126 } -110
- test mathop-7.10 {compiled |} { | 0xff 0377 3333333333333333333333 } 3333333333333333333503
+ test mathop-7.10 {compiled |} { | 0xff 0o377 3333333333333333333333 } 3333333333333333333503
test mathop-7.11 {compiled |: errors} -returnCodes error -body {
| x 0
} -result {can't use non-numeric string as operand of "|"}
@@ -510,10 +510,10 @@ namespace eval ::testmathop {
| 0 nan
} -result {can't use non-numeric floating-point value as operand of "|"}
test mathop-7.15 {compiled |: errors} -returnCodes error -body {
- | 08 0
+ | 0o8 0
} -result {can't use invalid octal number as operand of "|"}
test mathop-7.16 {compiled |: errors} -returnCodes error -body {
- | 0 08
+ | 0 0o8
} -result {can't use invalid octal number as operand of "|"}
test mathop-7.17 {compiled |: errors} -returnCodes error -body {
| 0 [error expectedError]
@@ -536,9 +536,9 @@ namespace eval ::testmathop {
$op 1 2 3.0
} -result {can't use floating-point value as operand of "|"}
test mathop-7.25 {interpreted |} { $op 100000000002 18 -126 } -110
- test mathop-7.26 {interpreted |} { $op 0xff 0377 333333333333 } 333333333503
+ test mathop-7.26 {interpreted |} { $op 0xff 0o377 333333333333 } 333333333503
test mathop-7.27 {interpreted |} { $op 1000000000000000000002 18 -126 } -110
- test mathop-7.28 {interpreted |} { $op 0xff 0377 3333333333333333333333 } 3333333333333333333503
+ test mathop-7.28 {interpreted |} { $op 0xff 0o377 3333333333333333333333 } 3333333333333333333503
test mathop-7.29 {interpreted |: errors} -returnCodes error -body {
$op x 0
} -result {can't use non-numeric string as operand of "|"}
@@ -552,10 +552,10 @@ namespace eval ::testmathop {
$op 0 nan
} -result {can't use non-numeric floating-point value as operand of "|"}
test mathop-7.33 {interpreted |: errors} -returnCodes error -body {
- $op 08 0
+ $op 0o8 0
} -result {can't use invalid octal number as operand of "|"}
test mathop-7.34 {interpreted |: errors} -returnCodes error -body {
- $op 0 08
+ $op 0 0o8
} -result {can't use invalid octal number as operand of "|"}
test mathop-7.35 {interpreted |: errors} -returnCodes error -body {
$op 0 [error expectedError]
@@ -604,9 +604,9 @@ namespace eval ::testmathop {
^ 1 2 3.0
} -result {can't use floating-point value as operand of "^"}
test mathop-8.7 {compiled ^} { ^ 100000000002 18 -126 } -100000000110
- test mathop-8.8 {compiled ^} { ^ 0xff 0377 333333333333 } 333333333333
+ test mathop-8.8 {compiled ^} { ^ 0xff 0o377 333333333333 } 333333333333
test mathop-8.9 {compiled ^} { ^ 1000000000000000000002 18 -126 } -1000000000000000000110
- test mathop-8.10 {compiled ^} { ^ 0xff 0377 3333333333333333333333 } 3333333333333333333333
+ test mathop-8.10 {compiled ^} { ^ 0xff 0o377 3333333333333333333333 } 3333333333333333333333
test mathop-8.11 {compiled ^: errors} -returnCodes error -body {
^ x 0
} -result {can't use non-numeric string as operand of "^"}
@@ -620,10 +620,10 @@ namespace eval ::testmathop {
^ 0 nan
} -result {can't use non-numeric floating-point value as operand of "^"}
test mathop-8.15 {compiled ^: errors} -returnCodes error -body {
- ^ 08 0
+ ^ 0o8 0
} -result {can't use invalid octal number as operand of "^"}
test mathop-8.16 {compiled ^: errors} -returnCodes error -body {
- ^ 0 08
+ ^ 0 0o8
} -result {can't use invalid octal number as operand of "^"}
test mathop-8.17 {compiled ^: errors} -returnCodes error -body {
^ 0 [error expectedError]
@@ -646,9 +646,9 @@ namespace eval ::testmathop {
$op 1 2 3.0
} -result {can't use floating-point value as operand of "^"}
test mathop-8.25 {interpreted ^} { $op 100000000002 18 -126 } -100000000110
- test mathop-8.26 {interpreted ^} { $op 0xff 0377 333333333333 } 333333333333
+ test mathop-8.26 {interpreted ^} { $op 0xff 0o377 333333333333 } 333333333333
test mathop-8.27 {interpreted ^} { $op 1000000000000000000002 18 -126 } -1000000000000000000110
- test mathop-8.28 {interpreted ^} { $op 0xff 0377 3333333333333333333333 } 3333333333333333333333
+ test mathop-8.28 {interpreted ^} { $op 0xff 0o377 3333333333333333333333 } 3333333333333333333333
test mathop-8.29 {interpreted ^: errors} -returnCodes error -body {
$op x 0
} -result {can't use non-numeric string as operand of "^"}
@@ -662,10 +662,10 @@ namespace eval ::testmathop {
$op 0 nan
} -result {can't use non-numeric floating-point value as operand of "^"}
test mathop-8.33 {interpreted ^: errors} -returnCodes error -body {
- $op 08 0
+ $op 0o8 0
} -result {can't use invalid octal number as operand of "^"}
test mathop-8.34 {interpreted ^: errors} -returnCodes error -body {
- $op 0 08
+ $op 0 0o8
} -result {can't use invalid octal number as operand of "^"}
test mathop-8.35 {interpreted ^: errors} -returnCodes error -body {
$op 0 [error expectedError]
diff --git a/tests/parseExpr.test b/tests/parseExpr.test
index 3a79fcb..66fdfcc 100644
--- a/tests/parseExpr.test
+++ b/tests/parseExpr.test
@@ -8,7 +8,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: parseExpr.test,v 1.27 2007/08/06 20:21:00 dgp Exp $
+# RCS: @(#) $Id: parseExpr.test,v 1.28 2007/10/15 21:27:50 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -590,7 +590,7 @@ test parseExpr-16.5 {GetLexeme procedure, integer lexeme too big} testexprparser
testexprparser {12345678901234567890} -1
} {- {} 0 subexpr 12345678901234567890 1 text 12345678901234567890 0 {}}
test parseExpr-16.6 {GetLexeme procedure, bad integer lexeme} -constraints testexprparser -body {
- testexprparser {0999} -1
+ testexprparser {0o999} -1
} -returnCodes error -match glob -result {*invalid octal number*}
test parseExpr-16.7 {GetLexeme procedure, double lexeme} testexprparser {
testexprparser {0.999} -1
@@ -762,15 +762,11 @@ test parseExpr-21.6 {error messages} -body {
} -returnCodes error -result {missing operator at _@_
in expression "0 _@_0"}
test parseExpr-21.7 {error messages} -body {
- expr {08}
-} -returnCodes error -result {missing operator at _@_
-in expression "0_@_8";
-looks like invalid octal number}
+ expr {0o8}
+} -returnCodes error -match glob -result {*invalid octal number*}
test parseExpr-21.8 {error messages} -body {
- expr {08x}
-} -returnCodes error -result {missing operator at _@_
-in expression "0_@_8x";
-looks like invalid octal number}
+ expr {0o8x}
+} -returnCodes error -match glob -result {*invalid octal number*}
test parseExpr-21.9 {error messages} -body {
expr {"}
} -returnCodes error -result {missing "
diff --git a/tests/set.test b/tests/set.test
index f57eb50..3ac1560 100644
--- a/tests/set.test
+++ b/tests/set.test
@@ -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: set.test,v 1.11 2006/10/09 19:15:45 msofer Exp $
+# RCS: @(#) $Id: set.test,v 1.12 2007/10/15 21:27:50 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -190,9 +190,9 @@ test set-1.22 {TclCompileSetCmd: doing assignment, large int} {
} 200000
test set-1.23 {TclCompileSetCmd: doing assignment, formatted int != int} {
set i 25
- set i 000012345 ;# an octal literal == 5349 decimal
+ set i 0o00012345 ;# an octal literal == 5349 decimal
list $i [incr i]
-} {000012345 5350}
+} {0o00012345 5350}
test set-1.24 {TclCompileSetCmd: too many arguments} {
set i 10
@@ -465,9 +465,9 @@ test set-3.22 {uncompiled set command: doing assignment, large int} {
test set-3.23 {uncompiled set command: doing assignment, formatted int != int} {
set z set
$z i 25
- $z i 000012345 ;# an octal literal == 5349 decimal
+ $z i 0o00012345 ;# an octal literal == 5349 decimal
list $i [incr i]
-} {000012345 5350}
+} {0o00012345 5350}
test set-3.24 {uncompiled set command: too many arguments} {
set z set
diff --git a/tests/string.test b/tests/string.test
index e408048..8cf93b7 100644
--- a/tests/string.test
+++ b/tests/string.test
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: string.test,v 1.64 2007/10/11 21:35:01 dgp Exp $
+# RCS: @(#) $Id: string.test,v 1.65 2007/10/15 21:27:50 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -274,12 +274,12 @@ test string-5.16 {string index, bytearray object with string obj shimmering} {
binary scan $str H* dump
string compare [string index $str 10] \x00
} 0
-test string-5.17 {string index, bad integer} {
- list [catch {string index "abc" 08} msg] $msg
-} {1 {bad index "08": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
-test string-5.18 {string index, bad integer} {
- list [catch {string index "abc" end-00289} msg] $msg
-} {1 {bad index "end-00289": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
+test string-5.17 {string index, bad integer} -body {
+ list [catch {string index "abc" 0o8} msg] $msg
+} -match glob -result {1 {*invalid octal number*}}
+test string-5.18 {string index, bad integer} -body {
+ list [catch {string index "abc" end-0o0289} msg] $msg
+} -match glob -result {1 {*invalid octal number*}}
test string-5.19 {string index, bytearray object out of bounds} {
string index [binary format I* {0x50515253 0x52}] -1
} {}
@@ -480,8 +480,8 @@ test string-6.57 {string is integer, false} {
list [string is integer -fail var " "] $var
} {0 0}
test string-6.58 {string is integer, false on bad octal} {
- list [string is integer -fail var 036963] $var
-} {0 3}
+ list [string is integer -fail var 0o36963] $var
+} {0 4}
test string-6.58.1 {string is integer, false on bad octal} {
list [string is integer -fail var 0o36963] $var
} {0 4}
@@ -650,8 +650,8 @@ test string-6.104 {string is wideinteger, false} {
list [string is wideinteger -fail var " "] $var
} {0 0}
test string-6.105 {string is wideinteger, false on bad octal} {
- list [string is wideinteger -fail var 036963] $var
-} {0 3}
+ list [string is wideinteger -fail var 0o36963] $var
+} {0 4}
test string-6.105.1 {string is wideinteger, false on bad octal} {
list [string is wideinteger -fail var 0o36963] $var
} {0 4}
diff --git a/tests/stringComp.test b/tests/stringComp.test
index 42cf5f4..961557b 100644
--- a/tests/stringComp.test
+++ b/tests/stringComp.test
@@ -15,7 +15,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: stringComp.test,v 1.12 2007/06/08 20:56:42 dkf Exp $
+# RCS: @(#) $Id: stringComp.test,v 1.13 2007/10/15 21:27:50 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -349,14 +349,14 @@ test stringComp-5.16 {string index, bytearray object with string obj shimmering}
}
foo
} 0
-test stringComp-5.17 {string index, bad integer} {
- proc foo {} {string index "abc" 08}
+test stringComp-5.17 {string index, bad integer} -body {
+ proc foo {} {string index "abc" 0o8}
list [catch {foo} msg] $msg
-} {1 {bad index "08": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
-test stringComp-5.18 {string index, bad integer} {
- proc foo {} {string index "abc" end-00289}
+} -match glob -result {1 {*invalid octal number*}}
+test stringComp-5.18 {string index, bad integer} -body {
+ proc foo {} {string index "abc" end-0o0289}
list [catch {foo} msg] $msg
-} {1 {bad index "end-00289": must be integer?[+-]integer? or end?[+-]integer? (looks like invalid octal number)}}
+} -match glob -result {1 {*invalid octal number*}}
test stringComp-5.19 {string index, bytearray object out of bounds} {
proc foo {} {string index [binary format I* {0x50515253 0x52}] -1}
foo
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"