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
5dee0ed7
Commit
5dee0ed7
authored
Jun 08, 2022
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Add NORM_IGNORENONSPACE support in LCMapStringEx().
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=36720
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8c1c83df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
7 deletions
+64
-7
locale.c
dlls/kernel32/tests/locale.c
+17
-0
locale.c
dlls/kernelbase/locale.c
+47
-7
No files found.
dlls/kernel32/tests/locale.c
View file @
5dee0ed7
...
...
@@ -2462,6 +2462,11 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
const
static
WCHAR
cjk_compat_result
[]
=
{
0x523b
,
0x5246
,
0x5272
,
0x5277
,
0x3515
,
0x52c7
,
0x52c9
,
0x52e4
,
0
};
const
static
WCHAR
accents_text
[]
=
{
0x00e0
,
0x00e7
,
' '
,
0x00e9
,
','
,
0x00ee
,
0x00f1
,
'/'
,
0x00f6
,
0x00fb
,
0x00fd
,
'!'
,
0
};
const
static
WCHAR
accents_result
[]
=
L"ac e,in/ouy!"
;
const
static
WCHAR
accents_result2
[]
=
L"aceinouy"
;
int
ret
,
ret2
,
i
;
WCHAR
buf
[
256
],
buf2
[
256
];
char
*
p_buf
=
(
char
*
)
buf
,
*
p_buf2
=
(
char
*
)
buf2
;
...
...
@@ -2703,6 +2708,12 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
lstrlenW
(
lower_case
)
+
1
,
ret
);
ok
(
!
lstrcmpW
(
buf
,
lower_case
),
"%s string comparison mismatch
\n
"
,
func_name
);
lstrcpyW
(
buf
,
fooW
);
ret
=
func_ptr
(
NORM_IGNORENONSPACE
,
accents_text
,
-
1
,
buf
,
ARRAY_SIZE
(
buf
));
ok
(
ret
==
lstrlenW
(
buf
)
+
1
,
"%s func_ptr should return %d, ret = %d
\n
"
,
func_name
,
lstrlenW
(
buf
)
+
1
,
ret
);
ok
(
!
lstrcmpW
(
buf
,
accents_result
),
"%s string comparison mismatch %s
\n
"
,
func_name
,
debugstr_w
(
buf
));
/* test NORM_IGNORESYMBOLS */
lstrcpyW
(
buf
,
fooW
);
ret
=
func_ptr
(
NORM_IGNORESYMBOLS
,
lower_case
,
-
1
,
buf
,
ARRAY_SIZE
(
buf
));
...
...
@@ -2717,6 +2728,12 @@ static void test_lcmapstring_unicode(lcmapstring_wrapper func_ptr, const char *f
lstrlenW
(
symbols_stripped
)
+
1
,
ret
);
ok
(
!
lstrcmpW
(
buf
,
symbols_stripped
),
"%s string comparison mismatch
\n
"
,
func_name
);
lstrcpyW
(
buf
,
fooW
);
ret
=
func_ptr
(
NORM_IGNORESYMBOLS
|
NORM_IGNORENONSPACE
,
accents_text
,
-
1
,
buf
,
ARRAY_SIZE
(
buf
));
ok
(
ret
==
lstrlenW
(
buf
)
+
1
,
"%s func_ptr should return %d, ret = %d
\n
"
,
func_name
,
lstrlenW
(
buf
)
+
1
,
ret
);
ok
(
!
lstrcmpW
(
buf
,
accents_result2
),
"%s string comparison mismatch %s
\n
"
,
func_name
,
debugstr_w
(
buf
));
/* test small buffer */
lstrcpyW
(
buf
,
fooW
);
ret
=
func_ptr
(
LCMAP_SORTKEY
,
lower_case
,
-
1
,
buf
,
2
);
...
...
dlls/kernelbase/locale.c
View file @
5dee0ed7
...
...
@@ -4023,6 +4023,52 @@ static int map_to_fullwidth( const USHORT *table, const WCHAR *src, int srclen,
return
pos
;
}
static
inline
int
nonspace_ignored
(
WCHAR
ch
)
{
if
(
get_char_type
(
CT_CTYPE2
,
ch
)
!=
C2_OTHERNEUTRAL
)
return
FALSE
;
return
(
get_char_type
(
CT_CTYPE3
,
ch
)
&
(
C3_NONSPACING
|
C3_DIACRITIC
));
}
/* remove ignored chars for NORM_IGNORENONSPACE/NORM_IGNORESYMBOLS */
static
int
map_remove_ignored
(
DWORD
flags
,
const
WCHAR
*
src
,
int
srclen
,
WCHAR
*
dst
,
int
dstlen
)
{
int
pos
;
for
(
pos
=
0
;
srclen
;
src
++
,
srclen
--
)
{
if
(
flags
&
NORM_IGNORESYMBOLS
)
{
if
(
get_char_type
(
CT_CTYPE1
,
*
src
)
&
C1_PUNCT
)
continue
;
if
(
get_char_type
(
CT_CTYPE3
,
*
src
)
&
C3_SYMBOL
)
continue
;
}
if
(
flags
&
NORM_IGNORENONSPACE
)
{
WCHAR
buffer
[
8
];
const
WCHAR
*
decomp
;
unsigned
int
i
,
j
,
len
;
if
((
decomp
=
get_decomposition
(
*
src
,
&
len
))
&&
len
>
1
)
{
for
(
i
=
j
=
0
;
i
<
len
;
i
++
)
if
(
!
nonspace_ignored
(
decomp
[
i
]
))
buffer
[
j
++
]
=
decomp
[
i
];
if
(
i
>
j
)
/* something was removed */
{
if
(
pos
+
j
<=
dstlen
)
memcpy
(
dst
+
pos
,
buffer
,
j
*
sizeof
(
WCHAR
)
);
pos
+=
j
;
continue
;
}
}
else
if
(
nonspace_ignored
(
*
src
))
continue
;
}
if
(
pos
<
dstlen
)
dst
[
pos
]
=
*
src
;
pos
++
;
}
return
pos
;
}
/* map full-width characters to single or double half-width characters. */
static
int
map_to_halfwidth
(
const
USHORT
*
table
,
const
WCHAR
*
src
,
int
srclen
,
WCHAR
*
dst
,
int
dstlen
)
{
...
...
@@ -4124,13 +4170,7 @@ static int lcmap_string( const struct sortguid *sortid, DWORD flags,
SetLastError
(
ERROR_INVALID_FLAGS
);
return
0
;
}
for
(
ret
=
0
;
srclen
;
src
++
,
srclen
--
)
{
if
((
flags
&
NORM_IGNORESYMBOLS
)
&&
(
get_char_type
(
CT_CTYPE1
,
*
src
)
&
(
C1_PUNCT
|
C1_SPACE
)))
continue
;
if
(
ret
<
dstlen
)
dst
[
ret
]
=
*
src
;
ret
++
;
}
ret
=
map_remove_ignored
(
flags
,
src
,
srclen
,
dst
,
dstlen
);
break
;
case
0
:
if
(
case_table
)
...
...
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