comctl32/status: replace nonprintable characters with spaces on SB_SETTEXT

Nikolay Sivov bunglehead at gmail.com
Sat Feb 28 16:08:26 CST 2009


Changelog:
    - replace nonprintable characters with spaces on SB_SETTEXT

>From c57df7fdec8fe0b82a86675db110990a6966a4d3 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sat, 28 Feb 2009 16:58:05 -0500
Subject: Replace nonprintable characters with spaces on SB_SETTEXT

---
 dlls/comctl32/status.c       |   12 ++++++++++++
 dlls/comctl32/tests/status.c |   12 ++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c
index a56c2a0..fb2274c 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..e82a391 100644
--- a/dlls/comctl32/tests/status.c
+++ b/dlls/comctl32/tests/status.c
@@ -318,17 +318,13 @@ 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);
-    }
+    ok(strcmp(charArray,"InvalidChars\\7 ") == 0, "Expected InvalidChars\\7 , got %s\n", charArray);
+
     expect(15,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));
 
-- 
1.5.6.5





More information about the wine-patches mailing list