summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2017-06-13 12:28:35 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2017-06-13 12:28:35 (GMT)
commit9a0f3fc06f63ce3a77d1257877bc079fa5d33d99 (patch)
treed0c5c22453d016bf52da864e549156ddbe9f4b85 /generic
parentc90a3679053d6959325eb3041f0b9b6fd011625e (diff)
downloadtcl-oo_copy_ns.zip
tcl-oo_copy_ns.tar.gz
tcl-oo_copy_ns.tar.bz2
Improve docs, add tests, fix a corner case in the implementation.oo_copy_ns
Diffstat (limited to 'generic')
-rw-r--r--generic/tclOOBasic.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c
index 798bad4..b2c06a7 100644
--- a/generic/tclOOBasic.c
+++ b/generic/tclOOBasic.c
@@ -1210,7 +1210,9 @@ TclOOCopyObjectCmd(
name = TclGetString(objv[2]);
Tcl_DStringInit(&buffer);
- if (name[0]!=':' || name[1]!=':') {
+ if (name[0] == '\0') {
+ name = NULL;
+ } else if (name[0]!=':' || name[1]!=':') {
Interp *iPtr = (Interp *) interp;
if (iPtr->varFramePtr != NULL) {
@@ -1222,13 +1224,18 @@ TclOOCopyObjectCmd(
name = Tcl_DStringValue(&buffer);
}
- /* Choose a unique namespace name if the user didn't supply one */
- namespaceName = NULL;
+ /*
+ * Choose a unique namespace name if the user didn't supply one.
+ */
+ namespaceName = NULL;
if (objc == 4) {
namespaceName = TclGetString(objv[3]);
- if (Tcl_FindNamespace(interp, namespaceName, NULL, 0) != NULL) {
+ if (namespaceName[0] == '\0') {
+ namespaceName = NULL;
+ } else if (Tcl_FindNamespace(interp, namespaceName, NULL,
+ 0) != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s refers to an existing namespace", namespaceName));
return TCL_ERROR;