summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-06-25 12:57:50 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-06-25 12:57:50 (GMT)
commit54096927a3f71635771813b5ceb91110ac92011e (patch)
tree6f7fbc2ac8742c8c3c00c0f6ba91990ac9e00498
parent076eb7c9e473f60d3821b1fcc622f69fbb8eba14 (diff)
parent527a4f67fa396747502ba37514a882725f401110 (diff)
downloadtcl-54096927a3f71635771813b5ceb91110ac92011e.zip
tcl-54096927a3f71635771813b5ceb91110ac92011e.tar.gz
tcl-54096927a3f71635771813b5ceb91110ac92011e.tar.bz2
[Bug 3537605]: Make [encoding dirs ? ?] report the right error message.
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclCmdAH.c16
-rw-r--r--tests/encoding.test8
3 files changed, 22 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index e7f5fc3..186b70b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-25 Donal K. Fellows <dkf@users.sf.net>
+
+ * generic/tclCmdAH.c (EncodingDirsObjCmd): [Bug 3537605]: Do the right
+ thing when reporting errors with the number of arguments.
+
2012-06-25 Jan Nijtmans <nijtmans@users.sf.net>
* generic/tclfileName.c: [Patch #1536227]: Cygwin network pathname
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 4292224..6dfc705 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -629,24 +629,26 @@ EncodingDirsObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
+ Tcl_Obj *dirListObj;
+
if (objc > 3) {
- Tcl_WrongNumArgs(interp, 1, objv, "?dirList?");
+ Tcl_WrongNumArgs(interp, 2, objv, "?dirList?");
return TCL_ERROR;
}
- objc -= 1;
- objv += 1;
- if (objc == 1) {
+ if (objc == 2) {
Tcl_SetObjResult(interp, Tcl_GetEncodingSearchPath());
return TCL_OK;
}
- if (Tcl_SetEncodingSearchPath(objv[1]) == TCL_ERROR) {
+
+ dirListObj = objv[2];
+ if (Tcl_SetEncodingSearchPath(dirListObj) == TCL_ERROR) {
Tcl_AppendResult(interp, "expected directory list but got \"",
- TclGetString(objv[1]), "\"", NULL);
+ TclGetString(dirListObj), "\"", NULL);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "ENCODING", "BADPATH",
NULL);
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, objv[1]);
+ Tcl_SetObjResult(interp, dirListObj);
return TCL_OK;
}
diff --git a/tests/encoding.test b/tests/encoding.test
index 51b7aa1..b4ee7c3 100644
--- a/tests/encoding.test
+++ b/tests/encoding.test
@@ -582,6 +582,14 @@ file delete {*}[glob -directory [temporaryDirectory] *.chars *.tcltestout]
# EscapeFreeProc, GetTableEncoding, unilen are fully tested by the rest of
# this file.
+
+test encoding-27.1 {encoding dirs basic behavior} -returnCodes error -body {
+ encoding dirs ? ?
+} -result {wrong # args: should be "encoding dirs ?dirList?"}
+test encoding-27.2 {encoding dirs basic behavior} -returnCodes error -body {
+ encoding dirs "\{not a list"
+} -result "expected directory list but got \"\{not a list\""
+
}
runtests