Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
a607ad31
Commit
a607ad31
authored
Jan 01, 2008
by
Eric Pouech
Committed by
Alexandre Julliard
Jan 02, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
richedit: Fixed a couple of charformatXXm structure conversions because of alignment issues.
parent
71f52d54
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
style.c
dlls/riched20/style.c
+17
-9
No files found.
dlls/riched20/style.c
View file @
a607ad31
...
...
@@ -25,12 +25,20 @@ WINE_DECLARE_DEBUG_CHANNEL(richedit_style);
static
int
all_refs
=
0
;
/* the following routines assume that:
* - char2[AW] extends char[AW] by adding fields at the end of the charA form)
* - szFaceName is the last field of char[AW] form, and wWeight the first of 2[AW]
* - the difference between A and W form is the szFaceName as Ansi vs Unicode string
* - because of alignment, offset of wWeight field in 2[AW] structure *IS NOT*
* sizeof(char[AW])
*/
CHARFORMAT2W
*
ME_ToCF2W
(
CHARFORMAT2W
*
to
,
CHARFORMAT2W
*
from
)
{
if
(
from
->
cbSize
==
sizeof
(
CHARFORMATA
))
{
CHARFORMATA
*
f
=
(
CHARFORMATA
*
)
from
;
CopyMemory
(
to
,
f
,
sizeof
(
*
f
)
-
sizeof
(
f
->
szFaceName
));
CopyMemory
(
to
,
f
,
FIELD_OFFSET
(
CHARFORMATA
,
szFaceName
));
to
->
cbSize
=
sizeof
(
CHARFORMAT2W
);
if
(
f
->
dwMask
&
CFM_FACE
)
{
MultiByteToWideChar
(
0
,
0
,
f
->
szFaceName
,
-
1
,
to
->
szFaceName
,
sizeof
(
to
->
szFaceName
)
/
sizeof
(
WCHAR
));
...
...
@@ -42,20 +50,20 @@ CHARFORMAT2W *ME_ToCF2W(CHARFORMAT2W *to, CHARFORMAT2W *from)
CHARFORMATW
*
f
=
(
CHARFORMATW
*
)
from
;
CopyMemory
(
to
,
f
,
sizeof
(
*
f
));
/* theoretically, we don't need to zero the remaining memory */
ZeroMemory
(
((
CHARFORMATW
*
)
to
)
+
1
,
sizeof
(
CHARFORMAT2W
)
-
sizeof
(
CHARFORMATW
));
ZeroMemory
(
&
to
->
wWeight
,
sizeof
(
CHARFORMAT2W
)
-
FIELD_OFFSET
(
CHARFORMAT2W
,
wWeight
));
to
->
cbSize
=
sizeof
(
CHARFORMAT2W
);
return
to
;
}
if
(
from
->
cbSize
==
sizeof
(
CHARFORMAT2A
))
{
CHARFORMAT
A
*
f
=
(
CHARFORMAT
A
*
)
from
;
CHARFORMAT
2A
*
f
=
(
CHARFORMAT2
A
*
)
from
;
/* copy the A structure without face name */
CopyMemory
(
to
,
f
,
sizeof
(
CHARFORMATA
)
-
sizeof
(
f
->
szFaceName
));
CopyMemory
(
to
,
f
,
FIELD_OFFSET
(
CHARFORMATA
,
szFaceName
));
/* convert face name */
if
(
f
->
dwMask
&
CFM_FACE
)
MultiByteToWideChar
(
0
,
0
,
f
->
szFaceName
,
-
1
,
to
->
szFaceName
,
sizeof
(
to
->
szFaceName
)
/
sizeof
(
WCHAR
));
/* copy the rest of the 2A structure to 2W */
CopyMemory
(
1
+
((
CHARFORMATW
*
)
to
),
f
+
1
,
sizeof
(
CHARFORMAT2A
)
-
sizeof
(
CHARFORMATA
));
CopyMemory
(
&
to
->
wWeight
,
&
f
->
wWeight
,
sizeof
(
CHARFORMAT2A
)
-
FIELD_OFFSET
(
CHARFORMAT2A
,
wWeight
));
to
->
cbSize
=
sizeof
(
CHARFORMAT2W
);
return
to
;
}
...
...
@@ -75,7 +83,7 @@ CHARFORMAT2W *ME_ToCFAny(CHARFORMAT2W *to, CHARFORMAT2W *from)
if
(
to
->
cbSize
==
sizeof
(
CHARFORMATA
))
{
CHARFORMATA
*
t
=
(
CHARFORMATA
*
)
to
;
CopyMemory
(
t
,
from
,
sizeof
(
*
t
)
-
sizeof
(
t
->
szFaceName
));
CopyMemory
(
t
,
from
,
FIELD_OFFSET
(
CHARFORMATA
,
szFaceName
));
WideCharToMultiByte
(
0
,
0
,
from
->
szFaceName
,
-
1
,
t
->
szFaceName
,
sizeof
(
t
->
szFaceName
),
0
,
0
);
t
->
cbSize
=
sizeof
(
*
t
);
/* it was overwritten by CopyMemory */
return
to
;
...
...
@@ -91,15 +99,15 @@ CHARFORMAT2W *ME_ToCFAny(CHARFORMAT2W *to, CHARFORMAT2W *from)
{
CHARFORMAT2A
*
t
=
(
CHARFORMAT2A
*
)
to
;
/* copy the A structure without face name */
CopyMemory
(
t
,
from
,
sizeof
(
CHARFORMATA
)
-
sizeof
(
t
->
szFaceName
));
CopyMemory
(
t
,
from
,
FIELD_OFFSET
(
CHARFORMATA
,
szFaceName
));
/* convert face name */
WideCharToMultiByte
(
0
,
0
,
from
->
szFaceName
,
-
1
,
t
->
szFaceName
,
sizeof
(
t
->
szFaceName
),
0
,
0
);
/* copy the rest of the 2A structure to 2W */
CopyMemory
(
&
t
->
wWeight
,
&
from
->
wWeight
,
sizeof
(
CHARFORMAT2
A
)
-
sizeof
(
CHARFORMATA
));
CopyMemory
(
&
t
->
wWeight
,
&
from
->
wWeight
,
sizeof
(
CHARFORMAT2
W
)
-
FIELD_OFFSET
(
CHARFORMAT2W
,
wWeight
));
t
->
cbSize
=
sizeof
(
*
t
);
/* it was overwritten by CopyMemory */
return
to
;
}
assert
(
to
->
cbSize
>=
sizeof
(
CHARFORMAT2W
));
assert
(
to
->
cbSize
>=
sizeof
(
CHARFORMAT2W
));
return
from
;
}
...
...
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