comctl32: Replace nonprintable characters with spaces on SB_SETTEXT (try2)
Nikolay Sivov
bunglehead at gmail.com
Tue Mar 3 15:54:50 CST 2009
Changelog:
(try2) some test added for a range of characters
- Replace nonprintable characters with spaces on SB_SETTEXT
>From b0a9b8b1e9220c291c1003e98e12311dc6ea99a5 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Tue, 3 Mar 2009 16:50:55 -0500
Subject: Replace nonprintable characters with spaces on SB_SETTEXT
---
dlls/comctl32/status.c | 12 ++++++++++++
dlls/comctl32/tests/status.c | 30 ++++++++++++++++++++----------
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c
index a56c2a0..388e774 100644
--- a/dlls/comctl32/status.c
+++ b/dlls/comctl32/status.c
@@ -762,6 +762,8 @@ STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
part->text = (LPWSTR)text;
} else {
LPWSTR ntext;
+ WCHAR *idx;
+ const WCHAR space = {' '};
if (text && !isW) {
LPCSTR atxt = (LPCSTR)text;
@@ -775,6 +777,16 @@ STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
strcpyW (ntext, text);
} else ntext = 0;
+ /* replace nonprintable characters with spaces */
+ if (ntext) {
+ idx = ntext;
+ while (*idx) {
+ if(!isprintW(*idx))
+ *idx = space;
+ idx++;
+ }
+ }
+
/* check if text is unchanged -> no need to redraw */
if (text) {
if (!changed && part->text && !lstrcmpW(ntext, part->text)) {
diff --git a/dlls/comctl32/tests/status.c b/dlls/comctl32/tests/status.c
index 4ae663f..f1cbda4 100644
--- a/dlls/comctl32/tests/status.c
+++ b/dlls/comctl32/tests/status.c
@@ -258,6 +258,8 @@ static void test_status_control(void)
RECT rc;
CHAR charArray[20];
HICON hIcon;
+ char ch;
+ char chstr[10] = "Inval id";
hWndStatus = create_status_control(WS_VISIBLE, 0);
@@ -307,7 +309,7 @@ static void test_status_control(void)
/* Test resetting text with different characters */
r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)"First at Again");
expect(TRUE,r);
- r = SendMessage(hWndStatus, SB_SETTEXT, 1, (LPARAM)"InvalidChars\\7\7");
+ r = SendMessage(hWndStatus, SB_SETTEXT, 1, (LPARAM)"Invalid\tChars\\7\7");
expect(TRUE,r);
r = SendMessage(hWndStatus, SB_SETTEXT, 2, (LPARAM)"InvalidChars\\n\n");
expect(TRUE,r);
@@ -318,20 +320,28 @@ static void test_status_control(void)
expect(11,LOWORD(r));
expect(0,HIWORD(r));
r = SendMessage(hWndStatus, SB_GETTEXT, 1, (LPARAM) charArray);
- todo_wine
- {
- ok(strcmp(charArray,"InvalidChars\\7 ") == 0, "Expected InvalidChars\\7 , got %s\n", charArray);
- }
- expect(15,LOWORD(r));
+ ok(strcmp(charArray,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray);
+
+ expect(16,LOWORD(r));
expect(0,HIWORD(r));
r = SendMessage(hWndStatus, SB_GETTEXT, 2, (LPARAM) charArray);
- todo_wine
- {
- ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);
- }
+ ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);
+
expect(15,LOWORD(r));
expect(0,HIWORD(r));
+ /* test more nonprintable chars */
+ for(ch = 0x00; ch < 0x7F; ch++) {
+ chstr[5] = ch;
+ r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)chstr);
+ expect(TRUE,r);
+ r = SendMessage(hWndStatus, SB_GETTEXT, 0, (LPARAM)charArray);
+ /* substitution with single space */
+ if (ch > 0x00 && ch < 0x20 && ch != '\t')
+ chstr[5] = ' ';
+ ok(strcmp(charArray, chstr) == 0, "Expected %s, got %s\n", chstr, charArray);
+ }
+
/* Set background color */
r = SendMessage(hWndStatus, SB_SETBKCOLOR , 0, RGB(255,0,0));
ok(r == CLR_DEFAULT ||
--
1.5.6.5
More information about the wine-patches
mailing list