WINEMENUBUILDER: small fixes, indentation and comments

Mike McCormack mike at codeweavers.com
Tue Feb 15 19:29:45 CST 2005


This patch attempts to bring winemenubuilder a little more in 
synchronization with the CrossOver version.  Next patch should be to 
convert to using unicode.

Mike


ChangeLog:
* small fixes, indentation and comments
-------------- next part --------------
Index: programs/winemenubuilder/winemenubuilder.c
===================================================================
RCS file: /home/wine/wine/programs/winemenubuilder/winemenubuilder.c,v
retrieving revision 1.22
diff -u -p -r1.22 winemenubuilder.c
--- programs/winemenubuilder/winemenubuilder.c	23 Dec 2004 17:06:43 -0000	1.22
+++ programs/winemenubuilder/winemenubuilder.c	16 Feb 2005 01:28:40 -0000
@@ -221,11 +221,11 @@ static BOOL CALLBACK EnumResNameProc(HMO
 
     if (!sEnumRes->nIndex--)
     {
-      *sEnumRes->pResInfo = FindResourceA(hModule, lpszName, (LPSTR)RT_GROUP_ICON);
-      return FALSE;
+        *sEnumRes->pResInfo = FindResourceA(hModule, lpszName, (LPSTR)RT_GROUP_ICON);
+        return FALSE;
     }
     else
-      return TRUE;
+        return TRUE;
 }
 
 static BOOL ExtractFromEXEDLL(const char *szFileName, int nIndex, const char *szXPMFileName)
