From e2f893c45dbe2a557d9cd795832810381969813b Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 8 Jun 2007 20:41:24 +0000 Subject: Make [string first] and [string last] clearer --- ChangeLog | 7 +++++++ doc/string.n | 22 +++++++++++----------- generic/tclCmdMZ.c | 7 ++++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae9e7f6..f71dbd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-06-08 Donal K. Fellows + + * generic/tclCmdMZ.c (Tcl_StringObjCmd): Changed [string first] and + * doc/string.n: [string last] so that they have clearer descriptions + for those people who know the adage about needles and haystacks. This + follows suggestions on comp.lang.tcl... + 2007-06-06 Miguel Sofer * generic/tclParse.c: fix for uninit read [Bug 1732414]. diff --git a/doc/string.n b/doc/string.n index 9186df9..23c1e3b 100644 --- a/doc/string.n +++ b/doc/string.n @@ -5,7 +5,7 @@ .\" See the file "license.terms" for information on usage and redistribution .\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. .\" -.\" RCS: @(#) $Id: string.n,v 1.34 2006/12/19 10:25:34 dkf Exp $ +.\" RCS: @(#) $Id: string.n,v 1.35 2007/06/08 20:41:25 dkf Exp $ .\" .so man.macros .TH string n 8.1 Tcl "Tcl Built-In Commands" @@ -49,13 +49,13 @@ the first \fIlength\fR characters are used in the comparison. If \fB\-length\fR is negative, it is ignored. If \fB\-nocase\fR is specified, then the strings are compared in a case-insensitive manner. .TP -\fBstring first \fIstring1 string2\fR ?\fIstartIndex\fR? -Search \fIstring2\fR for a sequence of characters that exactly match -the characters in \fIstring1\fR. If found, return the index of the -first character in the first such match within \fIstring2\fR. If not +\fBstring first \fIneedleString haystackString\fR ?\fIstartIndex\fR? +Search \fIhaystackString\fR for a sequence of characters that exactly match +the characters in \fIneedleString\fR. If found, return the index of the +first character in the first such match within \fIhaystackString\fR. If not found, return \-1. If \fIstartIndex\fR is specified (in any of the forms accepted by the \fBindex\fR method), then the search is -constrained to start with the character in \fIstring2\fR specified by +constrained to start with the character in \fIhaystackString\fR specified by the index. For example, .RS .CS @@ -177,13 +177,13 @@ function will return 0, then the \fIvarname\fR will always be set to 0, due to the varied nature of a valid boolean value. .RE .TP -\fBstring last \fIstring1 string2\fR ?\fIlastIndex\fR? -Search \fIstring2\fR for a sequence of characters that exactly match -the characters in \fIstring1\fR. If found, return the index of the -first character in the last such match within \fIstring2\fR. If there +\fBstring last \fIneedleString haystackString\fR ?\fIlastIndex\fR? +Search \fIhaystackString\fR for a sequence of characters that exactly match +the characters in \fIneedleString\fR. If found, return the index of the +first character in the last such match within \fIhaystackString\fR. If there is no match, then return \-1. If \fIlastIndex\fR is specified (in any of the forms accepted by the \fBindex\fR method), then only the -characters in \fIstring2\fR at or before the specified \fIlastIndex\fR +characters in \fIhaystackString\fR at or before the specified \fIlastIndex\fR will be considered by the search. For example, .RS .CS diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 274d8af..f07fb78 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -15,7 +15,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdMZ.c,v 1.150 2007/05/01 20:20:44 dgp Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.151 2007/06/08 20:41:25 dkf Exp $ */ #include "tclInt.h" @@ -1286,7 +1286,8 @@ Tcl_StringObjCmd( int match, start; if (objc < 4 || objc > 5) { - Tcl_WrongNumArgs(interp, 2,objv, "subString string ?startIndex?"); + Tcl_WrongNumArgs(interp, 2, objv, + "needleString haystackString ?startIndex?"); return TCL_ERROR; } @@ -1745,7 +1746,7 @@ Tcl_StringObjCmd( if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 2, objv, - "subString string ?startIndex?"); + "needleString haystackString ?startIndex?"); return TCL_ERROR; } -- cgit v0.12