Artifacts Associated With Ticket 217966
Ticket change [cd83450373] (rid 95904) by nobody on 2000-10-26 00:46:54:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 4666 RFE Version: 8.3 SubmitDate: '2000-03-28' LastModified: '2000-03-28' Severity: LOW Status: Closed Submitter: techsupp ChangedBy: ericm RelatedBugIDs: 4665 OS: Windows NT OSVersion: 4.0sp5 FixedDate: '2000-10-25' ClosedDate: '2000-03-28' Name: Vince Darley CVS: Tues March 28 2000 Comments: Compiles and runs fine on WinNT, since it's a simple generic patch, I assume it will work on Unix/MacOS too. DesiredBehavior: simple addition of 'namespace exists' so we can quickly and easily test if a namespace exists without special-casing children ns/with or without leading ::/... Patch: Index: tclNamesp.c =================================================================== RCS file: /cvsroot/tcl/generic/tclNamesp.c,v retrieving revision 1.17 diff -C3 -r1.17 tclNamesp.c *** tclNamesp.c2000/03/27 22:18:561.17 --- tclNamesp.c2000/03/29 00:01:43 *************** *** 104,109 **** --- 104,112 ---- static intNamespaceEvalCmd _ANSI_ARGS_(( ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); + static intNamespaceExistsCmd _ANSI_ARGS_(( + ClientData dummy, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[])); static intNamespaceExportCmd _ANSI_ARGS_(( ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); *************** *** 2409,2414 **** --- 2412,2418 ---- * namespace current * namespace delete ?name name...? * namespace eval name arg ?arg...? + * namespace exists name * namespace export ?-clear? ?pattern pattern...? * namespace forget ?pattern pattern...? * namespace import ?-force? ?pattern pattern...? *************** *** 2444,2455 **** { static char *subCmds[] = { "children", "code", "current", "delete", ! "eval", "export", "forget", "import", "inscope", "origin", "parent", "qualifiers", "tail", "which", (char *) NULL}; enum NSSubCmdIdx { NSChildrenIdx, NSCodeIdx, NSCurrentIdx, NSDeleteIdx, ! NSEvalIdx, NSExportIdx, NSForgetIdx, NSImportIdx, NSInscopeIdx, NSOriginIdx, NSParentIdx, NSQualifiersIdx, NSTailIdx, NSWhichIdx }; --- 2448,2459 ---- { static char *subCmds[] = { "children", "code", "current", "delete", ! "eval", "exists", "export", "forget", "import", "inscope", "origin", "parent", "qualifiers", "tail", "which", (char *) NULL}; enum NSSubCmdIdx { NSChildrenIdx, NSCodeIdx, NSCurrentIdx, NSDeleteIdx, ! NSEvalIdx, NSExistsIdx, NSExportIdx, NSForgetIdx, NSImportIdx, NSInscopeIdx, NSOriginIdx, NSParentIdx, NSQualifiersIdx, NSTailIdx, NSWhichIdx }; *************** *** 2486,2491 **** --- 2490,2498 ---- case NSEvalIdx: result = NamespaceEvalCmd(clientData, interp, objc, objv); break; + case NSExistsIdx: + result = NamespaceExistsCmd(clientData, interp, objc, objv); + break; case NSExportIdx: result = NamespaceExportCmd(clientData, interp, objc, objv); break; *************** *** 2946,2951 **** --- 2953,3006 ---- Tcl_PopCallFrame(interp); return result; + } + + /* + *---------------------------------------------------------------------- + * + * NamespaceExistsCmd -- + * + *Invoked to implement the "namespace exists" command that returns + *true if the given namespace currently exists, and false otherwise. + *Handles the following syntax: + * + * namespace exists name + * + * Results: + *Returns TCL_OK if successful, and TCL_ERROR if anything goes wrong. + * + * Side effects: + *Returns a result in the interpreter's result object. If anything + *goes wrong, the result is an error message. + * + *---------------------------------------------------------------------- + */ + + static int + NamespaceExistsCmd(dummy, interp, objc, objv) + ClientData dummy;/* Not used. */ + Tcl_Interp *interp;/* Current interpreter. */ + int objc;/* Number of arguments. */ + Tcl_Obj *CONST objv[];/* Argument objects. */ + { + Tcl_Namespace *namespacePtr; + Tcl_Obj *resultPtr; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, "name"); + return TCL_ERROR; + } + + /* + * Check whether the given namespace exists + */ + + resultPtr = Tcl_GetObjResult(interp); + if (GetNamespaceFromObj(interp, objv[2], &namespacePtr) != TCL_OK) { + return TCL_ERROR; + } + Tcl_SetBooleanObj(resultPtr, (namespacePtr == NULL) ? 0 : 1); + return TCL_OK; } /* PatchFiles: tclNamesp.c - foundin initialized to: "obsolete: 8.3"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: "patch to provide 'namespace exists' subcommand"
- type initialized to: "RFE"
Ticket change [9a0502a8c8] (rid 110886) by welch on 2000-10-26 08:10:56:
- closedate changed to: "2000-10-26T01:10:56"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [b4ed33642c] (rid 125137) by dgp on 2001-04-14 02:52:18:
- foundin changed to: "None"
- status changed to: "Open"
- subsystem changed to: "None"
Ticket change [9d2de9aeca] (rid 96266) by dgp on 2001-04-14 02:52:53:
- closedate changed to: "2001-04-13T19:52:53"
- closer changed to: "dgp"
- status changed to: "Closed"
- subsystem changed to: "21. [namespace]"