Duplicate StrRetToStr function in commdlg

Francois Gouget fgouget at free.fr
Wed Oct 31 22:54:32 CST 2001


   Yes, yet another duplicated StrRetToStr function:
COMDLG32_StrRetToStrNW in dlls/commdlg/filedlgbrowser.c. At least this
time it says that it's a copy. I guess it would be better if the
implementations were pointing to each other. It would at least make it
easier to maintain.

   But this case is not as easy as the shell32 case:
 * first the implementation is slightly different: the SHFree is not
commented out in this one. I don't think the difference is
intentional. So who is right?

 * commdlg is not supposed to import shell32. But it already imports a
couple of other functions from shell32 so why not this one? It would be
better than have another inconsisten implementation.

 * except that StrRetToStrNW is not exported. It is StrRetToStrN which
is exported. So is it ok to call StrRetToStrN? Is StrRetToStrNW really
more correct?


   Well, here is a proposed patch that imports StrRetToStrN from shell32
via the already-in-place GPA mechanism and removes
COMDLG32_StrRetToStrNW.

   Comments?


--
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
                           La terre est une bêta...
-------------- next part --------------
Index: dlls/commdlg/cdlg.h
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/cdlg.h,v
retrieving revision 1.17
diff -u -r1.17 cdlg.h
--- dlls/commdlg/cdlg.h	2001/02/12 03:51:04	1.17
+++ dlls/commdlg/cdlg.h	2001/10/31 22:26:22
@@ -103,6 +103,7 @@
 /* SHELL */
 extern LPVOID WINAPI (*COMDLG32_SHAlloc)(DWORD);
 extern DWORD WINAPI (*COMDLG32_SHFree)(LPVOID);
+extern HRESULT WINAPI (*COMDLG32_StrRetToStrNW)(LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl);
 extern BOOL WINAPI (*COMDLG32_SHGetFolderPathA)(HWND,int,HANDLE,DWORD,LPSTR);
 
 extern BOOL  WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType);
Index: dlls/commdlg/cdlg32.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/cdlg32.c,v
retrieving revision 1.18
diff -u -r1.18 cdlg32.c
--- dlls/commdlg/cdlg32.c	2001/06/19 03:34:07	1.18
+++ dlls/commdlg/cdlg32.c	2001/10/31 22:26:22
@@ -35,6 +35,7 @@
 LPVOID WINAPI (*COMDLG32_SHAlloc)(DWORD);
 DWORD WINAPI (*COMDLG32_SHFree)(LPVOID);
 BOOL WINAPI (*COMDLG32_SHGetFolderPathA)(HWND,int,HANDLE,DWORD,LPSTR);
+HRESULT WINAPI (*COMDLG32_StrRetToStrNW)(LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl);
 
 /***********************************************************************
  *	COMDLG32_DllEntryPoint			(COMDLG32.init)
@@ -93,6 +94,7 @@
 		
 		GPA(COMDLG32_SHAlloc, SHELL32_hInstance, (LPCSTR)196L);
 		GPA(COMDLG32_SHFree, SHELL32_hInstance, (LPCSTR)195L);
+		GPA(COMDLG32_StrRetToStrNW, SHELL32_hInstance, (LPCSTR)96L);
 		/* for the first versions of shell32 SHGetFolderPathA is in SHFOLDER.DLL */
 		COMDLG32_SHGetFolderPathA = (void*)GetProcAddress(SHELL32_hInstance,"SHGetFolderPathA");
 		if (!COMDLG32_SHGetFolderPathA)
Index: dlls/commdlg/filedlgbrowser.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlgbrowser.c,v
retrieving revision 1.28
diff -u -r1.28 filedlgbrowser.c
--- dlls/commdlg/filedlgbrowser.c	2001/07/25 00:43:30	1.28
+++ dlls/commdlg/filedlgbrowser.c	2001/10/31 22:26:23
@@ -81,42 +81,6 @@
     TRACE("new current folder %s\n", lpstrPath);
 }
 
-/* copied from shell32 to avoid linking to it */
-static HRESULT COMDLG32_StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)
-{
-	TRACE("dest=0x%p len=0x%lx strret=0x%p pidl=%p stub\n",dest,len,src,pidl);
-
-	switch (src->uType)
-	{
-	  case STRRET_WSTR:
-	    lstrcpynW((LPWSTR)dest, src->u.pOleStr, len);
-	    COMDLG32_SHFree(src->u.pOleStr);
-	    break;
-
-	  case STRRET_CSTRA:
-            if (len && !MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, (LPWSTR)dest, len ))
-                ((LPWSTR)dest)[len-1] = 0;
-	    break;
-
-	  case STRRET_OFFSETA:
-	    if (pidl)
-	    {
-                if (len && !MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset,
-                                                 -1, (LPWSTR)dest, len ))
-                    ((LPWSTR)dest)[len-1] = 0;
-	    }
-	    break;
-
-	  default:
-	    FIXME("unknown type!\n");
-	    if (len)
-	    { *(LPWSTR)dest = '\0';
-	    }
-	    return(FALSE);
-	}
-	return S_OK;
-}
-
 /*
  *	IShellBrowser
  */


More information about the wine-devel mailing list