Duplicated StrRetToStr functions in shell32

Francois Gouget fgouget at free.fr
Wed Oct 31 22:46:41 CST 2001


   Shell32 contains StrRetToStrNA and StrRetToStrNW which are almost
identical to StrRetToBufA and StrRetToBufW. Since shell32 already
imports shlwapi it seems like we should just call the latter functions!
That way I won't have to fix the "0x%p" thing twice.


Changelog:

 * dlls/shell32/shellstring.c

   Implement StrRetToStrN{A,W} by calling shlwapi.StrRetToBuf{A,W}
instead of duplicating the code



--
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
    I haven't lost my mind, it's backed up on tape around here somewhere...
-------------- next part --------------
Index: dlls/shell32/shellstring.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shellstring.c,v
retrieving revision 1.14
diff -u -r1.14 shellstring.c
--- dlls/shell32/shellstring.c	2001/09/10 23:16:31	1.14
+++ dlls/shell32/shellstring.c	2001/10/31 22:26:27
@@ -18,84 +18,27 @@
 
 /************************* STRRET functions ****************************/
 
-/*************************************************************************
- * StrRetToStrN				[SHELL32.96]
- * 
- * converts a STRRET to a normal string
- *
- * NOTES
- *  the pidl is for STRRET OFFSET
- */
+/*************************************************************************/
 HRESULT WINAPI StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *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:
-	    WideCharToMultiByte(CP_ACP, 0, src->u.pOleStr, -1, (LPSTR)dest, len, NULL, NULL);
-/*	    SHFree(src->u.pOleStr);  FIXME: is this right? */
-	    break;
-
-	  case STRRET_CSTRA:
-	    lstrcpynA((LPSTR)dest, src->u.cStr, len);
-	    break;
-
-	  case STRRET_OFFSETA:
-	    lstrcpynA((LPSTR)dest, ((LPCSTR)&pidl->mkid)+src->u.uOffset, len);
-	    break;
-
-	  default:
-	    FIXME("unknown type!\n");
-	    if (len)
-	    {
-	      *(LPSTR)dest = '\0';
-	    }
-	    return(FALSE);
-	}
-	return S_OK;
+    return StrRetToBufA(src,pidl,dest,len);
 }
 
 /*************************************************************************/
 
-HRESULT WINAPI StrRetToStrNW (LPVOID dest1, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
+HRESULT WINAPI StrRetToStrNW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
 {
-    LPWSTR dest = (LPWSTR) dest1;
-	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);
-/*	    SHFree(src->u.pOleStr);  FIXME: is this right? */
-	    break;
-
-	  case STRRET_CSTRA:
-              if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
-                  dest[len-1] = 0;
-	    break;
-
-	  case STRRET_OFFSETA:
-	    if (pidl)
-	    {
-              if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
-                                        dest, len ) && len)
-                  dest[len-1] = 0;
-	    }
-	    break;
-
-	  default:
-	    FIXME("unknown type!\n");
-	    if (len)
-	    { *(LPSTR)dest = '\0';
-	    }
-	    return(FALSE);
-	}
-	return S_OK;
+    return StrRetToBufW(src,pidl,dest,len);
 }
 
-/*************************************************************************/
-
+/*************************************************************************
+ * StrRetToStrN				[SHELL32.96]
+ *
+ * converts a STRRET to a normal string
+ *
+ * NOTES
+ *  the pidl is for STRRET OFFSET
+ */
 HRESULT WINAPI StrRetToStrNAW (LPVOID dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
 {
 	if(SHELL_OsIsUnicode())


More information about the wine-patches mailing list