summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>2000-06-01 00:33:27 (GMT)
committerhobbs <hobbs>2000-06-01 00:33:27 (GMT)
commit58476f96744cb7143b4129af3d1978f949d8b474 (patch)
tree27af8e10e0015c6de9e8f5eafcd39254d32ca5b9 /generic
parentfb987e05c7e3613f4a27e0f9262e29cbda36e51a (diff)
downloadtcl-58476f96744cb7143b4129af3d1978f949d8b474.zip
tcl-58476f96744cb7143b4129af3d1978f949d8b474.tar.gz
tcl-58476f96744cb7143b4129af3d1978f949d8b474.tar.bz2
* tests/set-old.test:
* doc/unset.n: * generic/tclVar.c (Tcl_UnsetObjCmd): added -nocomplain and -- options to unset, to allow for a silent unset operation.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclVar.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 8c279a0..8147f45 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.18 2000/05/31 15:03:34 ericm Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.19 2000/06/01 00:33:27 hobbs Exp $
*/
#include "tclInt.h"
@@ -2589,18 +2589,34 @@ Tcl_UnsetObjCmd(dummy, interp, objc, objv)
int objc; /* Number of arguments. */
Tcl_Obj *CONST objv[]; /* Argument objects. */
{
- register int i;
+ register int i, flags = TCL_LEAVE_ERR_MSG;
register char *name;
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "varName ?varName ...?");
+ Tcl_WrongNumArgs(interp, 1, objv,
+ "?--? ?-nocomplain? ?varName varName ...?");
return TCL_ERROR;
}
-
- for (i = 1; i < objc; i++) {
+
+ /*
+ * Very simple, restrictive argument parsing. The only options are
+ * -- and -nocomplain (which must come first to be an option).
+ */
+ i = 1;
+ name = TclGetString(objv[i]);
+ if ((name[0] == '-') && (strcmp("-nocomplain", name) == 0)) {
+ flags = 0;
+ i++;
+ name = TclGetString(objv[i]);
+ }
+ if ((name[0] == '-') && (strcmp("--", name) == 0)) {
+ i++;
+ }
+
+ for (; i < objc; i++) {
name = TclGetString(objv[i]);
- if (Tcl_UnsetVar2(interp, name, (char *) NULL,
- TCL_LEAVE_ERR_MSG) != TCL_OK) {
+ if ((Tcl_UnsetVar2(interp, name, (char *) NULL, flags) != TCL_OK)
+ && (flags == TCL_LEAVE_ERR_MSG)) {
return TCL_ERROR;
}
}