Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
360afb93
Commit
360afb93
authored
Oct 01, 2013
by
Andrew Eikum
Committed by
Alexandre Julliard
Oct 02, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
riched20: Continue interpreting data as UTF-8 after the first chunk boundary.
parent
b7709771
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
3 deletions
+92
-3
editor.c
dlls/riched20/editor.c
+53
-3
editor.c
dlls/riched20/tests/editor.c
+39
-0
No files found.
dlls/riched20/editor.c
View file @
360afb93
...
...
@@ -286,6 +286,9 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
WCHAR
*
pText
;
LRESULT
total_bytes_read
=
0
;
BOOL
is_read
=
FALSE
;
DWORD
cp
=
CP_ACP
,
copy
=
0
;
char
conv_buf
[
4
+
STREAMIN_BUFFER_SIZE
];
/* up to 4 additional UTF-8 bytes */
static
const
char
bom_utf8
[]
=
{
0xEF
,
0xBB
,
0xBF
};
TRACE
(
"%08x %p
\n
"
,
dwFormat
,
stream
);
...
...
@@ -307,8 +310,7 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
if
(
!
(
dwFormat
&
SF_UNICODE
))
{
char
*
buf
=
stream
->
buffer
;
DWORD
size
=
stream
->
dwSize
;
DWORD
cp
=
CP_ACP
;
DWORD
size
=
stream
->
dwSize
,
end
;
if
(
!
is_read
)
{
...
...
@@ -321,8 +323,56 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
}
}
nWideChars
=
MultiByteToWideChar
(
cp
,
0
,
buf
,
size
,
wszText
,
STREAMIN_BUFFER_SIZE
);
if
(
cp
==
CP_UTF8
)
{
if
(
copy
)
{
memcpy
(
conv_buf
+
copy
,
buf
,
size
);
buf
=
conv_buf
;
size
+=
copy
;
}
end
=
size
;
while
((
buf
[
end
-
1
]
&
0xC0
)
==
0x80
)
{
--
end
;
--
total_bytes_read
;
/* strange, but seems to match windows */
}
if
(
buf
[
end
-
1
]
&
0x80
)
{
DWORD
need
=
0
;
if
((
buf
[
end
-
1
]
&
0xE0
)
==
0xC0
)
need
=
1
;
if
((
buf
[
end
-
1
]
&
0xF0
)
==
0xE0
)
need
=
2
;
if
((
buf
[
end
-
1
]
&
0xF8
)
==
0xF0
)
need
=
3
;
if
(
size
-
end
>=
need
)
{
/* we have enough bytes for this sequence */
end
=
size
;
}
else
{
/* need more bytes, so don't transcode this sequence */
--
end
;
}
}
}
else
end
=
size
;
nWideChars
=
MultiByteToWideChar
(
cp
,
0
,
buf
,
end
,
wszText
,
STREAMIN_BUFFER_SIZE
);
pText
=
wszText
;
if
(
cp
==
CP_UTF8
)
{
if
(
end
!=
size
)
{
memcpy
(
conv_buf
,
buf
+
end
,
size
-
end
);
copy
=
size
-
end
;
}
}
}
else
{
...
...
dlls/riched20/tests/editor.c
View file @
360afb93
...
...
@@ -5035,6 +5035,29 @@ static DWORD CALLBACK test_EM_STREAMIN_esCallback(DWORD_PTR dwCookie,
return
0
;
}
static
DWORD
CALLBACK
test_EM_STREAMIN_esCallback_UTF8Split
(
DWORD_PTR
dwCookie
,
LPBYTE
pbBuff
,
LONG
cb
,
LONG
*
pcb
)
{
DWORD
*
phase
=
(
DWORD
*
)
dwCookie
;
if
(
*
phase
==
0
){
static
const
char
first
[]
=
"
\xef\xbb\xbf\xc3\x96\xc3
"
;
*
pcb
=
sizeof
(
first
)
-
1
;
memcpy
(
pbBuff
,
first
,
*
pcb
);
}
else
if
(
*
phase
==
1
){
static
const
char
second
[]
=
"
\x8f\xc3\x8b
"
;
*
pcb
=
sizeof
(
second
)
-
1
;
memcpy
(
pbBuff
,
second
,
*
pcb
);
}
else
*
pcb
=
0
;
++*
phase
;
return
0
;
}
struct
StringWithLength
{
int
length
;
char
*
buffer
;
...
...
@@ -5063,6 +5086,7 @@ static DWORD CALLBACK test_EM_STREAMIN_esCallback2(DWORD_PTR dwCookie,
static
void
test_EM_STREAMIN
(
void
)
{
HWND
hwndRichEdit
=
new_richedit
(
NULL
);
DWORD
phase
;
LRESULT
result
;
EDITSTREAM
es
;
char
buffer
[
1024
]
=
{
0
};
...
...
@@ -5204,6 +5228,21 @@ static void test_EM_STREAMIN(void)
"EM_STREAMIN: Test UTF8WithBOM set wrong text: Result: %s
\n
"
,
buffer
);
ok
(
es
.
dwError
==
0
,
"EM_STREAMIN: Test UTF8WithBOM set error %d, expected %d
\n
"
,
es
.
dwError
,
0
);
phase
=
0
;
es
.
dwCookie
=
(
DWORD_PTR
)
&
phase
;
es
.
dwError
=
0
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback_UTF8Split
;
result
=
SendMessage
(
hwndRichEdit
,
EM_STREAMIN
,
SF_TEXT
,
(
LPARAM
)
&
es
);
ok
(
result
==
8
,
"got %ld
\n
"
,
result
);
result
=
SendMessage
(
hwndRichEdit
,
WM_GETTEXT
,
1024
,
(
LPARAM
)
buffer
);
ok
(
result
==
3
,
"EM_STREAMIN: Test UTF8Split returned %ld
\n
"
,
result
);
result
=
memcmp
(
buffer
,
"
\xd6\xcf\xcb
"
,
3
);
ok
(
result
==
0
,
"EM_STREAMIN: Test UTF8Split set wrong text: Result: %s
\n
"
,
buffer
);
ok
(
es
.
dwError
==
0
,
"EM_STREAMIN: Test UTF8Split set error %d, expected %d
\n
"
,
es
.
dwError
,
0
);
es
.
dwCookie
=
(
DWORD_PTR
)
&
cookieForStream4
;
es
.
dwError
=
0
;
es
.
pfnCallback
=
test_EM_STREAMIN_esCallback2
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment