summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2012-11-15 21:04:23 (GMT)
committerdgp <dgp@users.sourceforge.net>2012-11-15 21:04:23 (GMT)
commita8c5c2b21e0c8d54e1a5e9814db08fb024e8a8b2 (patch)
treecb3d6c693c2cf27d6140004125160ad28524fa36
parent03474bd5446a2a6316815ec851906f9e5118eb97 (diff)
downloadtcl-a8c5c2b21e0c8d54e1a5e9814db08fb024e8a8b2.zip
tcl-a8c5c2b21e0c8d54e1a5e9814db08fb024e8a8b2.tar.gz
tcl-a8c5c2b21e0c8d54e1a5e9814db08fb024e8a8b2.tar.bz2
Goodbye to [case].
-rw-r--r--doc/case.n60
-rw-r--r--generic/tclBasic.c3
-rw-r--r--generic/tclCmdAH.c137
-rw-r--r--generic/tclInt.h3
-rw-r--r--tests/case.test89
-rw-r--r--tests/cmdAH.test2
6 files changed, 0 insertions, 294 deletions
diff --git a/doc/case.n b/doc/case.n
deleted file mode 100644
index 0155a61..0000000
--- a/doc/case.n
+++ /dev/null
@@ -1,60 +0,0 @@
-'\"
-'\" Copyright (c) 1993 The Regents of the University of California.
-'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-.so man.macros
-.TH case n 7.0 Tcl "Tcl Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-case \- Evaluate one of several scripts, depending on a given value
-.SH SYNOPSIS
-\fBcase\fI string \fR?\fBin\fR? \fIpatList body \fR?\fIpatList body \fR...?
-.sp
-\fBcase\fI string \fR?\fBin\fR? {\fIpatList body \fR?\fIpatList body \fR...?}
-.BE
-
-.SH DESCRIPTION
-.PP
-\fINote: the \fBcase\fI command is obsolete and is supported only
-for backward compatibility. At some point in the future it may be
-removed entirely. You should use the \fBswitch\fI command instead.\fR
-.PP
-The \fBcase\fR command matches \fIstring\fR against each of
-the \fIpatList\fR arguments in order.
-Each \fIpatList\fR argument is a list of one or
-more patterns. If any of these patterns matches \fIstring\fR then
-\fBcase\fR evaluates the following \fIbody\fR argument
-by passing it recursively to the Tcl interpreter and returns the result
-of that evaluation.
-Each \fIpatList\fR argument consists of a single
-pattern or list of patterns. Each pattern may contain any of the wild-cards
-described under \fBstring match\fR. If a \fIpatList\fR
-argument is \fBdefault\fR, the corresponding body will be evaluated
-if no \fIpatList\fR matches \fIstring\fR. If no \fIpatList\fR argument
-matches \fIstring\fR and no default is given, then the \fBcase\fR
-command returns an empty string.
-.PP
-Two syntaxes are provided for the \fIpatList\fR and \fIbody\fR arguments.
-The first uses a separate argument for each of the patterns and commands;
-this form is convenient if substitutions are desired on some of the
-patterns or commands.
-The second form places all of the patterns and commands together into
-a single argument; the argument must have proper list structure, with
-the elements of the list being the patterns and commands.
-The second form makes it easy to construct multi-line case commands,
-since the braces around the whole list make it unnecessary to include a
-backslash at the end of each line.
-Since the \fIpatList\fR arguments are in braces in the second form,
-no command or variable substitutions are performed on them; this makes
-the behavior of the second form different than the first form in some
-cases.
-
-.SH "SEE ALSO"
-switch(n)
-
-.SH KEYWORDS
-case, match, regular expression
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index bce6479..1ee514e 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -205,9 +205,6 @@ static const CmdInfo builtInCmds[] = {
{"append", Tcl_AppendObjCmd, TclCompileAppendCmd, NULL, 1},
{"apply", Tcl_ApplyObjCmd, NULL, TclNRApplyObjCmd, 1},
{"break", Tcl_BreakObjCmd, TclCompileBreakCmd, NULL, 1},
-#ifndef EXCLUDE_OBSOLETE_COMMANDS
- {"case", Tcl_CaseObjCmd, NULL, NULL, 1},
-#endif
{"catch", Tcl_CatchObjCmd, TclCompileCatchCmd, TclNRCatchObjCmd, 1},
{"concat", Tcl_ConcatObjCmd, NULL, NULL, 1},
{"continue", Tcl_ContinueObjCmd, TclCompileContinueCmd, NULL, 1},
diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c
index 14951e4..ee1f97a 100644
--- a/generic/tclCmdAH.c
+++ b/generic/tclCmdAH.c
@@ -132,143 +132,6 @@ Tcl_BreakObjCmd(
/*
*----------------------------------------------------------------------
*
- * Tcl_CaseObjCmd --
- *
- * This procedure is invoked to process the "case" Tcl command. See the
- * user documentation for details on what it does. THIS COMMAND IS
- * OBSOLETE AND DEPRECATED. SLATED FOR REMOVAL IN TCL 9.0.
- *
- * Results:
- * A standard Tcl object result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-Tcl_CaseObjCmd(
- ClientData dummy, /* Not used. */
- Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. */
-{
- register int i;
- int body, result, caseObjc;
- const char *stringPtr, *arg;
- Tcl_Obj *const *caseObjv;
- Tcl_Obj *armPtr;
-
- if (objc < 3) {
- Tcl_WrongNumArgs(interp, 1, objv,
- "string ?in? ?pattern body ...? ?default body?");
- return TCL_ERROR;
- }
-
- stringPtr = TclGetString(objv[1]);
- body = -1;
-
- arg = TclGetString(objv[2]);
- if (strcmp(arg, "in") == 0) {
- i = 3;
- } else {
- i = 2;
- }
- caseObjc = objc - i;
- caseObjv = objv + i;
-
- /*
- * If all of the pattern/command pairs are lumped into a single argument,
- * split them out again.
- */
-
- if (caseObjc == 1) {
- Tcl_Obj **newObjv;
-
- TclListObjGetElements(interp, caseObjv[0], &caseObjc, &newObjv);
- caseObjv = newObjv;
- }
-
- for (i = 0; i < caseObjc; i += 2) {
- int patObjc, j;
- const char **patObjv;
- const char *pat;
- unsigned char *p;
-
- if (i == caseObjc-1) {
- Tcl_ResetResult(interp);
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "extra case pattern with no body", -1));
- return TCL_ERROR;
- }
-
- /*
- * Check for special case of single pattern (no list) with no
- * backslash sequences.
- */
-
- pat = TclGetString(caseObjv[i]);
- for (p = (unsigned char *) pat; *p != '\0'; p++) {
- if (isspace(*p) || (*p == '\\')) { /* INTL: ISO space, UCHAR */
- break;
- }
- }
- if (*p == '\0') {
- if ((*pat == 'd') && (strcmp(pat, "default") == 0)) {
- body = i + 1;
- }
- if (Tcl_StringMatch(stringPtr, pat)) {
- body = i + 1;
- goto match;
- }
- continue;
- }
-
- /*
- * Break up pattern lists, then check each of the patterns in the
- * list.
- */
-
- result = Tcl_SplitList(interp, pat, &patObjc, &patObjv);
- if (result != TCL_OK) {
- return result;
- }
- for (j = 0; j < patObjc; j++) {
- if (Tcl_StringMatch(stringPtr, patObjv[j])) {
- body = i + 1;
- break;
- }
- }
- ckfree(patObjv);
- if (j < patObjc) {
- break;
- }
- }
-
- match:
- if (body != -1) {
- armPtr = caseObjv[body - 1];
- result = Tcl_EvalObjEx(interp, caseObjv[body], 0);
- if (result == TCL_ERROR) {
- Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
- "\n (\"%.50s\" arm line %d)",
- TclGetString(armPtr), Tcl_GetErrorLine(interp)));
- }
- return result;
- }
-
- /*
- * Nothing matched: return nothing.
- */
-
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* Tcl_CatchObjCmd --
*
* This object-based procedure is invoked to process the "catch" Tcl
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 1d04c82..21aa884 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3208,9 +3208,6 @@ MODULE_SCOPE Tcl_Command TclInitBinaryCmd(Tcl_Interp *interp);
MODULE_SCOPE int Tcl_BreakObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tcl_CaseObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
MODULE_SCOPE int Tcl_CatchObjCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
diff --git a/tests/case.test b/tests/case.test
deleted file mode 100644
index 6d63cea..0000000
--- a/tests/case.test
+++ /dev/null
@@ -1,89 +0,0 @@
-# Commands covered: case
-#
-# This file contains a collection of tests for one or more of the Tcl
-# built-in commands. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-#
-# Copyright (c) 1991-1993 The Regents of the University of California.
-# Copyright (c) 1994 Sun Microsystems, Inc.
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-
-if {[lsearch [namespace children] ::tcltest] == -1} {
- package require tcltest
- namespace import -force ::tcltest::*
-}
-
-test case-1.1 {simple pattern} {
- case a in a {format 1} b {format 2} c {format 3} default {format 4}
-} 1
-test case-1.2 {simple pattern} {
- case b a {format 1} b {format 2} c {format 3} default {format 4}
-} 2
-test case-1.3 {simple pattern} {
- case x in a {format 1} b {format 2} c {format 3} default {format 4}
-} 4
-test case-1.4 {simple pattern} {
- case x a {format 1} b {format 2} c {format 3}
-} {}
-test case-1.5 {simple pattern matches many times} {
- case b a {format 1} b {format 2} b {format 3} b {format 4}
-} 2
-test case-1.6 {fancier pattern} {
- case cx a {format 1} *c {format 2} *x {format 3} default {format 4}
-} 3
-test case-1.7 {list of patterns} {
- case abc in {a b c} {format 1} {def abc ghi} {format 2}
-} 2
-
-test case-2.1 {error in executed command} {
- list [catch {case a in a {error "Just a test"} default {format 1}} msg] \
- $msg $::errorInfo
-} {1 {Just a test} {Just a test
- while executing
-"error "Just a test""
- ("a" arm line 1)
- invoked from within
-"case a in a {error "Just a test"} default {format 1}"}}
-test case-2.2 {error: not enough args} {
- list [catch {case} msg] $msg
-} {1 {wrong # args: should be "case string ?in? ?pattern body ...? ?default body?"}}
-test case-2.3 {error: pattern with no body} {
- list [catch {case a b} msg] $msg
-} {1 {extra case pattern with no body}}
-test case-2.4 {error: pattern with no body} {
- list [catch {case a in b {format 1} c} msg] $msg
-} {1 {extra case pattern with no body}}
-test case-2.5 {error in default command} {
- list [catch {case foo in a {error case1} default {error case2} \
- b {error case 3}} msg] $msg $::errorInfo
-} {1 case2 {case2
- while executing
-"error case2"
- ("default" arm line 1)
- invoked from within
-"case foo in a {error case1} default {error case2} b {error case 3}"}}
-
-test case-3.1 {single-argument form for pattern/command pairs} {
- case b in {
- a {format 1}
- b {format 2}
- default {format 6}
- }
-} {2}
-test case-3.2 {single-argument form for pattern/command pairs} {
- case b {
- a {format 1}
- b {format 2}
- default {format 6}
- }
-} {2}
-test case-3.3 {single-argument form for pattern/command pairs} {
- list [catch {case z in {a 2 b}} msg] $msg
-} {1 {extra case pattern with no body}}
-
-# cleanup
-::tcltest::cleanupTests
-return
diff --git a/tests/cmdAH.test b/tests/cmdAH.test
index 2ecf626..3011597 100644
--- a/tests/cmdAH.test
+++ b/tests/cmdAH.test
@@ -59,8 +59,6 @@ test cmdAH-0.2 {Tcl_BreakObjCmd, success} {
list [catch {break} msg] $msg
} {3 {}}
-# Tcl_CaseObjCmd is tested in case.test
-
test cmdAH-1.1 {Tcl_CatchObjCmd, errors} -returnCodes error -body {
catch
} -result {wrong # args: should be "catch script ?resultVarName? ?optionVarName?"}