comctl32: toolbar: Fix the TB_ADDSTRING from resources for a NUL delimiter.

This commit is contained in:
Mikołaj Zalewski 2006-10-09 00:06:59 +02:00 committed by Alexandre Julliard
parent 869c3bb74b
commit 241956101e
4 changed files with 7 additions and 11 deletions

View File

@ -29,9 +29,6 @@
#define IDS_TBADD3 18
#define IDS_TBADD4 19
#define IDS_TBADD5 20
#define IDS_TBADD6 21
#define IDS_TBADD7 22
#define IDS_TBADD8 23
#define IDS_TBADD9 24
#endif /* __WINE_COMCTL32_TEST_RESOURCES_H */

View File

@ -37,7 +37,6 @@ STRINGTABLE
IDS_TBADD3 "*p*q*"
IDS_TBADD4 "#p#q##"
IDS_TBADD5 "|p||q|r|"
IDS_TBADD6 "\000a\000\000"
IDS_TBADD7 "abracadabra"
}

View File

@ -362,9 +362,6 @@ void test_add_string()
ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD5);
ok(ret == 8, "TB_ADDSTRINGA - unexpected return %d\n", ret);
CHECK_STRING_TABLE(11, ret6);
ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD6);
ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret);
CHECK_STRING_TABLE(11, ret6);
ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD7);
ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret);
CHECK_STRING_TABLE(14, ret7);

View File

@ -2921,9 +2921,8 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
INT len;
TRACE("adding string from resource!\n");
LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
szString, MAX_RESOURCE_STRING_LENGTH);
len = lstrlenW(szString);
TRACE("len=%d %s\n", len, debugstr_w(szString));
if (len == 0 || len == 1)
@ -2932,11 +2931,15 @@ TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
TRACE("Delimiter: 0x%x\n", *szString);
delimiter = *szString;
p = szString + 1;
if (szString[len-1] == delimiter)
szString[len-1] = 0;
while ((next_delim = strchrW(p, delimiter)) != NULL) {
*next_delim = 0;
if (next_delim + 1 >= szString + len)
{
/* this may happen if delimiter == '\0' or if the last char is a
* delimiter (then it is ignored like the native does) */
break;
}
infoPtr->strings = ReAlloc(infoPtr->strings, sizeof(LPWSTR)*(infoPtr->nNumStrings+1));
Str_SetPtrW(&infoPtr->strings[infoPtr->nNumStrings], p);