Overview
| Artifact ID: | e3f0c20fa40a2c90260d22d049a3eb3666a4bb46 |
|---|---|
| Ticket: | 218695ffffffffffffffffffffffffffffffffff
add array unset subcommand. |
| User & Date: | nobody on 2000-10-26 01:04:13 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 1775 RFE Version: 8.0.5 SubmitDate: '1999-04-09' LastModified: '1999-09-15' Severity: LOW Status: Released Submitter: pat ChangedBy: hobbs OS: Solaris OSVersion: 5.5.1 Machine: Other FixedDate: '1999-09-15' FixedInVersion: 8.3b1 ClosedDate: '2000-10-25' Name: scott murdock Extensions: tclx tcl-dp img itcl Comments: This is simpler and faster than a loop to get the names to unset. The alternative of a separate array for the subset may not be appropriate for a given program. I just copied the array names code and modified it a little. The only thing about this that is specific to 8.0.5 is the patch line numbers. DesiredBehavior: enables unsetting a selected set of array elements, using a name pattern, eg. array unset foo xyz,* Patch: *** generic/tclVar.c.orig Tue Feb 2 16:55:06 1999 --- generic/tclVar.c Thu Apr 8 18:04:21 1999 *************** *** 2872,2881 **** enum {ARRAY_ANYMORE, ARRAY_DONESEARCH, ARRAY_EXISTS, ARRAY_GET, ARRAY_NAMES, ARRAY_NEXTELEMENT, ARRAY_SET, ARRAY_SIZE, ! ARRAY_STARTSEARCH}; static char *arrayOptions[] = {"anymore", "donesearch", "exists", "get", "names", "nextelement", "set", "size", "startsearch", ! (char *) NULL}; Var *varPtr, *arrayPtr; Tcl_HashEntry *hPtr; --- 2872,2881 ---- enum {ARRAY_ANYMORE, ARRAY_DONESEARCH, ARRAY_EXISTS, ARRAY_GET, ARRAY_NAMES, ARRAY_NEXTELEMENT, ARRAY_SET, ARRAY_SIZE, ! ARRAY_STARTSEARCH, ARRAY_UNSET}; static char *arrayOptions[] = {"anymore", "donesearch", "exists", "get", "names", "nextelement", "set", "size", "startsearch", ! "unset", (char *) NULL}; Var *varPtr, *arrayPtr; Tcl_HashEntry *hPtr; *************** *** 3233,3238 **** --- 3233,3271 ---- &searchPtr->search); searchPtr->nextPtr = varPtr->searchPtr; varPtr->searchPtr = searchPtr; + break; + } + case ARRAY_UNSET: { + Tcl_HashSearch search; + Var *varPtr2; + char *pattern = NULL; + char *name; + Tcl_Obj *namePtr; + + if ((objc != 3) && (objc != 4)) { + Tcl_WrongNumArgs(interp, 2, objv, "arrayName ?pattern?"); + return TCL_ERROR; + } + if (notArray) { + return TCL_OK; + } + if (objc == 4) { + pattern = Tcl_GetStringFromObj(objv[3], (int *) NULL); + } + for (hPtr = Tcl_FirstHashEntry(varPtr->value.tablePtr, &search); + hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { + varPtr2 = (Var *) Tcl_GetHashValue(hPtr); + if (TclIsVarUndefined(varPtr2)) { + continue; + } + name = Tcl_GetHashKey(varPtr->value.tablePtr, hPtr); + if ((objc == 4) && !Tcl_StringMatch(name, pattern)) { + continue; /* element name doesn't match pattern */ + } + if (Tcl_UnsetVar2(interp, varName, name, 0) != TCL_OK) { + return TCL_ERROR; + } + } break; } } PatchFiles: generic/tclVar.c Added to 8.3 with minor mods. -- 09/15/1999 hobbs - foundin changed to: "final: 8.0.5"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "69. Other"
- title changed to: "add array unset subcommand."
- type changed to: "RFE"