summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--generic/tkText.c49
-rw-r--r--tests/text.test4
-rw-r--r--tests/textImage.test6
4 files changed, 37 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 90df1a8..da7eb59 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2003-05-19 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+ * tests/textImage.test: Fixed faults in option parsing and
+ * tests/text.test: made tests conformant. [Bug 739965]
+ * generic/tkText.c (TextSearchCmd):
+
* library/demos/en.msg: Base catalog for the widget demo.
* library/demos/widget: Added message-catalog support.
* library/console.tcl: Reworked to use tk::AmpMenuArgs and be more
diff --git a/generic/tkText.c b/generic/tkText.c
index 377217f..b6fbcbe 100644
--- a/generic/tkText.c
+++ b/generic/tkText.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: tkText.c,v 1.35 2003/05/19 14:37:20 dkf Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.36 2003/05/19 21:19:51 dkf Exp $
*/
#include "default.h"
@@ -2107,8 +2107,8 @@ TextSearchCmd(textPtr, interp, objc, objv)
SearchSpec searchSpec;
static CONST char *switchStrings[] = {
- "--", "-all", "-backward", "-count", "-elide", "-exact",
- "-forward", "-hidden", "-nocase", "-nolinestop", "-regexp", NULL
+ "--", "-all", "-backwards", "-count", "-elide", "-exact",
+ "-forwards", "-hidden", "-nocase", "-nolinestop", "-regexp", NULL
};
enum SearchSwitches {
SEARCH_END, SEARCH_ALL, SEARCH_BACK, SEARCH_COUNT, SEARCH_ELIDE,
@@ -2139,7 +2139,7 @@ TextSearchCmd(textPtr, interp, objc, objv)
* Parse switches and other arguments.
*/
- for (i = 2; i < objc; i++) {
+ for (i=2 ; i<objc ; i++) {
int index;
if (Tcl_GetString(objv[i])[0] != '-') {
break;
@@ -2151,10 +2151,10 @@ TextSearchCmd(textPtr, interp, objc, objv)
* Hide the -hidden option
*/
Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad switch \"", objv[i],
- "\": must be --, -all, -backward, -count, ",
- "-elide, -exact, -forward, -nocase, ",
- "-nolinestop, or -regexp", (char *) NULL);
+ Tcl_AppendResult(interp, "bad switch \"", Tcl_GetString(objv[i]),
+ "\": must be --, -all, -backward, -count, -elide, ",
+ "-exact, -forward, -nocase, -nolinestop, or -regexp",
+ (char *) NULL);
return TCL_ERROR;
}
@@ -2208,16 +2208,17 @@ TextSearchCmd(textPtr, interp, objc, objv)
argsLeft = objc - (i+2);
if ((argsLeft != 0) && (argsLeft != 1)) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "?switches? pattern index ?stopIndex?");
+ Tcl_WrongNumArgs(interp, 2, objv,
+ "?switches? pattern index ?stopIndex?");
return TCL_ERROR;
}
-
+
if (searchSpec.noLineStop && searchSpec.exact) {
- Tcl_SetResult(interp, "the \"-nolinestop\" option requires the \"-regexp\" option to be present", TCL_STATIC);
+ Tcl_SetResult(interp, "the \"-nolinestop\" option requires the "
+ "\"-regexp\" option to be present", TCL_STATIC);
return TCL_ERROR;
}
-
+
/*
* Scan through all of the lines of the text circularly, starting
* at the given index. 'objv[i]' is the pattern which may be an
@@ -2226,25 +2227,31 @@ TextSearchCmd(textPtr, interp, objc, objv)
*/
code = SearchPerform(interp, &searchSpec, objv[i], objv[i+1],
- (argsLeft == 1 ? objv[i+2] : NULL));
- if (code != TCL_OK) goto cleanup;
-
- /* Set the '-count' variable, if given */
+ (argsLeft == 1 ? objv[i+2] : NULL));
+ if (code != TCL_OK) {
+ goto cleanup;
+ }
+
+ /*
+ * Set the '-count' variable, if given.
+ */
if (searchSpec.varPtr != NULL && searchSpec.countPtr != NULL) {
Tcl_IncrRefCount(searchSpec.countPtr);
if (Tcl_ObjSetVar2(interp, searchSpec.varPtr, NULL,
- searchSpec.countPtr, TCL_LEAVE_ERR_MSG) == NULL) {
+ searchSpec.countPtr, TCL_LEAVE_ERR_MSG) == NULL) {
code = TCL_ERROR;
goto cleanup;
}
}
-
- /* Set the result */
+
+ /*
+ * Set the result
+ */
if (searchSpec.resPtr != NULL) {
Tcl_SetObjResult(interp, searchSpec.resPtr);
searchSpec.resPtr = NULL;
}
-
+
cleanup:
if (searchSpec.countPtr != NULL) {
Tcl_DecrRefCount(searchSpec.countPtr);
diff --git a/tests/text.test b/tests/text.test
index f3d5772..6f8a72e 100644
--- a/tests/text.test
+++ b/tests/text.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: text.test,v 1.21 2003/05/19 13:04:24 vincentdarley Exp $
+# RCS: @(#) $Id: text.test,v 1.22 2003/05/19 21:19:52 dkf Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -1766,7 +1766,7 @@ test text-22.3 {TextDumpCmd procedure, bad args} {
} {1 {Usage: .t dump ?-all -image -text -mark -tag -window? ?-command script? index ?index2?}}
test text-22.4 {TextDumpCmd procedure, bad args} {
list [catch {.t dump -bogus} msg] $msg
-} {1 {Usage: .t dump ?-all -image -text -mark -tag -window? ?-command script? index ?index2?}}
+} {1 {bad option "-bogus": must be -all, -command, -image, -mark, -tag, -text, or -window}}
test text-22.5 {TextDumpCmd procedure, bad args} {
list [catch {.t dump bogus} msg] $msg
} {1 {bad text index "bogus"}}
diff --git a/tests/textImage.test b/tests/textImage.test
index 73b9dc9..30cd6b7 100644
--- a/tests/textImage.test
+++ b/tests/textImage.test
@@ -7,7 +7,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: textImage.test,v 1.6 2003/04/01 21:06:54 dgp Exp $
+# RCS: @(#) $Id: textImage.test,v 1.7 2003/05/19 21:19:52 dkf Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -32,7 +32,7 @@ test textImage-1.2 {basic argument checking} {
text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0
pack .t
list [catch {.t image c} msg] $msg
-} {1 {bad image option "c": must be cget, configure, create, or names}}
+} {1 {ambiguous option "c": must be cget, configure, create, or names}}
test textImage-1.3 {cget argument checking} {
catch {destroy .t}
@@ -132,7 +132,7 @@ test textImage-1.14 {basic argument checking} {
text .t -font test_font -bd 0 -highlightthickness 0 -padx 0 -pady 0
pack .t
list [catch {.t image huh} msg] $msg
-} {1 {bad image option "huh": must be cget, configure, create, or names}}
+} {1 {bad option "huh": must be cget, configure, create, or names}}
test textImage-1.15 {align argument checking} {
catch {