RICHED20: fix 1.0 emulation off-by-ones
Krzysztof Foltman
wdev at foltman.com
Fri Oct 7 10:33:08 CDT 2005
ChangeLog:
* fixed 3 off-by-one bugs caused by 2-char EOL mark in 1.0 emulation
mode (one in ME_GetTextW, one in EM_LINELENGTH handler, one in
ME_RunOfsFromCharOfs)
Krzysztof
-------------- next part --------------
Index: editor.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/editor.c,v
retrieving revision 1.59
diff -u -r1.59 editor.c
@@ -1666,7 +1669,8 @@
if (item_end)
nNextLineOfs = ME_CharOfsFromRunOfs(editor, ME_FindItemFwd(item_end, diRun), 0);
else
- nNextLineOfs = ME_FindItemFwd(item, diParagraphOrEnd)->member.para.nCharOfs-1;
+ nNextLineOfs = ME_FindItemFwd(item, diParagraphOrEnd)->member.para.nCharOfs
+ - (editor->bEmulateVersion10?2:1);
nChars = nNextLineOfs - nThisLineOfs;
TRACE("EM_LINELENGTH(%d)==%d\n",wParam, nChars);
return nChars;
@@ -2069,6 +2078,9 @@
nWritten++;
}
assert(nLen == 1);
+ /* our end paragraph consists of 2 characters now */
+ if (editor->bEmulateVersion10)
+ nChars--;
}
else
CopyMemory(buffer, item->member.run.strText->szData, sizeof(WCHAR)*nLen);
Index: run.c
===================================================================
RCS file: /home/wine/wine/dlls/riched20/run.c,v
retrieving revision 1.12
diff -u -r1.12 run.c
--- run.c 22 Jul 2005 18:27:26 -0000 1.12
+++ run.c 7 Oct 2005 15:21:06 -0000
@@ -143,6 +145,7 @@
if (nCharOfs < pPara->member.para.next_para->member.para.nCharOfs)
{
+ int eollen = 1;
*ppRun = ME_FindItemFwd(pPara, diRun);
assert(*ppRun);
while (!((*ppRun)->member.run.nFlags & MERF_ENDPARA))
@@ -157,7 +160,10 @@
}
*ppRun = pNext;
}
- if (nCharOfs == nParaOfs + (*ppRun)->member.run.nCharOfs) {
+ /* the handling of bEmulateVersion10 may be a source of many bugs, I'm afraid */
+ eollen = (editor->bEmulateVersion10 ? 2 : 1);
+ if (nCharOfs >= nParaOfs + (*ppRun)->member.run.nCharOfs &&
+ nCharOfs < nParaOfs + (*ppRun)->member.run.nCharOfs + eollen) {
*pOfs = 0;
return;
}
More information about the wine-patches
mailing list