Signed-off-by: Brendan McGrath brendan@redmandi.com --- dlls/kernel32/tests/locale.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 2627fc5de84..e11fe1beb01 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -2362,6 +2362,13 @@ static void test_LCMapStringA(void) ok(ret == ret2, "lengths of sort keys must be equal\n"); ok(!lstrcmpA(buf, buf2), "sort keys must be equal\n");
+ /* test we get the same length when no dest buffer is provided */ + ret2 = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_SORTKEY, + upper_case, lstrlenA(upper_case), NULL, 0); + ok(ret2, "LCMapStringA must succeed\n"); + todo_wine + ok(ret == ret2, "lengths of sort keys must be equal (%d vs %d)\n", ret, ret2); + /* test LCMAP_SORTKEY | NORM_IGNORECASE */ ret = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_SORTKEY | NORM_IGNORECASE, upper_case, -1, buf, sizeof(buf));
Signed-off-by: Brendan McGrath brendan@redmandi.com --- dlls/kernel32/tests/locale.c | 1 - libs/wine/sortkey.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index e11fe1beb01..cf781e55884 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -2366,7 +2366,6 @@ static void test_LCMapStringA(void) ret2 = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_SORTKEY, upper_case, lstrlenA(upper_case), NULL, 0); ok(ret2, "LCMapStringA must succeed\n"); - todo_wine ok(ret == ret2, "lengths of sort keys must be equal (%d vs %d)\n", ret, ret2);
/* test LCMAP_SORTKEY | NORM_IGNORECASE */ diff --git a/libs/wine/sortkey.c b/libs/wine/sortkey.c index ef4488908b6..46c707e5ec0 100644 --- a/libs/wine/sortkey.c +++ b/libs/wine/sortkey.c @@ -80,7 +80,7 @@ int wine_get_sortkey(int flags, const WCHAR *src, int srclen, char *dst, int dst
if (!dstlen) /* compute length */ /* 4 * '\1' + 1 * '\0' + key length */ - return key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4 + 1; + return key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4;
if (dstlen < key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4 + 1) return 0; /* overflow */
Brendan McGrath brendan@redmandi.com wrote:
--- a/libs/wine/sortkey.c +++ b/libs/wine/sortkey.c @@ -80,7 +80,7 @@ int wine_get_sortkey(int flags, const WCHAR *src, int srclen, char *dst, int dst
if (!dstlen) /* compute length */ /* 4 * '\1' + 1 * '\0' + key length */
return key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4 + 1;
return key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4;
Thanks for the patch. Probably the comment above should be adapted as well.
Signed-off-by: Brendan McGrath brendan@redmandi.com --- Changes since v1: - Change the comment to reflect the change in code (see patch 2)
dlls/kernel32/tests/locale.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 2627fc5de84..e11fe1beb01 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -2362,6 +2362,13 @@ static void test_LCMapStringA(void) ok(ret == ret2, "lengths of sort keys must be equal\n"); ok(!lstrcmpA(buf, buf2), "sort keys must be equal\n");
+ /* test we get the same length when no dest buffer is provided */ + ret2 = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_SORTKEY, + upper_case, lstrlenA(upper_case), NULL, 0); + ok(ret2, "LCMapStringA must succeed\n"); + todo_wine + ok(ret == ret2, "lengths of sort keys must be equal (%d vs %d)\n", ret, ret2); + /* test LCMAP_SORTKEY | NORM_IGNORECASE */ ret = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_SORTKEY | NORM_IGNORECASE, upper_case, -1, buf, sizeof(buf));
Signed-off-by: Brendan McGrath brendan@redmandi.com --- Changes since v1: - Change the comment to reflect the change in code
dlls/kernel32/tests/locale.c | 1 - libs/wine/sortkey.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index e11fe1beb01..cf781e55884 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -2366,7 +2366,6 @@ static void test_LCMapStringA(void) ret2 = LCMapStringA(LOCALE_USER_DEFAULT, LCMAP_SORTKEY, upper_case, lstrlenA(upper_case), NULL, 0); ok(ret2, "LCMapStringA must succeed\n"); - todo_wine ok(ret == ret2, "lengths of sort keys must be equal (%d vs %d)\n", ret, ret2);
/* test LCMAP_SORTKEY | NORM_IGNORECASE */ diff --git a/libs/wine/sortkey.c b/libs/wine/sortkey.c index ef4488908b6..c61a7e56f5f 100644 --- a/libs/wine/sortkey.c +++ b/libs/wine/sortkey.c @@ -79,8 +79,8 @@ int wine_get_sortkey(int flags, const WCHAR *src, int srclen, char *dst, int dst }
if (!dstlen) /* compute length */ - /* 4 * '\1' + 1 * '\0' + key length */ - return key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4 + 1; + /* 4 * '\1' + key length */ + return key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4;
if (dstlen < key_len[0] + key_len[1] + key_len[2] + key_len[3] + 4 + 1) return 0; /* overflow */