Print meaningful message values instead of vague names for unknown messages

Dmitry Timoshkov dmitry at baikal.ru
Fri Jun 4 04:13:41 CDT 2004


Hello,

currently when I'm debugging one of my applications I get weird "???",
"TV_?" and similar message name, without even any numerical presentation.
And it's not necessary that a message will have a value larger than WM_USER.
So, I've changed code to always print numerical message value for unknown
messages.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Print meaningful message values instead of vague names for unknown messages.

--- cvs/hq/wine/windows/spy.c	Sat May 29 02:38:04 2004
+++ wine/windows/spy.c	Fri Jun 04 09:06:29 2004
@@ -1855,53 +1855,30 @@ inline static void set_indent_level( int
 static const char *SPY_GetMsgInternal( UINT msg )
 {
     if (msg <= SPY_MAX_MSGNUM)
-    {
-        if (!MessageTypeNames[msg]) return "???";
         return MessageTypeNames[msg];
-    }
 
     if (msg >= LVM_FIRST && msg <= LVM_FIRST + SPY_MAX_LVMMSGNUM)
-    {
-        if (!LVMMessageTypeNames[msg-LVM_FIRST]) return "LVM_?";
         return LVMMessageTypeNames[msg-LVM_FIRST];
-    }
 
     if (msg >= TV_FIRST && msg <= TV_FIRST + SPY_MAX_TVMSGNUM)
-    {
-        if (!TVMessageTypeNames[msg-TV_FIRST]) return "TV_?";
         return TVMessageTypeNames[msg-TV_FIRST];
-    }
 
     if (msg >= HDM_FIRST && msg <= HDM_FIRST + SPY_MAX_HDMMSGNUM)
-    {
-        if (!HDMMessageTypeNames[msg-HDM_FIRST]) return "HDM_?";
         return HDMMessageTypeNames[msg-HDM_FIRST];
-    }
 
     if (msg >= TCM_FIRST && msg <= TCM_FIRST + SPY_MAX_TCMMSGNUM)
-    {
-        if (!TCMMessageTypeNames[msg-TCM_FIRST]) return "TCM_?";
         return TCMMessageTypeNames[msg-TCM_FIRST];
-    }
 
     if (msg >= PGM_FIRST && msg <= PGM_FIRST + SPY_MAX_PGMMSGNUM)
-    {
-        if (!PGMMessageTypeNames[msg-PGM_FIRST]) return "PGM_?";
         return PGMMessageTypeNames[msg-PGM_FIRST];
-    }
 
     if (msg >= CCM_FIRST && msg <= CCM_FIRST + SPY_MAX_CCMMSGNUM)
-    {
-        if (!CCMMessageTypeNames[msg-CCM_FIRST]) return "???";
         return CCMMessageTypeNames[msg-CCM_FIRST];
-    }
 
     if (msg >= WM_WINE_DESTROYWINDOW && msg <= WM_WINE_DESTROYWINDOW + SPY_MAX_WINEMSGNUM)
-    {
-        if (!WINEMessageTypeNames[msg-WM_WINE_DESTROYWINDOW]) return "???";
         return WINEMessageTypeNames[msg-WM_WINE_DESTROYWINDOW];
-    }
-    return "";
+
+    return NULL;
 }
 
 /***********************************************************************
@@ -1946,13 +1923,10 @@ const USER_MSG *SPY_Bsearch_Msg( const U
 static void SPY_GetMsgStuff( SPY_INSTANCE *sp_e )
 {
     const USER_MSG *p;
-
-    sp_e->msg_name[sizeof(sp_e->msg_name)-1] = 0;
-    strncpy (sp_e->msg_name, SPY_GetMsgInternal( sp_e->msgnum ),
-	     sizeof(sp_e->msg_name)-1);
+    const char *msg_name = SPY_GetMsgInternal( sp_e->msgnum );
 
     sp_e->data_len = 0;
-    if (!sp_e->msg_name[0])
+    if (!msg_name)
     {
 	INT i = 0;
 
@@ -1987,7 +1961,12 @@ static void SPY_GetMsgStuff( SPY_INSTANC
                 return;
             }
         }
-        sprintf( sp_e->msg_name, "WM_USER+%04x", sp_e->msgnum - WM_USER );
+        sprintf( sp_e->msg_name, "%04x", sp_e->msgnum );
+    }
+    else
+    {
+        strncpy(sp_e->msg_name, msg_name, sizeof(sp_e->msg_name)-1);
+        sp_e->msg_name[sizeof(sp_e->msg_name)-1] = 0;
     }
 }
 






More information about the wine-patches mailing list