@@ -241,16 +241,18 @@ static BOOL ExtractFromEXEDLL(const char
     int nMaxBits = 0;
     int i;
 
-    if (!(hModule = LoadLibraryExA(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE)))
+    hModule = LoadLibraryExA(szFileName, 0, LOAD_LIBRARY_AS_DATAFILE);
+    if (!hModule)
     {
         WINE_ERR("LoadLibraryExA (%s) failed, error %ld\n", szFileName, GetLastError());
-        goto error1;
+        return FALSE;
     }
 
     if (nIndex < 0)
     {
         hResInfo = FindResourceA(hModule, MAKEINTRESOURCEA(-nIndex), (LPSTR)RT_GROUP_ICON);
-        WINE_ERR("FindResourceA (%s) called, return %p, error %ld\n", szFileName, hResInfo, GetLastError());
+        WINE_TRACE("FindResourceA (%s) called, return %p, error %ld\n",
+                   szFileName, hResInfo, GetLastError());
     }
     else
     {
@@ -330,7 +332,7 @@ static BOOL ExtractFromEXEDLL(const char
 }
 
 /* get the Unix file name for a given path, allocating the string */
-inline static char *get_unix_file_name( const char *dos )
+inline static char *get_unix_file_name( LPCSTR dos )
 {
     WCHAR dosW[MAX_PATH];
 
@@ -453,25 +455,30 @@ static char *extract_icon( const char *p
     if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine", &hkey ))
     {
         DWORD size = 0;
-        if (RegQueryValueExA(hkey, "IconsDir", 0, NULL, NULL, &size)==0) {
+
+        if (RegQueryValueExA(hkey, "IconsDir", 0, NULL, NULL, &size)==0)
+        {
             iconsdir = HeapAlloc(GetProcessHeap(), 0, size);
             RegQueryValueExA(hkey, "IconsDir", 0, NULL, iconsdir, &size);
 
-            s=get_unix_file_name(iconsdir);
-            if (s) {
+            s = get_unix_file_name(iconsdir);
+            if (s)
+            {
                 HeapFree(GetProcessHeap(), 0, iconsdir);
                 iconsdir=s;
             }
-        } else {
-		char	path[MAX_PATH];
+        }
+        else
+        {
+            char path[MAX_PATH];
 
-		if (GetTempPath(sizeof(path),path)) {
-		    s=get_unix_file_name(path);
-		    if (s) {
-			iconsdir=s;
-		    }
-		}
-	}
+            if (GetTempPath(sizeof(path),path))
+            {
+                s = get_unix_file_name(path);
+                if (s)
+                    iconsdir = s;
+            }
+        }
         RegCloseKey( hkey );
     }
     if (iconsdir==NULL || *iconsdir=='\0')
@@ -571,13 +578,14 @@ static BOOL DeferToRunOnce(LPWSTR link)
 }
 
 /* This escapes \ in filenames */
-static LPSTR
-escape(LPCSTR arg) {
-    LPSTR      narg, x;
+static LPSTR escape(LPCSTR arg)
+{
+    LPSTR narg, x;
 
     narg = HeapAlloc(GetProcessHeap(),0,2*strlen(arg)+2);
     x = narg;
-    while (*arg) {
+    while (*arg)
+    {
         *x++ = *arg;
         if (*arg == '\\')
             *x++='\\'; /* escape \ */
@@ -709,10 +717,10 @@ static BOOL InvokeShellLinker( IShellLin
 {
     char *link_name, *p, *icon_name = NULL, *work_dir = NULL;
     char *escaped_path = NULL, *escaped_args = NULL;
-    CHAR szDescription[MAX_PATH], szPath[MAX_PATH], szWorkDir[MAX_PATH];
-    CHAR szArgs[MAX_PATH], szIconPath[MAX_PATH];
+    CHAR szDescription[INFOTIPSIZE], szPath[MAX_PATH], szWorkDir[MAX_PATH];
+    CHAR szArgs[INFOTIPSIZE], szIconPath[MAX_PATH];
     int iIconId = 0, r;
-    DWORD ofs=0, csidl= -1;
+    DWORD csidl = -1, ofs = 0;
 
     if ( !link )
     {
@@ -731,25 +739,24 @@ static BOOL InvokeShellLinker( IShellLin
         return TRUE;
     }
 
-    szWorkDir[0]=0;
-    IShellLinkA_GetWorkingDirectory( sl, szWorkDir, sizeof(szWorkDir));
+    szWorkDir[0] = 0;
+    IShellLinkA_GetWorkingDirectory( sl, szWorkDir, MAX_PATH );
     WINE_TRACE("workdir    : %s\n", szWorkDir);
 
     szDescription[0] = 0;
-    IShellLinkA_GetDescription( sl, szDescription, sizeof(szDescription));
+    IShellLinkA_GetDescription( sl, szDescription, INFOTIPSIZE );
     WINE_TRACE("description: %s\n", szDescription);
 
     szPath[0] = 0;
-    IShellLinkA_GetPath( sl, szPath, sizeof(szPath), NULL, SLGP_RAWPATH );
+    IShellLinkA_GetPath( sl, szPath, MAX_PATH, NULL, SLGP_RAWPATH );
     WINE_TRACE("path       : %s\n", szPath);
 
     szArgs[0] = 0;
-    IShellLinkA_GetArguments( sl, szArgs, sizeof(szArgs) );
+    IShellLinkA_GetArguments( sl, szArgs, INFOTIPSIZE );
     WINE_TRACE("args       : %s\n", szArgs);
 
     szIconPath[0] = 0;
-    IShellLinkA_GetIconLocation( sl, szIconPath,
-                        sizeof(szIconPath), &iIconId );
+    IShellLinkA_GetIconLocation( sl, szIconPath, MAX_PATH, &iIconId );
     WINE_TRACE("icon file  : %s\n", szIconPath );
 
     if( !szPath[0] )
@@ -834,6 +841,8 @@ static BOOL Process_Link( LPWSTR linknam
     WCHAR fullname[MAX_PATH];
     DWORD len;
 
+    WINE_TRACE("%s, again %d\n", wine_dbgstr_w(linkname), bAgain);
+
     if( !linkname[0] )
     {
         WINE_ERR("link name missing\n");
@@ -855,7 +864,7 @@ static BOOL Process_Link( LPWSTR linknam
     }
 
     r = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
-                      &IID_IShellLink, (LPVOID *) &sl );
+                          &IID_IShellLink, (LPVOID *) &sl );
     if( FAILED( r ) )
     {
         WINE_ERR("No IID_IShellLink\n");
@@ -872,7 +881,7 @@ static BOOL Process_Link( LPWSTR linknam
     r = IPersistFile_Load( pf, fullname, STGM_READ );
     if( SUCCEEDED( r ) )
     {
-        /* If we something fails (eg. Couldn't extract icon)
+        /* If something fails (eg. Couldn't extract icon)
          * defer this menu entry to reboot via runonce
          */
         if( ! InvokeShellLinker( sl, fullname ) && bAgain )
@@ -940,7 +949,10 @@ int PASCAL WinMain (HINSTANCE hInstance,
     /* running multiple instances of wineshelllink
        at the same time may be dangerous */
     if( WAIT_OBJECT_0 != WaitForSingleObject( hsem, INFINITE ) )
+    {
+        CloseHandle(hsem);
         return FALSE;
+    }
 
     for( p = cmdline; p && *p; )
     {


More information about the wine-patches mailing list