Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=43630 Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/riched20/reader.c | 2 +- dlls/riched20/tests/editor.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/dlls/riched20/reader.c b/dlls/riched20/reader.c index 8410241729..dc551bf584 100644 --- a/dlls/riched20/reader.c +++ b/dlls/riched20/reader.c @@ -109,7 +109,7 @@ int _RTFGetChar(RTF_Info *info) } ch = (unsigned char)stream->buffer[stream->dwUsed++]; if (!ch) - return EOF; + return ' '; return ch; }
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 85c607becf..7975f3647c 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -5754,6 +5754,29 @@ static DWORD CALLBACK test_EM_STREAMIN_esCallback_UTF8Split(DWORD_PTR dwCookie, return 0; }
+static DWORD CALLBACK test_EM_STREAMIN_NullBytes(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) +{ + DWORD *phase = (DWORD *)dwCookie; + + if (*phase == 0) + { + static const char first[] = "{\rtf1\ansi{Th\0is"; + *pcb = sizeof(first); + memcpy(pbBuff, first, *pcb); + } + else if (*phase == 1) { + static const char second[] = " is a test}}"; + *pcb = sizeof(second); + memcpy(pbBuff, second, *pcb); + } + else + *pcb = 0; + + ++*phase; + + return 0; +} + struct StringWithLength { int length; char *buffer; @@ -6040,6 +6063,18 @@ static void test_EM_STREAMIN(void) result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); ok (!strcmp(buffer, "line1"), "EM_STREAMIN: Unexpected text '%s'\n", buffer); + + /* Test 0-bytes inside text */ + hwndRichEdit = new_richedit_with_style(NULL, 0); + phase = 0; + es.dwCookie = (DWORD_PTR)&phase; + es.dwError = 0; + es.pfnCallback = test_EM_STREAMIN_NullBytes; + result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es); + ok(result == 16, "got %ld, expected %d\n", result, 16); + result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); + ok (!strcmp(buffer, "Th is is a test"), "EM_STREAMIN: Unexpected text '%s'\n", buffer); + }
static void test_EM_StreamIn_Undo(void)
On Thu, Nov 08, 2018 at 04:26:47PM +0100, Fabian Maurer wrote:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=43630 Signed-off-by: Fabian Maurer dark.shadow4@web.de
dlls/riched20/reader.c | 2 +- dlls/riched20/tests/editor.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 85c607becf..7975f3647c 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -5754,6 +5754,29 @@ static DWORD CALLBACK test_EM_STREAMIN_esCallback_UTF8Split(DWORD_PTR dwCookie, return 0; }
+static DWORD CALLBACK test_EM_STREAMIN_NullBytes(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) +{
- DWORD *phase = (DWORD *)dwCookie;
- if (*phase == 0)
- {
The indentation here is strange. I've sent in a new version with this fixed and some other cosmeetic changes.
Thanks, Huw.
The indentation here is strange. I've sent in a new version with this fixed and some other cosmeetic changes.
Thanks, don't know how I managed to mess that up.
Regarding parameter names, I'm never sure whether to follow windows conventions like the other tests (dwCookie) or the wine conventions (cookie). What's the rule for that? One argument would be to fit the surrounding code, the other would be to do it "correct" for added code.
Regards, Fabian Maurer
On Fri, 9 Nov 2018 at 13:22, Fabian Maurer dark.shadow4@web.de wrote:
Regarding parameter names, I'm never sure whether to follow windows conventions like the other tests (dwCookie) or the wine conventions (cookie).
What's the rule for that? One argument would be to fit the surrounding code, the other would be to do it "correct" for added code.
You never want to use "dwCookie". The question may be harder to answer for cases where there are legitimate style preferences (in which case, well, apply judgement), but I don't think anyone considers the "dwCookie" style of variable naming one of those.