summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorericm <ericm>2000-07-25 00:05:40 (GMT)
committerericm <ericm>2000-07-25 00:05:40 (GMT)
commitc6bc600d803dbcb3b90be56c4653c52add4ba9b3 (patch)
tree29db30b6a07a41cbf1c7cbac313ba0defcbf7d1d /generic/tkText.c
parent5649a675dfb76712afa08a8711459fc263bdbeb3 (diff)
downloadtk-c6bc600d803dbcb3b90be56c4653c52add4ba9b3.zip
tk-c6bc600d803dbcb3b90be56c4653c52add4ba9b3.tar.gz
tk-c6bc600d803dbcb3b90be56c4653c52add4ba9b3.tar.bz2
* tests/text.test: Added tests for -regexp -nocase searches with
backslash character classes. * generic/tkText.c (TextSearchCmd): Text search did not work properly when -regexp and -nocase were used, in combination with backslash character classes represented by capital letters (ie, \W, \M); altered implementation of -regexp -nocase searches to use new regexp interfaces to fix this problem. [Bug: 5988].
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index cd5cac0..2ab2e2a 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.16 2000/07/21 23:44:11 ericm Exp $
+ * RCS: @(#) $Id: tkText.c,v 1.17 2000/07/25 00:05:40 ericm Exp $
*/
#include "default.h"
@@ -1673,6 +1673,7 @@ TextSearchCmd(textPtr, interp, argc, argv)
TkTextSegment *segPtr;
TkTextLine *linePtr;
TkTextIndex curIndex;
+ Tcl_Obj *patObj = NULL;
Tcl_RegExp regexp = NULL; /* Initialization needed only to
* prevent compiler warning. */
@@ -1748,7 +1749,7 @@ TextSearchCmd(textPtr, interp, argc, argv)
* Convert the pattern to lower-case if we're supposed to ignore case.
*/
- if (noCase) {
+ if (noCase && exact) {
Tcl_DStringInit(&patDString);
Tcl_DStringAppend(&patDString, pattern, -1);
pattern = Tcl_DStringValue(&patDString);
@@ -1798,7 +1799,10 @@ TextSearchCmd(textPtr, interp, argc, argv)
if (exact) {
patLength = strlen(pattern);
} else {
- regexp = Tcl_RegExpCompile(interp, pattern);
+ patObj = Tcl_NewStringObj(pattern, -1);
+ Tcl_IncrRefCount(patObj);
+ regexp = Tcl_GetRegExpFromObj(interp, patObj,
+ (noCase ? TCL_REG_NOCASE : 0) | TCL_REG_ADVANCED);
if (regexp == NULL) {
code = TCL_ERROR;
goto done;
@@ -2031,9 +2035,12 @@ TextSearchCmd(textPtr, interp, argc, argv)
}
done:
Tcl_DStringFree(&line);
- if (noCase) {
+ if (noCase && exact) {
Tcl_DStringFree(&patDString);
}
+ if (patObj != NULL) {
+ Tcl_DecrRefCount(patObj);
+ }
return code;
}