riched20: Implements FR_MATCHCASE for EM_FINDTEXT
Lei Zhang
leiz at ucla.edu
Tue Feb 21 12:19:01 CST 2006
My name is Lei Zhang. I'm a resident of Los Angeles, CA, USA, and I
currently attend UCLA. I hereby certify that I wrote this code without
copying from anyone else's sources, and I've never seen any secret
Microsoft source code.
License: LGPL
---
ChangeLog:
Implements FR_MATCHCASE for EM_FINDTEXT.
Removed todo flag from affected FR_MATCHCASE tests.
---
editor.c | 6 ++----
editor.h | 5 +++++
editstr.h | 1 +
tests/editor.c | 2 +-
4 files changed, 9 insertions(+), 5 deletions(-)
Index: dlls/riched20/editor.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/editor.c,v
retrieving revision 1.91
diff -u -r1.91 editor.c
--- dlls/riched20/editor.c 20 Feb 2006 20:19:30 -0000 1.91
+++ dlls/riched20/editor.c 21 Feb 2006 07:35:31 -0000
@@ -773,8 +773,6 @@
TRACE("flags==0x%08lx, chrg->cpMin==%ld, chrg->cpMax==%ld text==%s\n",
flags, chrg->cpMin, chrg->cpMax, debugstr_w(text));
- if (!(flags & FR_MATCHCASE))
- FIXME("Case-insensitive search not implemented\n");
if (flags & ~(FR_DOWN | FR_MATCHCASE))
FIXME("Flags 0x%08lx not implemented\n", flags & ~(FR_DOWN | FR_MATCHCASE));
@@ -815,7 +813,7 @@
int nCurStart = nStart;
int nMatched = 0;
- while (pCurItem && pCurItem->member.run.strText->szData[nCurStart + nMatched] == text[nMatched])
+ while (pCurItem && ME_CharCompare(pCurItem->member.run.strText->szData[nCurStart + nMatched], text[nMatched], (flags & FR_MATCHCASE)))
{
nMatched++;
if (nMatched == nLen)
@@ -864,7 +862,7 @@
int nCurEnd = nEnd;
int nMatched = 0;
- while (pCurItem && pCurItem->member.run.strText->szData[nCurEnd - nMatched - 1] == text[nLen - nMatched - 1])
+ while (ME_CharCompare(pCurItem->member.run.strText->szData[nCurEnd - nMatched - 1], text[nLen - nMatched - 1], (flags & FR_MATCHCASE)))
{
nMatched++;
if (nMatched == nLen)
Index: dlls/riched20/editor.h
===================================================================
RCS file: /home/wine/wine/dlls/riched20/editor.h,v
retrieving revision 1.30
diff -u -r1.30 editor.h
--- dlls/riched20/editor.h 5 Feb 2006 12:56:42 -0000 1.30
+++ dlls/riched20/editor.h 21 Feb 2006 07:35:32 -0000
@@ -95,6 +95,11 @@
return ch > '\0' && ch <= ' ';
}
+static inline int ME_CharCompare(WCHAR a, WCHAR b, int caseSensitive)
+{
+ return caseSensitive ? (a == b) : (towupper(a) == towupper(b));
+}
+
/* note: those two really return the first matching offset (starting from EOS)+1
* in other words, an offset of the first trailing white/black */
int ME_ReverseFindNonWhitespaceV(ME_String *s, int nVChar);
Index: dlls/riched20/editstr.h
===================================================================
RCS file: /home/wine/wine/dlls/riched20/editstr.h,v
retrieving revision 1.24
diff -u -r1.24 editstr.h
--- dlls/riched20/editstr.h 20 Feb 2006 20:19:30 -0000 1.24
+++ dlls/riched20/editstr.h 21 Feb 2006 07:35:32 -0000
@@ -29,6 +29,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <wctype.h>
#include <windef.h>
#include <winbase.h>
Index: dlls/riched20/tests/editor.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/tests/editor.c,v
retrieving revision 1.4
diff -u -r1.4 editor.c
--- dlls/riched20/tests/editor.c 20 Feb 2006 20:19:30 -0000 1.4
+++ dlls/riched20/tests/editor.c 21 Feb 2006 07:35:32 -0000
@@ -76,7 +76,7 @@
{20, 10, "Wine", FR_MATCHCASE, 13, 0},
/* Case-insensitive */
- {1, 31, "wInE", FR_DOWN, 4, 1},
+ {1, 31, "wInE", FR_DOWN, 4, 0},
{1, 31, "Wine", FR_DOWN, 4, 0},
/* High-to-low ranges */
More information about the wine-patches
mailing list